]> granicus.if.org Git - php/commitdiff
Fixing error handling. Skip if load data is not allowed
authorUlf Wendel <uw@php.net>
Thu, 1 Sep 2011 15:45:47 +0000 (15:45 +0000)
committerUlf Wendel <uw@php.net>
Thu, 1 Sep 2011 15:45:47 +0000 (15:45 +0000)
ext/mysql/tests/bug53649.phpt

index 126f34b73825273e73d14cbed73993190d5478fa..70bf9bed3630b4277b11bd5f34904348e75138b6 100644 (file)
@@ -4,28 +4,46 @@ Bug #53649 (mysql_query with "load data" unable to save result set)
 <?php\r
 require_once('skipif.inc');\r
 require_once('skipifconnectfailure.inc');\r
+\r
+if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) {\r
+       die(sprintf("skip Connect failed, [%d] %s\n", mysqlerrno(), mysqli_error()));\r
+}\r
+\r
+if (!mysql_query("DROP TABLE IF EXISTS test", $link) ||\r
+       !mysql_query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine, $link))\r
+       die(sprintf("skip [%d] %s\n", mysql_errno($link), mysql_error($link)));\r
+\r
+if (false === file_put_contents('bug53649.data', "1\n2\n3\n"))\r
+       die(sprintf("skip Failed to create data file\n"));\r
+\r
+if (!mysql_query("LOAD DATA LOCAL INFILE 'bug53649.data' INTO TABLE test", $link) &&\r
+       1148 == mysql_errno($link))\r
+               die("skip LOAD DATA LOAD INFILE not allowed\n");\r
 ?>\r
 --FILE--\r
 <?php\r
        require_once("connect.inc");\r
 \r
        if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) {\r
-               printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());\r
+               printf("[001] Connect failed, [%d] %s\n", mysqlerrno(), mysqli_error());\r
        }\r
 \r
-       if (!mysql_query("DROP TABLE IF EXISTS tlocaldata", $link)) {\r
-               printf("[002] [%d] %s\n", $link->errno, $link->error);\r
+       if (!mysql_query("DROP TABLE IF EXISTS test", $link)) {\r
+               printf("[002] [%d] %s\n", mysql_errno($link), mysql_error($link));\r
        }\r
 \r
-       if (!mysql_query("CREATE TABLE tlocaldata (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine, $link)) {\r
-               printf("[003] [%d] %s\n", $link->errno, $link->error);\r
+       if (!mysql_query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine, $link)) {\r
+               printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));\r
        }\r
 \r
-       file_put_contents('bug53649.data', "1\n2\n3\n");\r
+       if (false === file_put_contents('bug53649.data', "1\n2\n3\n"))\r
+               printf("[004] Failed to create data file\n");\r
 \r
-       mysql_query("SELECT 1 FROM DUAL", $link);\r
+       if (!mysql_query("SELECT 1 FROM DUAL", $link))\r
+         printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));\r
 \r
-       if (!mysql_query("LOAD DATA LOCAL INFILE 'bug53649.data' INTO TABLE tlocaldata", $link)) {\r
+       if (!mysql_query("LOAD DATA LOCAL INFILE 'bug53649.data' INTO TABLE test", $link)) {\r
+               printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));\r
                echo "bug";\r
        } else {\r
                echo "done";\r
@@ -41,7 +59,7 @@ if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) {
                $host, $user, $db, $port, $socket);\r
 }\r
 \r
-if (!mysql_query($link, 'DROP TABLE IF EXISTS tlocaldata', $link)) {\r
+if (!mysql_query($link, 'DROP TABLE IF EXISTS test', $link)) {\r
        printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));\r
 }\r
 \r