]> granicus.if.org Git - php/commitdiff
Fixed bug #53503 (mysqli::query returns false after successful LOAD DATA query)
authorKalle Sommer Nielsen <kalle@php.net>
Sun, 12 Dec 2010 16:17:50 +0000 (16:17 +0000)
committerKalle Sommer Nielsen <kalle@php.net>
Sun, 12 Dec 2010 16:17:50 +0000 (16:17 +0000)
NEWS
ext/mysqli/mysqli_nonapi.c
ext/mysqli/tests/bug53503.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index aa4c876e0e7aa2bd7fe0ee4becb1b51a613674cf..9cb8e674bf2395a73017229c08541d5df7d67972 100644 (file)
--- a/NEWS
+++ b/NEWS
   . Fixed bug #53512 (NumberFormatter::setSymbol crash on bogus $attr values).
     (Felipe)
 
+- MySQL Improved extension:
+  . Fixed bug #53503 (mysqli::query returns false after successful LOAD DATA 
+    query). (Kalle)
+
 - PDO Oracle driver:
   . Fixed bug #39199 (Cannot load Lob data with more than 4000 bytes on
     ORACLE 10). (spatar at mail dot nnov dot ru)
index 72b242a662dffc99c7c2c9e488037ed3644f17a1..8a570842e1aefb562eb73c6e3a7d6981b05cb8d7 100644 (file)
@@ -538,7 +538,7 @@ PHP_FUNCTION(mysqli_query)
                        result = mysql_use_result(mysql->mysql);
                        break;
        }
-       if (!result) {
+       if (!result && mysql_errno(mysql->mysql)) {
                php_mysqli_throw_sql_exception((char *)mysql_sqlstate(mysql->mysql), mysql_errno(mysql->mysql) TSRMLS_CC,
                                                                                "%s", mysql_error(mysql->mysql));
                RETURN_FALSE;
diff --git a/ext/mysqli/tests/bug53503.phpt b/ext/mysqli/tests/bug53503.phpt
new file mode 100644 (file)
index 0000000..1a2b7ed
--- /dev/null
@@ -0,0 +1,50 @@
+--TEST--\r
+Bug #53503 (mysqli::query returns false after successful LOAD DATA query)\r
+--SKIPIF--\r
+<?php\r
+require_once('skipif.inc');\r
+require_once('skipifconnectfailure.inc');\r
+?>\r
+--FILE--\r
+<?php\r
+       require_once("connect.inc");\r
+\r
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {\r
+               printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());\r
+       }\r
+\r
+       if (!$link->query("DROP TABLE IF EXISTS tlocaldata")) {\r
+               printf("[002] [%d] %s\n", $link->errno, $link->error);\r
+       }\r
+\r
+       if (!$link->query("CREATE TABLE tlocaldata (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) {\r
+               printf("[003] [%d] %s\n", $link->errno, $link->error);\r
+       }\r
+\r
+       file_put_contents('bug53503.data', 'jokijoki');\r
+\r
+       if (!$link->query("LOAD DATA LOCAL INFILE 'bug53503.data' REPLACE INTO TABLE tlocaldata (dump1)")) {\r
+               echo "bug";\r
+       } else {\r
+               echo "done";\r
+       }\r
+?>\r
+--CLEAN--\r
+<?php\r
+require_once('connect.inc');\r
+\r
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {\r
+       printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",\r
+               $host, $user, $db, $port, $socket);\r
+}\r
+\r
+if (!mysqli_query($link, 'DROP TABLE IF EXISTS tlocaldata')) {\r
+       printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));\r
+}\r
+\r
+mysqli_close($link);\r
+\r
+unlink('bug53503.data');\r
+?>\r
+--EXPECT--\r
+done
\ No newline at end of file