diff options
author | Igor Babaev <igor@askmonty.org> | 2013-02-07 21:46:02 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2013-02-07 21:46:02 -0800 |
commit | 48aee4595708bebc04a6c8e640bbf6f55ce4e33c (patch) | |
tree | dda97027aea0087f227d2fd2faf633f5e1de1076 /sql/sql_select.h | |
parent | 746152959a8787f3c7cf6b1c710fc1ee6c54419f (diff) | |
download | mariadb-git-48aee4595708bebc04a6c8e640bbf6f55ce4e33c.tar.gz |
Fixed bug mdev-3995.
This bug happened because the executor tried to use a wrong
TABLE REF object when building access keys. It constructed
keys from fields of a materialized table from a ref object
created to construct keys from the fields of the underlying
base table. This could happen only when materialized table
was created for a non-correlated IN subquery and only
when the materialized table used for lookups.
In this case we are guaranteed to be able to construct the
keys from the fields of tables that would be outer tables
for the tables of the IN subquery.
The patch makes sure that no ref objects constructed from
fields of materialized lookup tables are to be used.
Diffstat (limited to 'sql/sql_select.h')
-rw-r--r-- | sql/sql_select.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/sql/sql_select.h b/sql/sql_select.h index ab531f66649..eb064b39f22 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -515,6 +515,16 @@ typedef struct st_join_table { bool preread_init(); bool is_sjm_nest() { return test(bush_children); } + + bool access_from_tables_is_allowed(table_map used_tables, + table_map sjm_lookup_tables) + { + table_map used_sjm_lookup_tables= used_tables & sjm_lookup_tables; + return !used_sjm_lookup_tables || + (emb_sj_nest && + !(used_sjm_lookup_tables & ~emb_sj_nest->sj_inner_tables)); + } + } JOIN_TAB; @@ -947,6 +957,11 @@ public: */ bool resume_nested_loop; table_map const_table_map; + /** + Bitmap of semijoin tables that the current partial plan decided + to materialize and access by lookups + */ + table_map sjm_lookup_tables; /* Constant tables for which we have found a row (as opposed to those for which we didn't). @@ -1268,6 +1283,8 @@ public: outer_ref_cond= pseudo_bits_cond= NULL; in_to_exists_where= NULL; in_to_exists_having= NULL; + emb_sjm_nest= NULL; + sjm_lookup_tables= 0; } int prepare(Item ***rref_pointer_array, TABLE_LIST *tables, uint wind_num, |