1--TEST--
2Persistent connections - limits (-1, unlimited)
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7require_once("connect.inc");
8?>
9--INI--
10mysqli.allow_persistent=1
11mysqli.max_persistent=-1
12mysqli.max_links=-1
13--FILE--
14<?php
15    require_once("connect.inc");
16    // opens a regular connection
17    require_once("table.inc");
18
19    if (!$res = mysqli_query($link, "SELECT 'works..' as _desc"))
20        printf("[001] Cannot run query, [%d] %s\n",
21            mysqli_errno($link), mysqli_error($link));
22
23    $row = mysqli_fetch_assoc($res);
24    mysqli_free_result($res);
25    printf("Regular connection 1 - '%s'\n", $row['_desc']);
26
27    if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
28        printf("[002] Cannot open second regular connection, [%d] %s\n",
29            mysqli_connect_errno(), mysqli_connect_error());
30
31    if (!$res = mysqli_query($link2, "SELECT 'works...' as _desc"))
32        printf("[003] Cannot run query, [%d] %s\n",
33            mysqli_errno($link2), mysqli_error($link2));
34
35    $row = mysqli_fetch_assoc($res);
36    mysqli_free_result($res);
37    printf("Regular connection 2 - '%s'\n", $row['_desc']);
38
39    $host = 'p:' . $host;
40    if (!$plink = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
41        printf("[004] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
42            $host, $user, $db, $port, $socket,
43            mysqli_connect_errno(), mysqli_connect_error());
44
45    if (!$res = mysqli_query($plink, "SELECT 'works...' as _desc"))
46        printf("[005] Cannot run query, [%d] %s\n",
47            mysqli_errno($plink), mysqli_error($plink));
48
49    $row = mysqli_fetch_assoc($res);
50    mysqli_free_result($res);
51    printf("Persistent connection 1 - '%s'\n", $row['_desc']);
52
53    if (!$plink2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
54        printf("[006] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
55            $host, $user, $db, $port, $socket,
56            mysqli_connect_errno(), mysqli_connect_error());
57
58    if (!$res = mysqli_query($plink2, "SELECT 'works...' as _desc"))
59        printf("[007] Cannot run query, [%d] %s\n",
60            mysqli_errno($plink2), mysqli_error($plink2));
61
62    $row = mysqli_fetch_assoc($res);
63    mysqli_free_result($res);
64    printf("Persistent connection 2 - '%s'\n", $row['_desc']);
65
66    $plink3 = mysqli_init();
67    if (!my_mysqli_real_connect($plink3, $host, $user, $passwd, $db, $port, $socket))
68        printf("[008] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
69            $host, $user, $db, $port, $socket,
70            mysqli_connect_errno(), mysqli_connect_error());
71
72    if (!$res = mysqli_query($plink3, "SELECT 'works...' as _desc"))
73        printf("[009] Cannot run query, [%d] %s\n",
74            mysqli_errno($plink2), mysqli_error($plink2));
75
76    $row = mysqli_fetch_assoc($res);
77    mysqli_free_result($res);
78    printf("Persistent connection 3 - '%s'\n", $row['_desc']);
79
80    mysqli_close($link);
81    mysqli_close($link2);
82    mysqli_close($plink);
83    mysqli_close($plink2);
84    mysqli_close($plink3);
85    print "done!";
86?>
87--CLEAN--
88<?php
89	require_once("clean_table.inc");
90?>
91--EXPECT--
92Regular connection 1 - 'works..'
93Regular connection 2 - 'works...'
94Persistent connection 1 - 'works...'
95Persistent connection 2 - 'works...'
96Persistent connection 3 - 'works...'
97done!
98