mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Fixed bug #28728: a crash when executing EXPLAIN EXTENDED for a query
using a derived table over a grouping subselect. This crash happens only when materialization of the derived tables requires creation of auxiliary temporary table, for example when a grouping operation is carried out with usage of a temporary table. The crash happened because EXPLAIN EXTENDED when printing the query expression made an attempt to use the objects created in the mem_root of the temporary table which has been already freed by the moment when printing is called. This bug appeared after the method Item_field::print() had been introduced. mysql-test/r/subselect.result: Added a test case for bug #28728. mysql-test/t/subselect.test: Added a test case for bug #28728. sql/sql_select.cc: Fixed bug #28728: a crash when executing EXPLAIN EXTENDED for a query using a derived table over a grouping subselect. The crash happened because EXPLAIN EXTENDED when printing the query expression made an attempt to use the objects created in the mem_root of the temporary table which has been already freed by the moment when printing is accomplished. The fix in JOIN::exec() ensures using existing objects when printing subselects for a derived tables by EXPLAIN EXTENDED.
This commit is contained in:
@@ -2075,6 +2075,17 @@ JOIN::exec()
|
||||
thd->examined_row_count+= curr_join->examined_rows;
|
||||
DBUG_PRINT("counts", ("thd->examined_row_count: %lu",
|
||||
(ulong) thd->examined_row_count));
|
||||
|
||||
/*
|
||||
With EXPLAIN EXTENDED we have to restore original ref_array
|
||||
for a derived table which is always materialized.
|
||||
Otherwise we would not be able to print the query correctly.
|
||||
*/
|
||||
if (items0 &&
|
||||
(thd->lex->describe & DESCRIBE_EXTENDED) &&
|
||||
select_lex->linkage == DERIVED_TABLE_TYPE)
|
||||
set_items_ref_array(items0);
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user