diff options
author | unknown <bell@sanja.is.com.ua> | 2003-01-26 21:34:14 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2003-01-26 21:34:14 +0200 |
commit | 42ba47184c0394b682d4873d5bea4d31e2438b6a (patch) | |
tree | 31c2abc31e9acb20388a8652e15dfb623da9d680 /sql | |
parent | a72ebebf5dace430460ebdd9e96322780fcfe882 (diff) | |
parent | fb2226c37656e8e7fd531e2cc42c0a1a0f75e41a (diff) | |
download | mariadb-git-42ba47184c0394b682d4873d5bea4d31e2438b6a.tar.gz |
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
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.cc | 2 | ||||
-rw-r--r-- | sql/item.h | 14 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 8 | ||||
-rw-r--r-- | sql/sql_select.cc | 17 |
4 files changed, 24 insertions, 17 deletions
diff --git a/sql/item.cc b/sql/item.cc index d4128341fd3..64d059caea7 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -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() diff --git a/sql/item.h b/sql/item.h index 31c3c48cca8..423b07efded 100644 --- a/sql/item.h +++ b/sql/item.h @@ -699,7 +699,12 @@ public: 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 @@ public: } 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 diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 4310fbebaf7..2571ec4eee3 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -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]; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c9872813412..c39b958edfb 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -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 { |