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 ...@@ -291,7 +291,7 @@ table_map Item_field::used_tables() const
{ {
if (field->table->const_table) if (field->table->const_table)
return 0; // const item return 0; // const item
return field->table->map; return (depended_from? RAND_TABLE_BIT : field->table->map);
} }
Item * Item_field::get_tmp_table_item() Item * Item_field::get_tmp_table_item()
......
...@@ -699,7 +699,12 @@ public: ...@@ -699,7 +699,12 @@ public:
class Item_cache: public Item class Item_cache: public Item
{ {
table_map used_table_map;
public: 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 allocate(uint i) { return 0; };
virtual bool setup(Item *) { return 0; }; virtual bool setup(Item *) { return 0; };
virtual void store(Item *)= 0; virtual void store(Item *)= 0;
...@@ -710,13 +715,14 @@ public: ...@@ -710,13 +715,14 @@ public:
} }
enum Type type() const { return CACHE_ITEM; } enum Type type() const { return CACHE_ITEM; }
static Item_cache* get_cache(Item_result type); static Item_cache* get_cache(Item_result type);
table_map used_tables() const { return used_table_map; }
}; };
class Item_cache_int: public Item_cache class Item_cache_int: public Item_cache
{ {
longlong value; longlong value;
public: public:
Item_cache_int() { fixed= 1; null_value= 1; } Item_cache_int(): Item_cache() {}
void store(Item *item) void store(Item *item)
{ {
...@@ -733,7 +739,7 @@ class Item_cache_real: public Item_cache ...@@ -733,7 +739,7 @@ class Item_cache_real: public Item_cache
{ {
double value; double value;
public: public:
Item_cache_real() { fixed= 1; null_value= 1; } Item_cache_real(): Item_cache() {}
void store(Item *item) void store(Item *item)
{ {
...@@ -755,7 +761,7 @@ class Item_cache_str: public Item_cache ...@@ -755,7 +761,7 @@ class Item_cache_str: public Item_cache
char buffer[80]; char buffer[80];
String *value; String *value;
public: public:
Item_cache_str() { fixed= 1; null_value= 1; } Item_cache_str(): Item_cache() { }
void store(Item *item); void store(Item *item);
double val(); double val();
...@@ -770,7 +776,7 @@ class Item_cache_row: public Item_cache ...@@ -770,7 +776,7 @@ class Item_cache_row: public Item_cache
Item_cache **values; Item_cache **values;
uint item_count; uint item_count;
public: 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 '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, ...@@ -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()))) if (!cache && !(cache= Item_cache::get_cache(args[0]->result_type())))
return 1; return 1;
cache->setup(args[0]); 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)) if (args[1]->fix_fields(thd, tables, args))
return 1; return 1;
Item_in_subselect * sub= (Item_in_subselect *)args[1]; Item_in_subselect * sub= (Item_in_subselect *)args[1];
......
...@@ -484,16 +484,6 @@ JOIN::optimize() ...@@ -484,16 +484,6 @@ JOIN::optimize()
thd->fatal_error) thd->fatal_error)
DBUG_RETURN(1); 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"; thd->proc_info= "preparing";
if (result->initialize_tables(this)) if (result->initialize_tables(this))
{ {
...@@ -4895,6 +4885,9 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) ...@@ -4895,6 +4885,9 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
join->send_records=0; join->send_records=0;
if (join->tables == join->const_tables) 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) if (!(error=(*end_select)(join,join_tab,0)) || error == -3)
error=(*end_select)(join,join_tab,1); 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