Skip to content

Instantly share code, notes, and snippets.

@spetrunia
Created January 28, 2013 07:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spetrunia/4653693 to your computer and use it in GitHub Desktop.
Save spetrunia/4653693 to your computer and use it in GitHub Desktop.
=== modified file 'sql/opt_subselect.cc'
--- sql/opt_subselect.cc 2013-01-07 19:21:05 +0000
+++ sql/opt_subselect.cc 2013-01-28 07:38:00 +0000
@@ -2542,6 +2542,12 @@ void advance_sj_state(JOIN *join, table_
/* Mark strategy as used */
(*strategy)->mark_used();
pos->sj_strategy= sj_strategy;
+
+ if (sj_strategy == SJ_OPT_MATERIALIZE)
+ join->sj_materialized_lookup_tables |= handled_fanout;
+ else
+ join->sj_materialized_lookup_tables &= ~handled_fanout;
+
*current_read_time= read_time;
*current_record_count= rec_count;
join->cur_dups_producing_tables &= ~handled_fanout;
@@ -3066,6 +3072,11 @@ void restore_prev_sj_state(const table_m
const JOIN_TAB *tab, uint idx)
{
TABLE_LIST *emb_sj_nest;
+ if (tab->emb_sj_nest)
+ {
+ table_map subq_tables= tab->emb_sj_nest->sj_inner_tables;
+ join->sj_materialized_lookup_tables &= ~subq_tables;
+ }
if ((emb_sj_nest= tab->emb_sj_nest))
{
/* If we're removing the last SJ-inner table, remove the sj-nest */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment