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/mysql/tests/mysql_pconn_max_links.phpt ('Persistent connections and mysql.max_persistent')

Script

1: <?php
2:     
require_once("connect.inc");
3:     require_once(
'table.inc');
4:
5:     if (
$socket)
6:         
$host sprintf("%s:%s"$host$socket);
7:     else if (
$port)
8:         
$host sprintf("%s:%s"$host$port);
9:
10:     if (!
$plink mysql_pconnect($host$user$passwd))
11:         
printf("[001] Cannot connect using the second DB user created during SKIPIF, [%d] %s\n",
12:             
mysql_errno(), mysql_error());
13:
14:     if (!
mysql_select_db($db$plink))
15:         
printf("[002] [%d] %s\n"mysql_errno($plink), mysql_error($plink));
16:
17:     
ob_start();
18:     
phpinfo();
19:     
$phpinfo strip_tags(ob_get_contents());
20:     
ob_end_clean();
21:     
$phpinfo substr($phpinfostrpos($phpinfo'MySQL Support => enabled'), 500);
22:     if (!
preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU'$phpinfo$matches))
23:         
printf("[003] Cannot get # active persistent links from phpinfo()");
24:     
$num_plinks $matches[1];
25:
26:     if (!
$res mysql_query('SELECT id, label FROM test WHERE id = 1'$plink))
27:         
printf("[004] Cannot run query on persistent connection of second DB user, [%d] %s\n",
28:             
mysql_errno($plink), mysql_error($plink));
29:
30:     if (!
$row mysql_fetch_assoc($res))
31:         
printf("[005] Cannot run fetch result, [%d] %s\n",
32:             
mysql_errno($plink), mysql_error($plink));
33:     
mysql_free_result($res);
34:     
var_dump($row);
35:
36:     
// change the password for the second DB user and kill the persistent connection
37:     
if (!$res mysql_query("SELECT CURRENT_USER() AS _user"$link))
38:         
printf("[006] [%d] %s"mysql_errno($link), mysql_error($link));
39:
40:     
$row mysql_fetch_assoc($res);
41:     
mysql_free_result($res);
42:     
$host substr($row['_user'], strrpos($row['_user'], "@") + 1strlen($row['_user']));
43:
44:     
$sql sprintf('SET PASSWORD FOR pcontest@"%s" = PASSWORD("newpass")'mysql_real_escape_string($host$link));
45:     if (!
mysql_query($sql$link))
46:         
printf("[007] Cannot change PW of second DB user, [%d] %s\n"mysql_errno($link), mysql_error($link));
47:
48:     
// persistent connections cannot be closed but only be killed
49:     
$pthread_id mysql_thread_id($plink);
50:     if (!
mysql_query(sprintf('KILL %d'$pthread_id), $link))
51:         
printf("[008] Cannot KILL persistent connection of second DB user, [%d] %s\n"mysql_errno($link), mysql_error($link));
52:     
// give the server a second to really kill the thread
53:     
sleep(1);
54:
55:     if (!
$res mysql_query("SHOW FULL PROCESSLIST"$link))
56:         
printf("[009] [%d] %s\n"mysql_errno($link), mysql_error($link));
57:
58:     
$running_threads = array();
59:     while (
$row mysql_fetch_assoc($res))
60:         
$running_threads[$row['Id']] = $row;
61:     
mysql_free_result($res);
62:
63:     if (isset(
$running_threads[$pthread_id]))
64:         
printf("[010] Persistent connection has not been killed\n");
65:
66:     
// we might get the old handle
67:     
if ($plink = @mysql_pconnect($host'pcontest''pcontest'))
68:         
printf("[011] Can connect using the old password, [%d] %s\n",
69:             
mysql_errno(), mysql_error());
70:
71:     
ob_start();
72:     
phpinfo();
73:     
$phpinfo strip_tags(ob_get_contents());
74:     
ob_end_clean();
75:     
$phpinfo substr($phpinfostrpos($phpinfo'MySQL Support => enabled'), 500);
76:     if (!
preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU'$phpinfo$matches))
77:         
printf("[012] Cannot get # active persistent links from phpinfo()\n");
78:
79:     
$num_plinks_kill $matches[1];
80:     if (
$num_plinks_kill $num_plinks)
81:         
printf("[013] Statistics seems to be wrong, got %d active persistent links, expecting < %d links\n",
82:             
$num_plinks_kill$num_plinks);
83:
84:     
// The first connection has been closed, the last pconnect() was unable to connect -> no connection open
85:     // We must be able to connect because max_persistent limit has not been reached
86:     
if (!$plink mysql_pconnect($host'pcontest''newpass'))
87:         die(
sprintf("[014] Cannot connect using the second DB, [%d] %s\n",
88:             
mysql_errno(), mysql_error()));
89:
90:     if (!
mysql_select_db($db$plink))
91:         
printf("[015] [%d] %s\n"mysql_errno($plink), mysql_error($plink));
92:
93:     if (!
$res mysql_query('SELECT id, label FROM test WHERE id = 1'$plink))
94:         
printf("[016] Cannot run query on persistent connection of second DB user, [%d] %s\n",
95:             
mysql_errno($plink), mysql_error($plink));
96:
97:     if (!
$row mysql_fetch_assoc($res))
98:         
printf("[017] Cannot run fetch result, [%d] %s\n",
99:             
mysql_errno($plink), mysql_error($plink));
100:     
mysql_free_result($res);
101:     
var_dump($row);
102:
103:     
mysql_query(sprintf('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest@"%s"'mysql_real_escape_string($host$link)), $link);
104:     
mysql_query(sprintf('DROP USER pcontest@"%s"'mysql_real_escape_string($host$link)), $link);
105:     
mysql_close($link);
106:     print 
"done!";
107:
?>
108:

Expected

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d

Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
array(2) {
  [%u|b%"id"]=>
  %unicode|string%(1) "1"
  [%u|b%"label"]=>
  %unicode|string%(1) "a"
}

Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
array(2) {
  [%u|b%"id"]=>
  %unicode|string%(1) "1"
  [%u|b%"label"]=>
  %unicode|string%(1) "a"
}
done!

Output

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /var/php_gcov/PHP_5_5/ext/mysql/tests/connect.inc on line 37

Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /var/php_gcov/PHP_5_5/ext/mysql/tests/mysql_pconn_max_links.php on line 10
array(2) {
  ["id"]=>
  string(1) "1"
  ["label"]=>
  string(1) "a"
}
[007] Cannot change PW of second DB user, [1044] Access denied for user 'phpqa'@'localhost' to database 'mysql'
[011] Can connect using the old password, [0] 
[013] Statistics seems to be wrong, got 2 active persistent links, expecting < 1 links

Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /var/php_gcov/PHP_5_5/ext/mysql/tests/mysql_pconn_max_links.php on line 86

Warning: mysql_pconnect(): Too many open links (3) in /var/php_gcov/PHP_5_5/ext/mysql/tests/mysql_pconn_max_links.php on line 86
[014] Cannot connect using the second DB, [0]

Diff

010+ [007] Cannot change PW of second DB user, [1044] Access denied for user 'phpqa'@'localhost' to database 'mysql'
011+ [011] Can connect using the old password, [0] 
012+ [013] Statistics seems to be wrong, got 2 active persistent links, expecting < 1 links
012- array(2) {
013-   [%u|b%"id"]=>
014-   %unicode|string%(1) "1"
015+ 
016+ Warning: mysql_pconnect(): Too many open links (3) in /var/php_gcov/PHP_5_5/ext/mysql/tests/mysql_pconn_max_links.php on line 86
017+ [014] Cannot connect using the second DB, [0]
015-   [%u|b%"label"]=>
016-   %unicode|string%(1) "a"
017- }
018- done!

 

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

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