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). mysql-test/r/union.result: MWL#17: Table elimination - Adjust test results
This commit is contained in:
parent
b1e25edc9b
commit
6b4727dcb9
@ -522,7 +522,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||||||
2 UNION t2 const PRIMARY PRIMARY 4 const 1 100.00
|
2 UNION t2 const PRIMARY PRIMARY 4 const 1 100.00
|
||||||
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
|
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
|
||||||
Warnings:
|
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);
|
(select * from t1 where a=5) union (select * from t2 where a=1);
|
||||||
a b
|
a b
|
||||||
1 10
|
1 10
|
||||||
|
@ -16937,18 +16937,28 @@ static void print_join(THD *thd,
|
|||||||
*t= ti++;
|
*t= ti++;
|
||||||
|
|
||||||
DBUG_ASSERT(tables->elements >= 1);
|
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)->print(thd, eliminated_tables, str, query_type);
|
||||||
|
|
||||||
TABLE_LIST **end= table + tables->elements;
|
TABLE_LIST **end= table + tables->elements;
|
||||||
for (TABLE_LIST **tbl= table + 1; tbl < end; tbl++)
|
for (TABLE_LIST **tbl= table + 1; tbl < end; tbl++)
|
||||||
{
|
{
|
||||||
TABLE_LIST *curr= *tbl;
|
TABLE_LIST *curr= *tbl;
|
||||||
// psergey-todo-todo:
|
/*
|
||||||
// base table: check
|
The (*) check guards againist the case of printing the query for
|
||||||
if (curr->table && (curr->table->map & eliminated_tables) ||
|
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 &
|
curr->nested_join && !(curr->nested_join->used_tables &
|
||||||
~eliminated_tables))
|
~eliminated_tables)))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user