forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for bug #71863 Segfault when EXPLAIN with "Unknown column" error
The reason was that after the big refactoring of mysqlnd at the end of last year code that is initializing the error_info structure in the result set was not added. It existed already for connections and PS. The code that segfaults is hit only with MariaDB because MariaDB sends full metadata about the EXPLAIN query + EOF packet and only then it sends an error packet. MySQL doesn't do that but sends directly an error which is caught (by different code path). As errors during execution (which means after sending meta) are pretty rare there was no test case of MySQL to catch it.
- Loading branch information
1 parent
ac0bbea
commit b27ff62
Showing
4 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--TEST-- | ||
Bug #71863 Segfault when EXPLAIN with "Unknown Column" Error | ||
--SKIPIF-- | ||
<?php | ||
require_once('skipif.inc'); | ||
require_once('skipifconnectfailure.inc'); | ||
require_once("connect.inc"); | ||
if (!$IS_MYSQLND) { | ||
die("skip mysqlnd only test"); | ||
} | ||
?> | ||
--FILE-- | ||
<?php | ||
require_once("connect.inc"); | ||
|
||
$req = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket); | ||
|
||
// create db and table for test | ||
mysqli_query($req, "DROP TABLE IF EXISTS test_bug_71863") or die(mysqli_error($req)); | ||
mysqli_query($req, "CREATE TABLE test_bug_71863 (id INT UNSIGNED NOT NULL DEFAULT 0)") or die(mysqli_error($req)); | ||
|
||
// segfault if EXPLAIN + "Unknown column" error | ||
mysqli_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"); | ||
|
||
?> | ||
--CLEAN-- | ||
<?php | ||
require_once("connect.inc"); | ||
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) | ||
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); | ||
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bug_71863")) | ||
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); | ||
mysqli_close($link); | ||
?> | ||
--EXPECTF-- | ||
Warning: mysqli_query(): (42S22/1054): Unknown column 'owner_id' in 'where clause' in %sbug71863.php on line %d | ||
Unknown column 'owner_id' in 'where clause' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters