xref: /PHP-7.1/ext/mysqli/tests/bug53503.phpt (revision 113213f0)
1--TEST--
2Bug #53503 (mysqli::query returns false after successful LOAD DATA query)
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7
8if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
9	die("skip Cannot connect to MySQL");
10
11include_once("local_infile_tools.inc");
12if ($msg = check_local_infile_support($link, $engine))
13	die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
14
15mysqli_close($link);
16
17?>
18--FILE--
19<?php
20	require_once("connect.inc");
21
22	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
23		printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
24	}
25
26	if (!$link->query("DROP TABLE IF EXISTS test")) {
27		printf("[002] [%d] %s\n", $link->errno, $link->error);
28	}
29
30	if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) {
31		printf("[003] [%d] %s\n", $link->errno, $link->error);
32	}
33
34	if (FALSE == file_put_contents('bug53503.data', "1\n2\n3\n"))
35		printf("[004] Failed to create CVS file\n");
36
37	if (!$link->query("SELECT 1 FROM DUAL"))
38		printf("[005] [%d] %s\n", $link->errno, $link->error);
39
40	if (!$link->query("LOAD DATA LOCAL INFILE 'bug53503.data' INTO TABLE test")) {
41		printf("[006] [%d] %s\n", $link->errno, $link->error);
42		echo "bug";
43	} else {
44		echo "done";
45	}
46	$link->close();
47?>
48--CLEAN--
49<?php
50require_once('connect.inc');
51
52if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
53	printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
54		$host, $user, $db, $port, $socket);
55}
56
57if (!$link->query($link, 'DROP TABLE IF EXISTS test')) {
58	printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
59}
60
61$link->close();
62
63unlink('bug53503.data');
64?>
65--EXPECT--
66done
67