xref: /PHP-7.2/ext/mysqli/tests/bug53503.phpt (revision 2eaabf06)
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--INI--
19mysqli.allow_local_infile=1
20--FILE--
21<?php
22	require_once("connect.inc");
23
24	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
25		printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
26	}
27
28	if (!$link->query("DROP TABLE IF EXISTS test")) {
29		printf("[002] [%d] %s\n", $link->errno, $link->error);
30	}
31
32	if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) {
33		printf("[003] [%d] %s\n", $link->errno, $link->error);
34	}
35
36	if (FALSE == file_put_contents('bug53503.data', "1\n2\n3\n"))
37		printf("[004] Failed to create CVS file\n");
38
39	if (!$link->query("SELECT 1 FROM DUAL"))
40		printf("[005] [%d] %s\n", $link->errno, $link->error);
41
42	if (!$link->query("LOAD DATA LOCAL INFILE 'bug53503.data' INTO TABLE test")) {
43		printf("[006] [%d] %s\n", $link->errno, $link->error);
44		echo "bug";
45	} else {
46		echo "done";
47	}
48	$link->close();
49?>
50--CLEAN--
51<?php
52require_once('connect.inc');
53
54if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
55	printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
56		$host, $user, $db, $port, $socket);
57}
58
59if (!$link->query($link, 'DROP TABLE IF EXISTS test')) {
60	printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
61}
62
63$link->close();
64
65unlink('bug53503.data');
66?>
67--EXPECT--
68done
69