diff options
author | unknown <timour@askmonty.org> | 2011-05-17 00:00:11 +0300 |
---|---|---|
committer | unknown <timour@askmonty.org> | 2011-05-17 00:00:11 +0300 |
commit | 4a9c027ad85597e5bcd42b59245a743366af476a (patch) | |
tree | 4d7ebfb5bfdb1a5cc5e2657303f2c60662cfaafc /mysql-test/r/subselect_no_opts.result | |
parent | b757f734925c80343c262e6ddf8379cc665e7103 (diff) | |
download | mariadb-git-4a9c027ad85597e5bcd42b59245a743366af476a.tar.gz |
Fix LP BUG#778413
Analysis:
The subquery is evaluated first during ref-optimization of the outer
query because the subquery is considered constant from the perspective
of the outer query. Thus an attempt is made to evaluate the MAX subquery
and use the new constant to drive an index nested loops join.
During this evaluation the inner-most subquery replaces the JOIN_TAB
with a new one that fetches the data from a temp table.
The function select_describe crashes at the lines:
TABLE_LIST *real_table= table->pos_in_table_list;
item_list.push_back(new Item_string(real_table->alias,
strlen(real_table->alias),
cs));
because 'table' is a temp table, and it has no corresponding table
reference. This 'real_table' is NULL, and real_table->alias results
in a crash.
Solution:
In the spirit of MWL#89 prevent the evaluation of expensive predicates
during optimization. This patch prevents the evaluation of expensive
predicates during ref optimization.
sql/item_subselect.h:
Remove unused class member. Not needed for the fix, but noticed now and removed.
Diffstat (limited to 'mysql-test/r/subselect_no_opts.result')
-rw-r--r-- | mysql-test/r/subselect_no_opts.result | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result index 24d652b7bd8..14711c30a7f 100644 --- a/mysql-test/r/subselect_no_opts.result +++ b/mysql-test/r/subselect_no_opts.result @@ -371,7 +371,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 3 SUBQUERY t8 const PRIMARY PRIMARY 37 1 100.00 Using index Warnings: -Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where 1 +Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1)) SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM t8 WHERE pseudo='joce'); ERROR 21000: Operand should contain 1 column(s) @@ -550,7 +550,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: -Note 1003 select '3' AS `numreponse` from `test`.`t1` where (('1' = '1')) +Note 1003 select '3' AS `numreponse` from `test`.`t1` where (('1' = '1') and ('3' = 3)) drop table t1; CREATE TABLE t1 (a int(1)); INSERT INTO t1 VALUES (1); |