uw Tue, 22 Sep 2009 11:58:46 +
Revision: http://svn.php.net/viewvc?view=revision&revision=288562
Log:
Fixing test
Changed paths:
U php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_pconn_max_links.phpt
U php/php-src/trunk/ext/mysql/tests/mysql_pconn_max_links.phpt
Modified: php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_pconn_max_links.phpt
===
--- php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_pconn_max_links.phpt 2009-09-22 11:32:40 UTC (rev 288561)
+++ php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_pconn_max_links.phpt 2009-09-22 11:58:46 UTC (rev 288562)
@@ -18,26 +18,35 @@
if (!mysql_select_db($db, $link))
die(sprintf("skip [%d] %s", mysql_errno($link), mysql_error($link)));
+ if (!$res = mysql_query("SELECT CURRENT_USER() AS _user", $link))
+ die(sprintf("skip [%d] %s", mysql_errno($link), mysql_error($link)));
+
+ $row = mysql_fetch_assoc($res);
+ mysql_free_result($res);
+ $host = substr($row['_user'], strrpos($row['_user'], "@") + 1, strlen($row['_user']));
+
mysql_query('DROP USER pcontest', $link);
- if (!mysql_query('CREATE USER pcontest IDENTIFIED BY "pcontest"', $link)) {
+ mysql_query(sprintf('DROP USER pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
+ if (!mysql_query(sprintf('CREATE USER pcontest@"%s" IDENTIFIED BY "pcontest"', mysql_real_escape_string($host, $link)), $link)) {
printf("skip Cannot create second DB user [%d] %s", mysql_errno($link), mysql_error($link));
mysql_close($link);
die();
}
// we might be able to specify the host using CURRENT_USER(), but...
- if (!mysql_query(sprintf("GRANT SELECT ON TABLE %s.test TO pcontest@'%%'", $db), $link)) {
+ if (!mysql_query(sprintf('GRANT SELECT ON TABLE %s.test TO pcontest@"%s"', $db, mysql_real_escape_string($host, $link)), $link)) {
printf("skip Cannot GRANT SELECT to second DB user [%d] %s", mysql_errno($link), mysql_error($link));
- mysql_query('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest', $link);
- mysql_query('DROP USER pcontest', $link);
+ mysql_query(sprintf('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
+ mysql_query(sprintf('DROP USER pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
mysql_close($link);
die();
}
+
mysql_close($link);
?>
--INI--
-mysql.max_links=2
-mysql.max_persistent=1
+mysql.max_links=3
+mysql.max_persistent=2
mysql.allow_persistent=1
--FILE--
enabled'), 500);
if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches))
- printf("[011] Cannot get # active persistent links from phpinfo()");
+ printf("[012] Cannot get # active persistent links from phpinfo()\n");
$num_plinks_kill = $matches[1];
- if ($num_plinks_kill >= $num_plinks)
- printf("[012] Statistics seems to be wrong, got %d active persistent links, expecting < %d links",
+ if ($num_plinks_kill > $num_plinks)
+ printf("[013] Statistics seems to be wrong, got %d active persistent links, expecting < %d links\n",
$num_plinks_kill, $num_plinks);
// The first connection has been closed, the last pconnect() was unable to connect -> no connection open
// We must be able to connect because max_persistent limit has not been reached
if (!$plink = mysql_pconnect($host, 'pcontest', 'newpass'))
- printf("[013] Cannot connect using the second DB, [%d] %s\n",
- mysql_errno(), mysql_error());
+ die(sprintf("[014] Cannot connect using the second DB, [%d] %s\n",
+ mysql_errno(), mysql_error()));
if (!mysql_select_db($db, $plink))
- printf("[014] [%d] %s\n", mysql_errno($plink), mysql_error($plink));
+ printf("[015] [%d] %s\n", mysql_errno($plink), mysql_error($plink));
if (!$res = mysql_query('SELECT id, label FROM test WHERE id = 1', $plink))
- printf("[015] Cannot run query on persistent connection of second DB user, [%d] %s\n",
+ printf("[016] Cannot run query on persistent connection of second DB user, [%d] %s\n",
mysql_errno($plink), mysql_error($plink));
if (!$row = mysql_fetch_assoc($res))
- printf("[016] Cannot run fetch result, [%d] %s\n",
+ printf("[017] Cannot run fetch result, [%d] %s\n",
mysql_errno($plink), mysql_error($plink));
mysql_free_result($res);
var_dump($row);
- mysql_query('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest', $link);
- mysql_query('DROP USER pcontest', $link);
+ mysql_query(sprintf('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
+ mysql_query(sprintf('DROP USER pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
mysql_close($link);
print "done!";
?>
@@ -148,9 +165,16 @@
$host, $myhost, $user, $db, $port, $socket);
}
-...@mysql_query('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest', $link);
-...@mysql_query('DROP USER pcontest', $link);
+if (!$res = mysql_query("SELECT CURRENT_USER() AS _user", $