uw Thu, 01 Sep 2011 15:45:47 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=315998
Log: Fixing error handling. Skip if load data is not allowed Changed paths: U php/php-src/branches/PHP_5_3/ext/mysql/tests/bug53649.phpt U php/php-src/branches/PHP_5_4/ext/mysql/tests/bug53649.phpt U php/php-src/trunk/ext/mysql/tests/bug53649.phpt
Modified: php/php-src/branches/PHP_5_3/ext/mysql/tests/bug53649.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysql/tests/bug53649.phpt 2011-09-01 15:42:07 UTC (rev 315997) +++ php/php-src/branches/PHP_5_3/ext/mysql/tests/bug53649.phpt 2011-09-01 15:45:47 UTC (rev 315998) @@ -4,28 +4,46 @@ <?php require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); + +if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { + die(sprintf("skip Connect failed, [%d] %s\n", mysqlerrno(), mysqli_error())); +} + +if (!mysql_query("DROP TABLE IF EXISTS test", $link) || + !mysql_query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine, $link)) + die(sprintf("skip [%d] %s\n", mysql_errno($link), mysql_error($link))); + +if (false === file_put_contents('bug53649.data', "1\n2\n3\n")) + die(sprintf("skip Failed to create data file\n")); + +if (!mysql_query("LOAD DATA LOCAL INFILE 'bug53649.data' INTO TABLE test", $link) && + 1148 == mysql_errno($link)) + die("skip LOAD DATA LOAD INFILE not allowed\n"); ?> --FILE-- <?php require_once("connect.inc"); if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + printf("[001] Connect failed, [%d] %s\n", mysqlerrno(), mysqli_error()); } - if (!mysql_query("DROP TABLE IF EXISTS tlocaldata", $link)) { - printf("[002] [%d] %s\n", $link->errno, $link->error); + if (!mysql_query("DROP TABLE IF EXISTS test", $link)) { + printf("[002] [%d] %s\n", mysql_errno($link), mysql_error($link)); } - if (!mysql_query("CREATE TABLE tlocaldata (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine, $link)) { - printf("[003] [%d] %s\n", $link->errno, $link->error); + if (!mysql_query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine, $link)) { + printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } - file_put_contents('bug53649.data', "1\n2\n3\n"); + if (false === file_put_contents('bug53649.data', "1\n2\n3\n")) + printf("[004] Failed to create data file\n"); - mysql_query("SELECT 1 FROM DUAL", $link); + if (!mysql_query("SELECT 1 FROM DUAL", $link)) + printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link)); - if (!mysql_query("LOAD DATA LOCAL INFILE 'bug53649.data' INTO TABLE tlocaldata", $link)) { + if (!mysql_query("LOAD DATA LOCAL INFILE 'bug53649.data' INTO TABLE test", $link)) { + printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link)); echo "bug"; } else { echo "done"; @@ -41,7 +59,7 @@ $host, $user, $db, $port, $socket); } -if (!mysql_query($link, 'DROP TABLE IF EXISTS tlocaldata', $link)) { +if (!mysql_query($link, 'DROP TABLE IF EXISTS test', $link)) { printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } Modified: php/php-src/branches/PHP_5_4/ext/mysql/tests/bug53649.phpt =================================================================== --- php/php-src/branches/PHP_5_4/ext/mysql/tests/bug53649.phpt 2011-09-01 15:42:07 UTC (rev 315997) +++ php/php-src/branches/PHP_5_4/ext/mysql/tests/bug53649.phpt 2011-09-01 15:45:47 UTC (rev 315998) @@ -4,28 +4,46 @@ <?php require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); + +if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { + die(sprintf("skip Connect failed, [%d] %s\n", mysqlerrno(), mysqli_error())); +} + +if (!mysql_query("DROP TABLE IF EXISTS test", $link) || + !mysql_query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine, $link)) + die(sprintf("skip [%d] %s\n", mysql_errno($link), mysql_error($link))); + +if (false === file_put_contents('bug53649.data', "1\n2\n3\n")) + die(sprintf("skip Failed to create data file\n")); + +if (!mysql_query("LOAD DATA LOCAL INFILE 'bug53649.data' INTO TABLE test", $link) && + 1148 == mysql_errno($link)) + die("skip LOAD DATA LOAD INFILE not allowed\n"); ?> --FILE-- <?php require_once("connect.inc"); if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + printf("[001] Connect failed, [%d] %s\n", mysqlerrno(), mysqli_error()); } - if (!mysql_query("DROP TABLE IF EXISTS tlocaldata", $link)) { - printf("[002] [%d] %s\n", $link->errno, $link->error); + if (!mysql_query("DROP TABLE IF EXISTS test", $link)) { + printf("[002] [%d] %s\n", mysql_errno($link), mysql_error($link)); } - if (!mysql_query("CREATE TABLE tlocaldata (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine, $link)) { - printf("[003] [%d] %s\n", $link->errno, $link->error); + if (!mysql_query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine, $link)) { + printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } - file_put_contents('bug53649.data', "1\n2\n3\n"); + if (false === file_put_contents('bug53649.data', "1\n2\n3\n")) + printf("[004] Failed to create data file\n"); - mysql_query("SELECT 1 FROM DUAL", $link); + if (!mysql_query("SELECT 1 FROM DUAL", $link)) + printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link)); - if (!mysql_query("LOAD DATA LOCAL INFILE 'bug53649.data' INTO TABLE tlocaldata", $link)) { + if (!mysql_query("LOAD DATA LOCAL INFILE 'bug53649.data' INTO TABLE test", $link)) { + printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link)); echo "bug"; } else { echo "done"; @@ -41,7 +59,7 @@ $host, $user, $db, $port, $socket); } -if (!mysql_query($link, 'DROP TABLE IF EXISTS tlocaldata', $link)) { +if (!mysql_query($link, 'DROP TABLE IF EXISTS test', $link)) { printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } Modified: php/php-src/trunk/ext/mysql/tests/bug53649.phpt =================================================================== --- php/php-src/trunk/ext/mysql/tests/bug53649.phpt 2011-09-01 15:42:07 UTC (rev 315997) +++ php/php-src/trunk/ext/mysql/tests/bug53649.phpt 2011-09-01 15:45:47 UTC (rev 315998) @@ -4,28 +4,46 @@ <?php require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); + +if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { + die(sprintf("skip Connect failed, [%d] %s\n", mysqlerrno(), mysqli_error())); +} + +if (!mysql_query("DROP TABLE IF EXISTS test", $link) || + !mysql_query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine, $link)) + die(sprintf("skip [%d] %s\n", mysql_errno($link), mysql_error($link))); + +if (false === file_put_contents('bug53649.data', "1\n2\n3\n")) + die(sprintf("skip Failed to create data file\n")); + +if (!mysql_query("LOAD DATA LOCAL INFILE 'bug53649.data' INTO TABLE test", $link) && + 1148 == mysql_errno($link)) + die("skip LOAD DATA LOAD INFILE not allowed\n"); ?> --FILE-- <?php require_once("connect.inc"); if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + printf("[001] Connect failed, [%d] %s\n", mysqlerrno(), mysqli_error()); } - if (!mysql_query("DROP TABLE IF EXISTS tlocaldata", $link)) { - printf("[002] [%d] %s\n", $link->errno, $link->error); + if (!mysql_query("DROP TABLE IF EXISTS test", $link)) { + printf("[002] [%d] %s\n", mysql_errno($link), mysql_error($link)); } - if (!mysql_query("CREATE TABLE tlocaldata (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine, $link)) { - printf("[003] [%d] %s\n", $link->errno, $link->error); + if (!mysql_query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine, $link)) { + printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } - file_put_contents('bug53649.data', "1\n2\n3\n"); + if (false === file_put_contents('bug53649.data', "1\n2\n3\n")) + printf("[004] Failed to create data file\n"); - mysql_query("SELECT 1 FROM DUAL", $link); + if (!mysql_query("SELECT 1 FROM DUAL", $link)) + printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link)); - if (!mysql_query("LOAD DATA LOCAL INFILE 'bug53649.data' INTO TABLE tlocaldata", $link)) { + if (!mysql_query("LOAD DATA LOCAL INFILE 'bug53649.data' INTO TABLE test", $link)) { + printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link)); echo "bug"; } else { echo "done"; @@ -41,7 +59,7 @@ $host, $user, $db, $port, $socket); } -if (!mysql_query($link, 'DROP TABLE IF EXISTS tlocaldata', $link)) { +if (!mysql_query($link, 'DROP TABLE IF EXISTS test', $link)) { printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php