--- /dev/null
+--TEST--\r
+Bug #53649 (mysql_query with "load data" unable to save result set)\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_mysql_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 (!mysql_query("DROP TABLE IF EXISTS tlocaldata", $link)) {\r
+ printf("[002] [%d] %s\n", $link->errno, $link->error);\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
+ }\r
+\r
+ file_put_contents('bug53649.data', "1\n2\n3\n");\r
+\r
+ mysql_query("SELECT 1 FROM DUAL", $link);\r
+\r
+ if (!mysql_query("LOAD DATA LOCAL INFILE 'bug53649.data' INTO TABLE tlocaldata", $link)) {\r
+ echo "bug";\r
+ } else {\r
+ echo "done";\r
+ }\r
+ mysql_close($link);\r
+?>\r
+--CLEAN--\r
+<?php\r
+require_once('connect.inc');\r
+\r
+if (!$link = my_mysql_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 (!mysql_query($link, 'DROP TABLE IF EXISTS tlocaldata', $link)) {\r
+ printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));\r
+}\r
+\r
+mysql_close($link);\r
+\r
+unlink('bug53649.data');\r
+?>\r
+--EXPECT--\r
+done
\ No newline at end of file
printf("[003] [%d] %s\n", $link->errno, $link->error);\r
}\r
\r
- file_put_contents('bug53503.data', 'jokijoki');\r
+ file_put_contents('bug53503.data', "1\n2\n3\n");\r
\r
- if (!$link->query("LOAD DATA LOCAL INFILE 'bug53503.data' REPLACE INTO TABLE tlocaldata (dump1)")) {\r
+ $link->query("SELECT 1 FROM DUAL");\r
+\r
+ if (!$link->query("LOAD DATA LOCAL INFILE 'bug53503.data' INTO TABLE tlocaldata")) {\r
echo "bug";\r
} else {\r
echo "done";\r
}\r
+ $link->close();\r
?>\r
--CLEAN--\r
<?php\r
$host, $user, $db, $port, $socket);\r
}\r
\r
-if (!mysqli_query($link, 'DROP TABLE IF EXISTS tlocaldata')) {\r
+if (!$link->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
+$link->close();\r
\r
unlink('bug53503.data');\r
?>\r
zend_bool is_warning;
DBG_INF("LOAD DATA");
conn->last_query_type = QUERY_LOAD_LOCAL;
+ conn->field_count = 0; /* overwrite previous value, or the last value could be used and lead to bug#53503 */
CONN_SET_STATE(conn, CONN_SENDING_LOAD_DATA);
ret = mysqlnd_handle_local_infile(conn, rset_header->info_or_local_file, &is_warning TSRMLS_CC);
CONN_SET_STATE(conn, (ret == PASS || is_warning == TRUE)? CONN_READY:CONN_QUIT_SENT);