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