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