Commit 42ba4718 authored by unknown's avatar unknown

Merge sanja.is.com.ua:/home/bell/mysql/work-leak-4.1

into sanja.is.com.ua:/home/bell/mysql/work-select-4.1


sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
parents a72ebebf fb2226c3
......@@ -291,7 +291,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);
}
Item * Item_field::get_tmp_table_item()
......
......@@ -699,7 +699,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;
......@@ -710,13 +715,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)
{
......@@ -733,7 +739,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)
{
......@@ -755,7 +761,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();
......@@ -770,7 +776,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
......
......@@ -289,6 +289,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];
......
......@@ -484,16 +484,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))
{
......@@ -4895,8 +4885,11 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
join->send_records=0;
if (join->tables == join->const_tables)
{
if (!(error=(*end_select)(join,join_tab,0)) || error == -3)
error=(*end_select)(join,join_tab,1);
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);
}
else
{
......
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