diff options
| author | Sergey Petrunya <psergey@askmonty.org> | 2011-01-13 19:25:31 +0300 |
|---|---|---|
| committer | Sergey Petrunya <psergey@askmonty.org> | 2011-01-13 19:25:31 +0300 |
| commit | d2cbb1044388290e4d801055052c8163e6475c24 (patch) | |
| tree | 012507962bd5f0642e36d99d020eac1b7a56abf4 /sql/sql_join_cache.cc | |
| parent | 959bf3c1eebcc7a9352ab953e74d0c5e3b7ccfa6 (diff) | |
| download | mariadb-git-d2cbb1044388290e4d801055052c8163e6475c24.tar.gz | |
Backport of (see below) + temporary measures to make SJ-Materialization work with join buffering.
Date: Mon, 01 Nov 2010 15:15:25 -0000
3272 Roy Lyseng 2010-11-01
Bug#52068: Optimizer generates invalid semijoin materialization plan
When MaterializeScan semijoin strategy was used and there were one
or more outer dependent tables before the semijoin tables, the scan
over the materialized table was not properly reset for each row of
the prefix outer tables.
Example: suppose we have a join order:
ot1 SJ-Mat-Scan(it2 it3) ot4
Notice that this is called a MaterializeScan, even though there is an
outer table ahead of the materialized tables. Usually a MaterializeScan
has the outer tables after the materialized table, but this is
a special (but legal) case with outer dependent tables both before and
after the materialized table.
For each qualifying row from ot1, a new scan over the materialized
table must be set up. The code failed to do that, so all scans after
the first one returned zero rows from the materialized table.
Diffstat (limited to 'sql/sql_join_cache.cc')
| -rw-r--r-- | sql/sql_join_cache.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 2c28aae781c..501ec0faf23 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -169,9 +169,17 @@ JOIN_TAB *JOIN_CACHE::get_next_table(JOIN_TAB *tab) if (join_tab->first_sjm_sibling) return tab; uint i= tab-join->join_tab; + /* + Temporary measure before MWL#90 refactorings are there: if 'tab' is at upper + level (i.e. it's not inside an SJM nest), still include into the join buffer + the tables from within SJM nest. We might need the subquery's select list + columns, because SJ-Materialization-Scan upacks data to those. + while (sj_is_materialize_strategy(join->best_positions[i].sj_strategy) && i < join->tables) i+= join->best_positions[i].n_sj_tables; + + */ return join->join_tab+i < join_tab ? join->join_tab+i : NULL; } |
