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
1.2100 06/03/22 16:46:38 igor@stripped +3 -0
Fixed bug #17164.
If the WHERE condition of a query contained an ORed FALSE term then the set of tables
whose rows cannot serve for null complements in outer joins was determined incorrectly.
It resulted in blocking possible conversions of outer joins into joins for such queries.
sql/item_cmpfunc.cc
1.195 06/03/22 16:46:32 igor@stripped +8 -4
Fixed bug #17164.
If the WHERE condition of a query contained an ORed FALSE term then the set of tables
whose rows cannot serve for null complements in outer joins was determined
incorrectly.
It resulted in blocking possible conversions of outer joins into joins for such
queries.
mysql-test/t/join_outer.test
1.35 06/03/22 16:46:32 igor@stripped +20 -0
Added a test case for bug #17164.
mysql-test/r/join_outer.result
1.46 06/03/22 16:46:32 igor@stripped +19 -0
Added a test case for bug #17164.
# 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: rurik.mysql.com
# Root: /home/igor/dev/mysql-5.0-0
--- 1.194/sql/item_cmpfunc.cc 2006-03-09 03:07:32 -08:00
+++ 1.195/sql/item_cmpfunc.cc 2006-03-22 16:46:32 -08:00
@@ -2546,6 +2546,7 @@
while ((item=li++))
{
table_map tmp_table_map;
+ bool is_const_item;
while (item->type() == Item::COND_ITEM &&
((Item_cond*) item)->functype() == functype() &&
!((Item_cond*) item)->list.is_empty())
@@ -2563,10 +2564,13 @@
(item= *li.ref())->check_cols(1))
return TRUE; /* purecov: inspected */
used_tables_cache|= item->used_tables();
- tmp_table_map= item->not_null_tables();
- not_null_tables_cache|= tmp_table_map;
- and_tables_cache&= tmp_table_map;
- const_item_cache&= item->const_item();
+ if (!(is_const_item= item->const_item()))
+ {
+ tmp_table_map= item->not_null_tables();
+ not_null_tables_cache|= tmp_table_map;
+ and_tables_cache&= tmp_table_map;
+ const_item_cache&= is_const_item;
+ }
with_sum_func= with_sum_func || item->with_sum_func;
if (item->maybe_null)
maybe_null=1;
--- 1.45/mysql-test/r/join_outer.result 2006-01-26 08:54:26 -08:00
+++ 1.46/mysql-test/r/join_outer.result 2006-03-22 16:46:32 -08:00
@@ -1135,3 +1135,22 @@
1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 4 Using where
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1
DROP TABLE t1,t2;
+CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
+INDEX (name)) ENGINE=InnoDB;
+CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11),
+FOREIGN KEY (fkey) REFERENCES t2(id)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
+INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
+EXPLAIN
+SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
+WHERE t1.name LIKE 'A%';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index
+1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using where; Using index
+EXPLAIN
+SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
+WHERE t1.name LIKE 'A%' OR FALSE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index
+1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using where; Using index
+DROP TABLE t1,t2;
--- 1.34/mysql-test/t/join_outer.test 2006-01-26 08:54:27 -08:00
+++ 1.35/mysql-test/t/join_outer.test 2006-03-22 16:46:32 -08:00
@@ -759,3 +759,23 @@
DROP TABLE t1,t2;
+#
+# Test for bug #17164: ORed FALSE blocked conversion of outer join into join
+#
+
+CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
+ INDEX (name)) ENGINE=InnoDB;
+CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11),
+ FOREIGN KEY (fkey) REFERENCES t2(id)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
+INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
+
+EXPLAIN
+SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
+ WHERE t1.name LIKE 'A%';
+
+EXPLAIN
+SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
+ WHERE t1.name LIKE 'A%' OR FALSE;
+
+DROP TABLE t1,t2;
| Thread |
|---|
| • bk commit into 5.0 tree (igor:1.2100) BUG#17164 | igor | 23 Mar |