#At file:///home/gluh/MySQL/mysql-5.1-bugteam/ based on revid:omer@stripped
3408 Sergey Glukhov 2010-03-19
Bug#51494 crash with join, explain and 'sounds like' operator
The crash happens because of discrepancy between values of
conts_tables and join->const_table_map(make_join_statisctics).
Calculation of conts_tables used condition with
HA_STATS_RECORDS_IS_EXACT flag check. Calculation of
join->const_table_map does not use this flag check.
In case of MERGE table without union with index
the table does not become const table and
thus join_read_const_table() is not called
for the table. join->const_table_map supposes
this table is const and later in make_join_select
this table is used for making&calculation const
condition. As table record buffer is not populated
it leads to crash.
The fix is adding a check if an engine supports
HA_STATS_RECORDS_IS_EXACT flag before updating
join->const_table_map.
@ mysql-test/r/merge.result
test result
@ mysql-test/t/merge.test
test case
@ sql/sql_select.cc
adding a check if an engine supports
HA_STATS_RECORDS_IS_EXACT flag before updating
join->const_table_map.
modified:
mysql-test/r/merge.result
mysql-test/t/merge.test
sql/sql_select.cc
=== modified file 'mysql-test/r/merge.result'
--- a/mysql-test/r/merge.result 2010-03-03 10:49:03 +0000
+++ b/mysql-test/r/merge.result 2010-03-19 06:01:02 +0000
@@ -2286,4 +2286,16 @@ m1 CREATE TABLE `m1` (
DROP TABLE m1;
DROP TABLE `test@1`.`t@1`;
DROP DATABASE `test@1`;
+#
+# Bug#51494c rash with join, explain and 'sounds like' operator
+#
+CREATE TABLE t1 (a INT) ENGINE=MYISAM;
+INSERT INTO t1 VALUES(1);
+CREATE TABLE t2 (b INT NOT NULL,c INT,d INT,e BLOB NOT NULL,
+KEY idx0 (d, c)) ENGINE=MERGE;
+EXPLAIN SELECT * FROM t1 NATURAL RIGHT JOIN
+t2 WHERE b SOUNDS LIKE e AND d = 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+DROP TABLE t2, t1;
End of 5.1 tests
=== modified file 'mysql-test/t/merge.test'
--- a/mysql-test/t/merge.test 2010-03-03 10:49:03 +0000
+++ b/mysql-test/t/merge.test 2010-03-19 06:01:02 +0000
@@ -1690,4 +1690,19 @@ DROP TABLE m1;
DROP TABLE `test@1`.`t@1`;
DROP DATABASE `test@1`;
+--echo #
+--echo # Bug#51494c rash with join, explain and 'sounds like' operator
+--echo #
+
+CREATE TABLE t1 (a INT) ENGINE=MYISAM;
+INSERT INTO t1 VALUES(1);
+
+CREATE TABLE t2 (b INT NOT NULL,c INT,d INT,e BLOB NOT NULL,
+KEY idx0 (d, c)) ENGINE=MERGE;
+
+EXPLAIN SELECT * FROM t1 NATURAL RIGHT JOIN
+t2 WHERE b SOUNDS LIKE e AND d = 1;
+
+DROP TABLE t2, t1;
+
--echo End of 5.1 tests
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2010-03-14 16:01:45 +0000
+++ b/sql/sql_select.cc 2010-03-19 06:01:02 +0000
@@ -2943,7 +2943,8 @@ make_join_statistics(JOIN *join, TABLE_L
s->quick=select->quick;
s->needed_reg=select->needed_reg;
select->quick=0;
- if (records == 0 && s->table->reginfo.impossible_range)
+ if (records == 0 && s->table->reginfo.impossible_range &&
+ (s->table->file->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT))
{
/*
Impossible WHERE or ON expression
Attachment: [text/bzr-bundle] bzr/sergey.glukhov@sun.com-20100319060102-57ykzjf4pc93avy1.bundle
Thread |
---|
• bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:3408)Bug#51494 | Sergey Glukhov | 19 Mar |