Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-06-02 11:44:16-07:00, igor@stripped +3 -0
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@stripped, 2007-06-02 11:44:11-07:00, igor@stripped +10 -0
Added a test case for bug #28728.
mysql-test/t/subselect.test@stripped, 2007-06-02 11:44:11-07:00, igor@stripped +14 -0
Added a test case for bug #28728.
sql/sql_select.cc@stripped, 2007-06-02 11:44:12-07:00, igor@stripped +11 -0
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 is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: igor
# Host: olga.mysql.com
# Root: /home/igor/dev-opt/mysql-5.0-opt-bug28728
--- 1.528/sql/sql_select.cc 2007-06-02 11:44:22 -07:00
+++ 1.529/sql/sql_select.cc 2007-06-02 11:44:22 -07:00
@@ -2075,6 +2075,17 @@
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;
}
--- 1.190/mysql-test/r/subselect.result 2007-06-02 11:44:22 -07:00
+++ 1.191/mysql-test/r/subselect.result 2007-06-02 11:44:22 -07:00
@@ -4071,4 +4071,14 @@
2 GA
4 FL
DROP TABLE t1,t2;
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (1), (2);
+EXPLAIN EXTENDED
+SELECT * FROM (SELECT count(*) FROM t1 GROUP BY a) as res;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
+2 DERIVED t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
+Warnings:
+Note 1003 select `res`.`count(*)` AS `count(*)` from (select count(0) AS `count(*)` from `test`.`t1` group by `test`.`t1`.`a`) `res`
+DROP TABLE t1;
End of 5.0 tests.
--- 1.152/mysql-test/t/subselect.test 2007-06-02 11:44:22 -07:00
+++ 1.153/mysql-test/t/subselect.test 2007-06-02 11:44:22 -07:00
@@ -2906,4 +2906,18 @@
DROP TABLE t1,t2;
+#
+# Bug #28728: crash with EXPLAIN EXTENDED for a query with a derived table
+# over a grouping subselect
+#
+
+CREATE TABLE t1 (a int);
+
+INSERT INTO t1 VALUES (1), (2);
+
+EXPLAIN EXTENDED
+SELECT * FROM (SELECT count(*) FROM t1 GROUP BY a) as res;
+
+DROP TABLE t1;
+
--echo End of 5.0 tests.
Thread |
---|
• bk commit into 5.0 tree (igor:1.2508) BUG#28728 | igor | 2 Jun |