maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #00398
bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (psergey:2714)
#At lp:maria based on revid:psergey@xxxxxxxxxxxx-20090614123504-jf4pcb333ojwaxfy
2714 Sergey Petrunia 2009-06-15
MWL#17: Table elimination
- Fix print_join() to work both for EXPLAIN EXTENDED (after table elimination) and for
CREATE VIEW (after join->prepare() but without any optimization).
modified:
mysql-test/r/union.result
sql/sql_select.cc
per-file messages:
mysql-test/r/union.result
MWL#17: Table elimination
- Adjust test results
sql/sql_select.cc
MWL#17: Table elimination
- Fix print_join() to work both for EXPLAIN EXTENDED (after table elimination) and for
CREATE VIEW (after join->prepare() but without any optimization).
=== modified file 'mysql-test/r/union.result'
--- a/mysql-test/r/union.result 2009-03-19 10:18:52 +0000
+++ b/mysql-test/r/union.result 2009-06-14 20:59:24 +0000
@@ -522,7 +522,7 @@ id select_type table type possible_keys
2 UNION t2 const PRIMARY PRIMARY 4 const 1 100.00
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 (select '1' AS `a`,'1' AS `b` from `test`.`t1` where ('1' = 1)) union (select '1' AS `a`,'10' AS `b` from `test`.`t2` where ('1' = 1))
+Note 1003 (select '1' AS `a`,'1' AS `b` from `test`.`t1` where 1) union (select '1' AS `a`,'10' AS `b` from `test`.`t2` where 1)
(select * from t1 where a=5) union (select * from t2 where a=1);
a b
1 10
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2009-06-14 12:35:04 +0000
+++ b/sql/sql_select.cc 2009-06-14 20:59:24 +0000
@@ -16937,18 +16937,28 @@ static void print_join(THD *thd,
*t= ti++;
DBUG_ASSERT(tables->elements >= 1);
- //pserey:TODO check!
+ /*
+ Assert that the first table in the list isn't eliminated (if it was we
+ would have skipped the entire join nest)
+ */
+ DBUG_ASSERT(!eliminated_tables ||
+ !((*table)->table && ((*table)->table->map & eliminated_tables) ||
+ (*table)->nested_join && !((*table)->nested_join->used_tables &
+ ~eliminated_tables)));
(*table)->print(thd, eliminated_tables, str, query_type);
TABLE_LIST **end= table + tables->elements;
for (TABLE_LIST **tbl= table + 1; tbl < end; tbl++)
{
TABLE_LIST *curr= *tbl;
- // psergey-todo-todo:
- // base table: check
- if (curr->table && (curr->table->map & eliminated_tables) ||
- curr->nested_join && !(curr->nested_join->used_tables &
- ~eliminated_tables))
+ /*
+ The (*) check guards againist the case of printing the query for
+ CREATE VIEW. There we'll have nested_join->used_tables==0.
+ */
+ if (eliminated_tables && // (*)
+ (curr->table && (curr->table->map & eliminated_tables) ||
+ curr->nested_join && !(curr->nested_join->used_tables &
+ ~eliminated_tables)))
{
continue;
}