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