Commit fb2226c3 authored by unknown's avatar unknown

removed switching off static table optimization for subselects (SCRUM ,...

removed switching off static table optimization for subselects (SCRUM , pre-commit  to be able merge with temporary table fix)



sql/item.cc:
  report other table for outer reference
sql/item.h:
  report other table for outer reference
sql/item_cmpfunc.cc:
  report other table for outer reference
sql/sql_select.cc:
  removed switching off static table optimization for subselects
parent 3fe840ee
......@@ -261,7 +261,7 @@ table_map Item_field::used_tables() const
{
if (field->table->const_table)
return 0; // const item
return field->table->map;
return (depended_from? RAND_TABLE_BIT : field->table->map);
}
......
......@@ -666,7 +666,12 @@ class Item_field_buff :public Item_buff
class Item_cache: public Item
{
table_map used_table_map;
public:
Item_cache(): used_table_map(0) {fixed= 1; null_value= 1;}
void set_used_tables(table_map map) { used_table_map= map; }
virtual bool allocate(uint i) { return 0; };
virtual bool setup(Item *) { return 0; };
virtual void store(Item *)= 0;
......@@ -677,13 +682,14 @@ class Item_cache: public Item
}
enum Type type() const { return CACHE_ITEM; }
static Item_cache* get_cache(Item_result type);
table_map used_tables() const { return used_table_map; }
};
class Item_cache_int: public Item_cache
{
longlong value;
public:
Item_cache_int() { fixed= 1; null_value= 1; }
Item_cache_int(): Item_cache() {}
void store(Item *item)
{
......@@ -700,7 +706,7 @@ class Item_cache_real: public Item_cache
{
double value;
public:
Item_cache_real() { fixed= 1; null_value= 1; }
Item_cache_real(): Item_cache() {}
void store(Item *item)
{
......@@ -722,7 +728,7 @@ class Item_cache_str: public Item_cache
char buffer[80];
String *value;
public:
Item_cache_str() { fixed= 1; null_value= 1; }
Item_cache_str(): Item_cache() { }
void store(Item *item);
double val();
......@@ -737,7 +743,7 @@ class Item_cache_row: public Item_cache
Item_cache **values;
uint item_count;
public:
Item_cache_row(): values(0), item_count(2) { fixed= 1; null_value= 1; }
Item_cache_row(): Item_cache(), values(0), item_count(2) {}
/*
'allocate' used only in row transformer, to preallocate space for row
......
......@@ -290,6 +290,14 @@ bool Item_in_optimizer::fix_fields(THD *thd, struct st_table_list *tables,
if (!cache && !(cache= Item_cache::get_cache(args[0]->result_type())))
return 1;
cache->setup(args[0]);
if (cache->cols() == 1)
cache->set_used_tables(RAND_TABLE_BIT);
else
{
uint n= cache->cols();
for (uint i= 0; i < n; i++)
((Item_cache *)cache->el(i))->set_used_tables(RAND_TABLE_BIT);
}
if (args[1]->fix_fields(thd, tables, args))
return 1;
Item_in_subselect * sub= (Item_in_subselect *)args[1];
......
......@@ -442,16 +442,6 @@ JOIN::optimize()
thd->fatal_error)
DBUG_RETURN(1);
if (select_lex->dependent)
{
/*
Just remove all const-table optimization in case of depended query
TODO: optimize
*/
const_table_map= 0;
const_tables= 0;
found_const_table_map= 0;
}
thd->proc_info= "preparing";
if (result->initialize_tables(this))
{
......@@ -4681,6 +4671,9 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
join->send_records=0;
if (join->tables == join->const_tables)
{
if (!join->select_lex->dependent ||
((!join->conds || join->conds->val_int()) &&
(!join->having || join->having->val_int())))
if (!(error=(*end_select)(join,join_tab,0)) || error == -3)
error=(*end_select)(join,join_tab,1);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment