iff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
|
index f88e1e7..ae0ab27 100644
|
--- a/sql/item_subselect.cc
|
+++ b/sql/item_subselect.cc
|
@@ -4536,10 +4536,11 @@ void subselect_union_engine::print(String *str, enum_query_type query_type)
|
void subselect_uniquesubquery_engine::print(String *str,
|
enum_query_type query_type)
|
{
|
+ TABLE *table= tab->tab_list ? tab->tab_list->table : tab->table;
|
str->append(STRING_WITH_LEN("<primary_index_lookup>("));
|
tab->ref.items[0]->print(str, query_type);
|
str->append(STRING_WITH_LEN(" in "));
|
- if (tab->table->s->table_category == TABLE_CATEGORY_TEMPORARY)
|
+ if (table->s->table_category == TABLE_CATEGORY_TEMPORARY)
|
{
|
/*
|
Temporary tables' names change across runs, so they can't be used for
|
@@ -4548,8 +4549,8 @@ void subselect_uniquesubquery_engine::print(String *str,
|
str->append(STRING_WITH_LEN("<temporary table>"));
|
}
|
else
|
- str->append(&tab->table->s->table_name);
|
- KEY *key_info= tab->table->key_info+ tab->ref.key;
|
+ str->append(&table->s->table_name);
|
+ KEY *key_info= table->key_info+ tab->ref.key;
|
str->append(STRING_WITH_LEN(" on "));
|
str->append(&key_info->name);
|
if (cond)
|
@@ -4567,12 +4568,13 @@ all other tests pass.
|
|
void subselect_uniquesubquery_engine::print(String *str)
|
{
|
- KEY *key_info= tab->table->key_info + tab->ref.key;
|
+ TABLE *table= tab->tab_list ? tab->tab_list->table : tab->table;
|
+ KEY *key_info= table->key_info + tab->ref.key;
|
str->append(STRING_WITH_LEN("<primary_index_lookup>("));
|
for (uint i= 0; i < key_info->user_defined_key_parts; i++)
|
tab->ref.items[i]->print(str);
|
str->append(STRING_WITH_LEN(" in "));
|
- str->append(&tab->table->s->table_name);
|
+ str->append(&table->s->table_name);
|
str->append(STRING_WITH_LEN(" on "));
|
str->append(&key_info->name);
|
if (cond)
|
@@ -4587,11 +4589,12 @@ void subselect_uniquesubquery_engine::print(String *str)
|
void subselect_indexsubquery_engine::print(String *str,
|
enum_query_type query_type)
|
{
|
+ TABLE *table= tab->tab_list ? tab->tab_list->table : tab->table;
|
str->append(STRING_WITH_LEN("<index_lookup>("));
|
tab->ref.items[0]->print(str, query_type);
|
str->append(STRING_WITH_LEN(" in "));
|
- str->append(tab->table->s->table_name.str, tab->table->s->table_name.length);
|
- KEY *key_info= tab->table->key_info+ tab->ref.key;
|
+ str->append(&table->s->table_name);
|
+ KEY *key_info= table->key_info+ tab->ref.key;
|
str->append(STRING_WITH_LEN(" on "));
|
str->append(&key_info->name);
|
if (check_null)
|
@@ -5271,6 +5274,7 @@ subselect_hash_sj_engine::make_unique_engine()
|
DBUG_RETURN(NULL);
|
|
tab->table= tmp_table;
|
+ tab->tab_list= 0;
|
tab->preread_init_done= FALSE;
|
tab->ref.tmp_table_index_lookup_init(thd, tmp_key, it, FALSE);
|
|
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
|
index 1c03b0b..db7a4c0 100644
|
--- a/sql/opt_subselect.cc
|
+++ b/sql/opt_subselect.cc
|
@@ -4128,6 +4128,7 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab)
|
|
sjm->materialized= FALSE;
|
sjm_tab->table= sjm->table;
|
+ sjm_tab->tab_list= emb_sj_nest;
|
sjm->table->pos_in_table_list= emb_sj_nest;
|
|
DBUG_RETURN(FALSE);
|
I have hack for it which can be put before real fix (or can be real fix)
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index f88e1e7e101..a4a36d96ccc 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -4538,6 +4538,12 @@ void subselect_uniquesubquery_engine::print(String *str,
{
str->append(STRING_WITH_LEN("<primary_index_lookup>("));
tab->ref.items[0]->print(str, query_type);
+ if (!tab->table)
+ {
+ // table is not opened so unknown
+ str->append(')');
+ return;
+ }
str->append(STRING_WITH_LEN(" in "));
if (tab->table->s->table_category == TABLE_CATEGORY_TEMPORARY)
{