1--TEST--
2mysqli_pconnect() - mysqli.allow_persistent = 0
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8
9die("skip TODO - we need to add a user level way to check if CHANGE_USER gets called by pconnect");
10?>
11--INI--
12mysqli.allow_persistent=0
13mysqli.max_persistent=2
14mysqli.max_links=2
15--FILE--
16<?php
17    require_once 'connect.inc';
18
19    $host = 'p:' . $host;
20    if (!$link1 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
21        // automatic downgrade to normal connections has failed
22        printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
23            $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
24    }
25    if (!mysqli_query($link1, "SET @pcondisabled = 'Connection 1'"))
26        printf("[002] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n",
27            mysqli_errno($link1), mysqli_error($link1));
28
29    if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
30        // automatic downgrade to normal connections has failed
31        printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
32            $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
33    }
34
35    if (!$res = mysqli_query($link1, 'SELECT @pcondisabled AS _test'))
36        printf("[004] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
37
38    $row = mysqli_fetch_assoc($res);
39    printf("Connecction 1 - SELECT @pcondisabled -> '%s'\n", $row['_test']);
40    mysqli_free_result($res);
41
42    if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test'))
43        printf("[005] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
44
45    $row = mysqli_fetch_assoc($res);
46    printf("Connecction 2 - SELECT @pcondisabled -> '%s'\n", $row['_test']);
47    mysqli_free_result($res);
48
49    if ($link1 === $link2)
50        printf("[006] Links should not be identical\n");
51
52    mysqli_close($link1);
53    mysqli_close($link2);
54    print "done!";
55?>
56--EXPECTF--
57Warning: my_mysqli_connect(): Persistent connections are disabled. Downgrading to normal in %s on line %d
58
59Warning: my_mysqli_connect(): Persistent connections are disabled. Downgrading to normal in %s on line %d
60Connecction 1 - SELECT @pcondisabled -> 'Connection 1'
61Connecction 2 - SELECT @pcondisabled -> ''
62done!
63