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