xref: /PHP-7.1/ext/mysqli/tests/bug71863.phpt (revision 7af945e2)
1--TEST--
2Bug #71863 Segfault when EXPLAIN with "Unknown Column" Error
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7require_once("connect.inc");
8if (!$IS_MYSQLND) {
9	die("skip mysqlnd only test");
10}
11?>
12--FILE--
13<?php
14require_once("connect.inc");
15
16$req = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
17
18// create db and table for test
19mysqli_query($req, "DROP TABLE IF EXISTS test_bug_71863") or die(mysqli_error($req));
20mysqli_query($req, "CREATE TABLE test_bug_71863 (id INT UNSIGNED NOT NULL DEFAULT 0)") or die(mysqli_error($req));
21
22// segfault if EXPLAIN + "Unknown column" error
23mysqli_query($req, "EXPLAIN SELECT `id` FROM `test_bug_71863` WHERE `owner_id` = '2' AND `object_id` = '1' AND type = '0'") or die(mysqli_error($req)."\n");
24
25?>
26--CLEAN--
27<?php
28require_once("connect.inc");
29if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
30    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
31if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bug_71863"))
32    printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
33mysqli_close($link);
34?>
35--EXPECTF--
36%AUnknown column 'owner_id' in 'where clause'
37