summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbell@sanja.is.com.ua <>2003-10-23 20:50:53 +0300
committerbell@sanja.is.com.ua <>2003-10-23 20:50:53 +0300
commitb0bd7f80be30f049facfc9b8d465c5717a554179 (patch)
tree3d9a27d3a8298630430123ea697a0b73425e3347
parentb9dccb34ddcf8c528c48103d01885de8e8fd9d84 (diff)
downloadmariadb-git-b0bd7f80be30f049facfc9b8d465c5717a554179.tar.gz
ufter review fix (BUG#1444)
-rw-r--r--sql/item.cc27
-rw-r--r--sql/item_subselect.cc12
2 files changed, 23 insertions, 16 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 970a92992ed..42753750c17 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -829,12 +829,14 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
// it is primary INSERT st_select_lex => skip first table resolving
table_list= table_list->next;
}
+
+ Item_subselect *prev_subselect_item= prev_unit->item;
if ((tmp= find_field_in_tables(thd, this,
table_list, &where,
0)) != not_found_field)
{
- prev_unit->item->used_tables_cache|= tmp->table->map;
- prev_unit->item->const_item_cache= 0;
+ prev_subselect_item->used_tables_cache|= tmp->table->map;
+ prev_subselect_item->const_item_cache= 0;
break;
}
if (sl->resolve_mode == SELECT_LEX::SELECT_MODE &&
@@ -844,15 +846,15 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
{
if (*refer && (*refer)->fixed) // Avoid crash in case of error
{
- prev_unit->item->used_tables_cache|= (*refer)->used_tables();
- prev_unit->item->const_item_cache&= (*refer)->const_item();
+ prev_subselect_item->used_tables_cache|= (*refer)->used_tables();
+ prev_subselect_item->const_item_cache&= (*refer)->const_item();
}
break;
}
// Reference is not found => depend from outer (or just error)
- prev_unit->item->used_tables_cache|= OUTER_REF_TABLE_BIT;
- prev_unit->item->const_item_cache= 0;
+ prev_subselect_item->used_tables_cache|= OUTER_REF_TABLE_BIT;
+ prev_subselect_item->const_item_cache= 0;
if (sl->master_unit()->first_select()->linkage ==
DERIVED_TABLE_TYPE)
@@ -1401,6 +1403,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
for ( ; sl ; sl= (prev_unit= sl->master_unit())->outer_select())
{
last= sl;
+ Item_subselect *prev_subselect_item= prev_unit->item;
if (sl->resolve_mode == SELECT_LEX::SELECT_MODE &&
(ref= find_item_in_list(this, sl->item_list,
&counter,
@@ -1409,8 +1412,8 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
{
if (*ref && (*ref)->fixed) // Avoid crash in case of error
{
- prev_unit->item->used_tables_cache|= (*ref)->used_tables();
- prev_unit->item->const_item_cache&= (*ref)->const_item();
+ prev_subselect_item->used_tables_cache|= (*ref)->used_tables();
+ prev_subselect_item->const_item_cache&= (*ref)->const_item();
}
break;
}
@@ -1424,14 +1427,14 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
table_list, &where,
0)) != not_found_field)
{
- prev_unit->item->used_tables_cache|= tmp->table->map;
- prev_unit->item->const_item_cache= 0;
+ prev_subselect_item->used_tables_cache|= tmp->table->map;
+ prev_subselect_item->const_item_cache= 0;
break;
}
// Reference is not found => depend from outer (or just error)
- prev_unit->item->used_tables_cache|= OUTER_REF_TABLE_BIT;
- prev_unit->item->const_item_cache= 0;
+ prev_subselect_item->used_tables_cache|= OUTER_REF_TABLE_BIT;
+ prev_subselect_item->const_item_cache= 0;
if (sl->master_unit()->first_select()->linkage ==
DERIVED_TABLE_TYPE)
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 4ad49ebec74..704681dd511 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -112,6 +112,11 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref)
}
fix_length_and_dec();
}
+ if (engine->uncacheable())
+ {
+ const_item_cache= 0;
+ used_tables_cache|= RAND_TABLE_BIT;
+ }
fixed= 1;
thd->where= save_where;
return res;
@@ -149,13 +154,12 @@ void Item_subselect::fix_length_and_dec()
table_map Item_subselect::used_tables() const
{
- return (table_map) (engine->dependent() ? used_tables_cache :
- (engine->uncacheable() ? RAND_TABLE_BIT : 0L));
+ return (table_map) (engine->dependent() ? used_tables_cache : 0L);
}
bool Item_subselect::const_item() const
{
- return engine->uncacheable()? 0 : const_item_cache;
+ return const_item_cache;
}
void Item_subselect::update_used_tables()
@@ -163,7 +167,7 @@ void Item_subselect::update_used_tables()
if (!engine->uncacheable())
{
// did all used tables become ststic?
- if ((used_tables_cache & ~engine->upper_select_const_tables()) == 0)
+ if ((used_tables_cache & ~engine->upper_select_const_tables()))
const_item_cache= 1;
}
}