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.2138 06/04/04 12:55:02 igor@stripped +3 -0
Fixed bug #18237.
The code in opt_sum_query that prevented the COUNT/MIN/MAX
optimization from being applied to outer joins was not adjusted
after introducing nested joins. As a result if an outer join
contained a reference to a view as an inner table the code of
opt_sum_query missed the presence of an on expressions and
erroneously applied the mentioned optimization.
sql/opt_sum.cc
1.50 06/04/04 12:54:56 igor@stripped +7 -1
Fixed bug #18237.
The code in opt_sum_query that prevented the COUNT/MIN/MAX
optimization from being applied to outer joins was not adjusted
after introducing nested joins. As a result if an outer join
contained a reference to a view as an inner table the code of
opt_sum_query missed the presence of an on expressions and
erroneously applied the mentioned optimization.
mysql-test/t/view.test
1.139 06/04/04 12:54:56 igor@stripped +21 -0
Added a test case for bug #18237.
mysql-test/r/view.result
1.150 06/04/04 12:54:56 igor@stripped +17 -0
Added a test case for bug #18237.
# 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.49/sql/opt_sum.cc 2006-01-06 22:28:02 -08:00
+++ 1.50/sql/opt_sum.cc 2006-04-04 12:54:56 -07:00
@@ -96,8 +96,14 @@
*/
for (TABLE_LIST *tl= tables; tl; tl= tl->next_leaf)
{
+ TABLE_LIST *embedded;
+ for (embedded= tl ; embedded; embedded= embedded->embedding)
+ {
+ if (embedded->on_expr)
+ break;
+ }
+ if (embedded)
/* Don't replace expression on a table that is part of an outer join */
- if (tl->on_expr)
{
outer_tables|= tl->table->map;
--- 1.149/mysql-test/r/view.result 2006-03-27 18:28:49 -08:00
+++ 1.150/mysql-test/r/view.result 2006-04-04 12:54:56 -07:00
@@ -2562,3 +2562,20 @@
1.4142135623731
DROP VIEW v1;
DROP TABLE t1;
+CREATE TABLE t1 (id int PRIMARY KEY);
+CREATE TABLE t2 (id int PRIMARY KEY);
+INSERT INTO t1 VALUES (1), (3);
+INSERT INTO t2 VALUES (1), (2), (3);
+CREATE VIEW v2 AS SELECT * FROM t2;
+SELECT COUNT(*) FROM t1 LEFT JOIN t2 ON t1.id=t2.id;
+COUNT(*)
+2
+SELECT * FROM t1 LEFT JOIN t2 ON t1.id=t2.id;
+id id
+1 1
+3 3
+SELECT COUNT(*) FROM t1 LEFT JOIN v2 ON t1.id=v2.id;
+COUNT(*)
+2
+DROP VIEW v2;
+DROP TABLE t1, t2;
--- 1.138/mysql-test/t/view.test 2006-03-27 18:28:49 -08:00
+++ 1.139/mysql-test/t/view.test 2006-04-04 12:54:56 -07:00
@@ -2413,3 +2413,24 @@
DROP VIEW v1;
DROP TABLE t1;
+
+#
+# Bug #18237: invalid count optimization applied to an outer join with a view
+#
+
+CREATE TABLE t1 (id int PRIMARY KEY);
+CREATE TABLE t2 (id int PRIMARY KEY);
+
+INSERT INTO t1 VALUES (1), (3);
+INSERT INTO t2 VALUES (1), (2), (3);
+
+CREATE VIEW v2 AS SELECT * FROM t2;
+
+SELECT COUNT(*) FROM t1 LEFT JOIN t2 ON t1.id=t2.id;
+SELECT * FROM t1 LEFT JOIN t2 ON t1.id=t2.id;
+
+SELECT COUNT(*) FROM t1 LEFT JOIN v2 ON t1.id=v2.id;
+
+DROP VIEW v2;
+
+DROP TABLE t1, t2;
| Thread |
|---|
| • bk commit into 5.0 tree (igor:1.2138) BUG#18237 | igor | 4 Apr |