svn: /php/php-src/ branches/PHP_5_3/ext/mysql/tests/connect.inc branches/PHP_5_3/ext/mysql/tests/mysql_pconn_disable.phpt
trunk/ext/mysql/tests/connect.inc trunk/ext/mysql/tests/mysql_pconn_disable.phpt
| From: | Ulf Wendel | Date: | Thu, 05 Nov 2009 11:51:21 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/ext/mysql/tests/connect.inc branches/PHP_5_3/ext/mysql/tests/mysql_pconn_disable.phpt trunk/ext/mysql/tests/connect.inc trunk/ext/mysql/tests/mysql_pconn_disable.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-60852@lists.php.net to get a copy of this message | ||
uw Thu, 05 Nov 2009 11:51:21 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=290266
Log:
Fixing test: it didn't do a select_db and gave a false-positive with libmysql
Changed paths:
U php/php-src/branches/PHP_5_3/ext/mysql/tests/connect.inc
U php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_pconn_disable.phpt
U php/php-src/trunk/ext/mysql/tests/connect.inc
U php/php-src/trunk/ext/mysql/tests/mysql_pconn_disable.phpt
Modified: php/php-src/branches/PHP_5_3/ext/mysql/tests/connect.inc
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysql/tests/connect.inc 2009-11-05 11:49:14 UTC (rev 290265)
+++ php/php-src/branches/PHP_5_3/ext/mysql/tests/connect.inc 2009-11-05 11:51:21 UTC (rev 290266)
@@ -21,7 +21,7 @@
if (!function_exists('my_mysql_connect')) {
/* wrapper to simplify test porting */
- function my_mysql_connect($host, $user, $passwd, $db, $port, $socket, $flags = NULL) {
+ function my_mysql_connect($host, $user, $passwd, $db, $port, $socket, $flags = NULL, $persistent =
false) {
global $connect_flags;
$flags = ($flags === NULL) ? $connect_flags : $flags;
@@ -31,9 +31,15 @@
else if ($port)
$host = sprintf("%s:%s", $host, $port);
- if (!$link = mysql_connect($host, $user, $passwd, true, $flags)) {
- printf("[000-a] Cannot connect using host '%s', user '%s', password
'****', [%d] %s\n",
- $host, $user, $passwd,
+ if ($persistent) {
+ $link = mysql_pconnect($host, $user, $passwd, $flags);
+ } else {
+ $link = mysql_connect($host, $user, $passwd, true, $flags);
+ }
+
+ if (!$link) {
+ printf("[000-a] Cannot connect using host '%s', user '%s', password
'****', persistent = %d, [%d] %s\n",
+ $host, $user, ($persistent) ? 1 : 0,
mysql_errno(), mysql_error());
return false;
}
Modified: php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_pconn_disable.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_pconn_disable.phpt 2009-11-05 11:49:14 UTC
(rev 290265)
+++ php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_pconn_disable.phpt 2009-11-05 11:51:21 UTC
(rev 290266)
@@ -13,19 +13,11 @@
<?php
require_once("connect.inc");
require_once("table.inc");
- // assert(ini_get('mysql.allow_persistent') == false);
- if ($socket)
- $myhost = sprintf("%s:%s", $host, $socket);
- else if ($port)
- $myhost = sprintf("%s:%s", $host, $port);
- else
- $myhost = $host;
-
- if (($plink = mysql_pconnect($myhost, $user, $passwd)))
+ if (($plink = my_mysql_connect($host, $user, $passwd, $db, $port, $socket, NULL, true)))
printf("[001] Can connect to the server.\n");
- if (($res = @mysql_query('SELECT id FROM test ORDER BY id ASC', $plink)) &&
+ if (($res = mysql_query('SELECT id FROM test ORDER BY id ASC', $plink)) &&
($row = mysql_fetch_assoc($res)) &&
(mysql_free_result($res))) {
printf("[002] Can fetch data using persistent connection! Data = '%s'\n",
@@ -35,7 +27,7 @@
$thread_id = mysql_thread_id($plink);
mysql_close($plink);
- if (!($plink = mysql_pconnect($myhost, $user, $passwd)))
+ if (!($plink = my_mysql_connect($host, $user, $passwd, $db, $port, $socket, NULL, true)))
printf("[003] Cannot connect, [%d] %s\n", mysql_errno(), mysql_error());
if (mysql_thread_id($plink) != $thread_id)
@@ -44,7 +36,7 @@
$thread_id = mysql_thread_id($plink);
mysql_close($plink);
- if (!($plink = mysql_connect($myhost, $user, $passwd, true)))
+ if (!($plink = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)))
printf("[005] Cannot connect, [%d] %s\n", mysql_errno(), mysql_error());
if (mysql_thread_id($plink) == $thread_id)
Modified: php/php-src/trunk/ext/mysql/tests/connect.inc
===================================================================
--- php/php-src/trunk/ext/mysql/tests/connect.inc 2009-11-05 11:49:14 UTC (rev 290265)
+++ php/php-src/trunk/ext/mysql/tests/connect.inc 2009-11-05 11:51:21 UTC (rev 290266)
@@ -21,7 +21,7 @@
if (!function_exists('my_mysql_connect')) {
/* wrapper to simplify test porting */
- function my_mysql_connect($host, $user, $passwd, $db, $port, $socket, $flags = NULL) {
+ function my_mysql_connect($host, $user, $passwd, $db, $port, $socket, $flags = NULL, $persistent =
false) {
global $connect_flags;
$flags = ($flags === NULL) ? $connect_flags : $flags;
@@ -31,9 +31,15 @@
else if ($port)
$host = sprintf("%s:%s", $host, $port);
- if (!$link = mysql_connect($host, $user, $passwd, true, $flags)) {
- printf("[000-a] Cannot connect using host '%s', user '%s', password
'****', [%d] %s\n",
- $host, $user, $passwd,
+ if ($persistent) {
+ $link = mysql_pconnect($host, $user, $passwd, $flags);
+ } else {
+ $link = mysql_connect($host, $user, $passwd, true, $flags);
+ }
+
+ if (!$link) {
+ printf("[000-a] Cannot connect using host '%s', user '%s', password
'****', persistent = %d, [%d] %s\n",
+ $host, $user, ($persistent) ? 1 : 0,
mysql_errno(), mysql_error());
return false;
}
Modified: php/php-src/trunk/ext/mysql/tests/mysql_pconn_disable.phpt
===================================================================
--- php/php-src/trunk/ext/mysql/tests/mysql_pconn_disable.phpt 2009-11-05 11:49:14 UTC (rev 290265)
+++ php/php-src/trunk/ext/mysql/tests/mysql_pconn_disable.phpt 2009-11-05 11:51:21 UTC (rev 290266)
@@ -13,19 +13,11 @@
<?php
require_once("connect.inc");
require_once("table.inc");
- // assert(ini_get('mysql.allow_persistent') == false);
- if ($socket)
- $myhost = sprintf("%s:%s", $host, $socket);
- else if ($port)
- $myhost = sprintf("%s:%s", $host, $port);
- else
- $myhost = $host;
-
- if (($plink = mysql_pconnect($myhost, $user, $passwd)))
+ if (($plink = my_mysql_connect($host, $user, $passwd, $db, $port, $socket, NULL, true)))
printf("[001] Can connect to the server.\n");
- if (($res = @mysql_query('SELECT id FROM test ORDER BY id ASC', $plink)) &&
+ if (($res = mysql_query('SELECT id FROM test ORDER BY id ASC', $plink)) &&
($row = mysql_fetch_assoc($res)) &&
(mysql_free_result($res))) {
printf("[002] Can fetch data using persistent connection! Data = '%s'\n",
@@ -35,7 +27,7 @@
$thread_id = mysql_thread_id($plink);
mysql_close($plink);
- if (!($plink = mysql_pconnect($myhost, $user, $passwd)))
+ if (!($plink = my_mysql_connect($host, $user, $passwd, $db, $port, $socket, NULL, true)))
printf("[003] Cannot connect, [%d] %s\n", mysql_errno(), mysql_error());
if (mysql_thread_id($plink) != $thread_id)
@@ -44,7 +36,7 @@
$thread_id = mysql_thread_id($plink);
mysql_close($plink);
- if (!($plink = mysql_connect($myhost, $user, $passwd, true)))
+ if (!($plink = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)))
printf("[005] Cannot connect, [%d] %s\n", mysql_errno(), mysql_error());
if (mysql_thread_id($plink) == $thread_id)