PHP  
 PHP_5_5
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/mysqli/tests/mysqli_pconn_max_links.phpt ('Persistent connections and mysqli.max_links')

Script

1: <?php
2:     
require_once("connect.inc");
3:     require_once(
'table.inc');
4:
5:
6:     if (!
mysqli_query($link'DROP USER pcontest') ||
7:         !
mysqli_query($link'DROP USER pcontest@localhost') ||
8:         !
mysqli_query($link'CREATE USER pcontest@"%" IDENTIFIED BY "pcontest"') ||
9:         !
mysqli_query($link'CREATE USER pcontest@localhost IDENTIFIED BY "pcontest"') ||
10:         !
mysqli_query($linksprintf("GRANT SELECT ON TABLE %s.test TO pcontest@'%%'"$db)) ||
11:         !
mysqli_query($linksprintf("GRANT SELECT ON TABLE %s.test TO pcontest@'localhost'"$db))) {
12:         
printf("[000] Init failed, [%d] %s\n",
13:             
mysqli_errno($plink), mysqli_error($plink));
14:     }
15:
16:     if (!
$plink my_mysqli_connect('p:' $host'pcontest''pcontest'$db$port$socket))
17:         
printf("[001] Cannot connect using the second DB user created during SKIPIF, [%d] %s\n",
18:             
mysqli_connect_errno(), mysqli_connect_error());
19:
20:     
ob_start();
21:     
phpinfo();
22:     
$phpinfo strip_tags(ob_get_contents());
23:     
ob_end_clean();
24:
25:     
$phpinfo substr($phpinfostrpos($phpinfo'MysqlI Support => enabled'), 500);
26:     if (!
preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU'$phpinfo$matches))
27:         
printf("[002] Cannot get # active persistent links from phpinfo()\n");
28:     
$num_plinks $matches[1];
29:
30:     if (!
$res mysqli_query($plink'SELECT id, label FROM test WHERE id = 1'))
31:         
printf("[003] Cannot run query on persistent connection of second DB user, [%d] %s\n",
32:             
mysqli_errno($plink), mysqli_error($plink));
33:
34:     if (!
$row mysqli_fetch_assoc($res))
35:         
printf("[004] Cannot run fetch result, [%d] %s\n",
36:             
mysqli_errno($plink), mysqli_error($plink));
37:     
mysqli_free_result($res);
38:     
var_dump($row);
39:
40:     
// change the password for the second DB user and kill the persistent connection
41:     
if (!mysqli_query($link'SET PASSWORD FOR pcontest = PASSWORD("newpass")') ||
42:             !
mysqli_query($link'FLUSH PRIVILEGES'))
43:         
printf("[005] Cannot change PW of second DB user, [%d] %s\n"mysqli_errno($link), mysqli_error($link));
44:
45:         
// change the password for the second DB user and kill the persistent connection
46:     
if (!mysqli_query($link'SET PASSWORD FOR pcontest@localhost = PASSWORD("newpass")') ||
47:             !
mysqli_query($link'FLUSH PRIVILEGES'))
48:         
printf("[006] Cannot change PW of second DB user, [%d] %s\n"mysqli_errno($link), mysqli_error($link));
49:
50:     
// persistent connections cannot be closed but only be killed
51:     
$pthread_id mysqli_thread_id($plink);
52:     if (!
mysqli_query($linksprintf('KILL %d'$pthread_id)))
53:         
printf("[007] Cannot KILL persistent connection of second DB user, [%d] %s\n"mysqli_errno($link), mysqli_error($link));
54:     
// give the server a second to really kill the thread
55:     
sleep(1);
56:
57:     if (!
$res mysqli_query($link"SHOW FULL PROCESSLIST"))
58:         
printf("[008] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
59:
60:     
$running_threads = array();
61:     while (
$row mysqli_fetch_assoc($res))
62:         
$running_threads[$row['Id']] = $row;
63:     
mysqli_free_result($res);
64:
65:     if (isset(
$running_threads[$pthread_id]))
66:         
printf("[009] Persistent connection has not been killed\n");
67:
68:     
// this fails and we have 0 (<= $num_plinks) connections
69:     
if ($plink = @my_mysqli_connect('p:' $host'pcontest''pcontest'$db$port$socket))
70:         
printf("[010] Can connect using the old password, [%d] %s\n",
71:             
mysqli_connect_errno($link), mysqli_connect_error($link));
72:
73:     
ob_start();
74:     
phpinfo();
75:     
$phpinfo strip_tags(ob_get_contents());
76:     
ob_end_clean();
77:     
$phpinfo substr($phpinfostripos($phpinfo'MysqlI Support => enabled'), 500);
78:     if (!
preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU'$phpinfo$matches))
79:         
printf("[010] Cannot get # of active persistent links from phpinfo()\n");
80:
81:     
$num_plinks_kill $matches[1];
82:     if (
$num_plinks_kill $num_plinks)
83:         
printf("[011] Expecting Active Persistent Links < %d, got %d\n"$num_plinks$num_plinks_kill);
84:
85:     if (!
$plink my_mysqli_connect('p:' $host'pcontest''newpass'$db$port$socket))
86:         
printf("[012] Cannot connect using the new password, [%d] %s\n",
87:             
mysqli_connect_errno(), mysqli_connect_error());
88:
89:     if (!
$res mysqli_query($plink'SELECT id, label FROM test WHERE id = 1'))
90:         
printf("[013] Cannot run query on persistent connection of second DB user, [%d] %s\n",
91:             
mysqli_errno($plink), mysqli_error($plink));
92:
93:     if (!
$row mysqli_fetch_assoc($res))
94:         
printf("[014] Cannot run fetch result, [%d] %s\n",
95:             
mysqli_errno($plink), mysqli_error($plink));
96:     
mysqli_free_result($res);
97:     
var_dump($row);
98:
99:     if (
$plink2 my_mysqli_connect('p:' $host'pcontest''newpass'$db$port$socket))
100:         
printf("[015] Can open more persistent connections than allowed, [%d] %s\n",
101:             
mysqli_connect_errno(), mysqli_connect_error());
102:
103:     
ob_start();
104:     
phpinfo();
105:     
$phpinfo strip_tags(ob_get_contents());
106:     
ob_end_clean();
107:     
$phpinfo substr($phpinfostripos($phpinfo'MysqlI Support => enabled'), 500);
108:     if (!
preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU'$phpinfo$matches))
109:         
printf("[016] Cannot get # of active persistent links from phpinfo()\n");
110:
111:     
$num_plinks $matches[1];
112:     if (
$num_plinks > (int)ini_get('mysqli.max_persistent'))
113:         
printf("[017] mysqli.max_persistent=%d allows %d open connections!\n"ini_get('mysqli.max_persistent'),$num_plinks);
114:
115:     
mysqli_query($link'REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest');
116:     
mysqli_query($link'DROP USER pcontest');
117:     
mysqli_close($link);
118:     print 
"done!";
119:
?>
120:

Expected

array(2) {
  [%u|b%"id"]=>
  %unicode|string%(1) "1"
  [%u|b%"label"]=>
  %unicode|string%(1) "a"
}
array(2) {
  [%u|b%"id"]=>
  %unicode|string%(1) "1"
  [%u|b%"label"]=>
  %unicode|string%(1) "a"
}

Warning: %s: Too many open persistent links (%d) in %s on line %d
done!

Output

array(2) {
  ["id"]=>
  string(1) "1"
  ["label"]=>
  string(1) "a"
}
[005] Cannot change PW of second DB user, [1044] Access denied for user 'phpqa'@'localhost' to database 'mysql'
[006] Cannot change PW of second DB user, [1044] Access denied for user 'phpqa'@'localhost' to database 'mysql'
[007] Cannot KILL persistent connection of second DB user, [1095] You are not owner of thread 101814
[010] Can connect using the old password, [0] 

Warning: mysqli_real_connect(): Too many open persistent links (2) in /var/php_gcov/PHP_5_5/ext/mysqli/tests/connect.inc on line 94
[012] Cannot connect using the new password, [0] 

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /var/php_gcov/PHP_5_5/ext/mysqli/tests/mysqli_pconn_max_links.php on line 89

Warning: mysqli_errno() expects parameter 1 to be mysqli, boolean given in /var/php_gcov/PHP_5_5/ext/mysqli/tests/mysqli_pconn_max_links.php on line 91

Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /var/php_gcov/PHP_5_5/ext/mysqli/tests/mysqli_pconn_max_links.php on line 91
[013] Cannot run query on persistent connection of second DB user, [0] 

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in /var/php_gcov/PHP_5_5/ext/mysqli/tests/mysqli_pconn_max_links.php on line 93

Warning: mysqli_errno() expects parameter 1 to be mysqli, boolean given in /var/php_gcov/PHP_5_5/ext/mysqli/tests/mysqli_pconn_max_links.php on line 95

Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /var/php_gcov/PHP_5_5/ext/mysqli/tests/mysqli_pconn_max_links.php on line 95
[014] Cannot run fetch result, [0] 

Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, null given in /var/php_gcov/PHP_5_5/ext/mysqli/tests/mysqli_pconn_max_links.php on line 96
NULL

Warning: mysqli_real_connect(): Too many open persistent links (2) in /var/php_gcov/PHP_5_5/ext/mysqli/tests/connect.inc on line 94
done!

Diff

007+ [005] Cannot change PW of second DB user, [1044] Access denied for user 'phpqa'@'localhost' to database 'mysql'
008+ [006] Cannot change PW of second DB user, [1044] Access denied for user 'phpqa'@'localhost' to database 'mysql'
009+ [007] Cannot KILL persistent connection of second DB user, [1095] You are not owner of thread 101814
010+ [010] Can connect using the old password, [0] 
007- array(2) {
008-   [%u|b%"id"]=>
009-   %unicode|string%(1) "1"
010-   [%u|b%"label"]=>
011-   %unicode|string%(1) "a"
012- }
013+ [012] Cannot connect using the new password, [0] 
015- done!
014+ 
015+ Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /var/php_gcov/PHP_5_5/ext/mysqli/tests/mysqli_pconn_max_links.php on line 89
016+ 
017+ Warning: mysqli_errno() expects parameter 1 to be mysqli, boolean given in /var/php_gcov/PHP_5_5/ext/mysqli/tests/mysqli_pconn_max_links.php on line 91
018+ 
019+ Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /var/php_gcov/PHP_5_5/ext/mysqli/tests/mysqli_pconn_max_links.php on line 91
020+ [013] Cannot run query on persistent connection of second DB user, [0] 
021+ 
022+ Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in /var/php_gcov/PHP_5_5/ext/mysqli/tests/mysqli_pconn_max_links.php on line 93
023+ 
024+ Warning: mysqli_errno() expects parameter 1 to be mysqli, boolean given in /var/php_gcov/PHP_5_5/ext/mysqli/tests/mysqli_pconn_max_links.php on line 95
025+ 
026+ Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /var/php_gcov/PHP_5_5/ext/mysqli/tests/mysqli_pconn_max_links.php on line 95
027+ [014] Cannot run fetch result, [0] 
028+ 
029+ Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, null given in /var/php_gcov/PHP_5_5/ext/mysqli/tests/mysqli_pconn_max_links.php on line 96
030+ NULL
031+ 
032+ Warning: mysqli_real_connect(): Too many open persistent links (2) in /var/php_gcov/PHP_5_5/ext/mysqli/tests/connect.inc on line 94
033+ done!

 

Generated at Tue, 22 Apr 2014 03:58:31 +0000 (2 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.