diff options
author | konstantin@mysql.com <> | 2005-07-13 17:39:48 +0400 |
---|---|---|
committer | konstantin@mysql.com <> | 2005-07-13 17:39:48 +0400 |
commit | 374b9182af1f7a46bb6bde838f981e8ee84e4af9 (patch) | |
tree | 82c0ae2ed7d2c2a9c768f1b80eb8834abe18ea3e /sql | |
parent | 1826c398970de0ea20f7329b63768512f0184dbd (diff) | |
parent | bef558b7ee2ebfd091949194354e4b4c33ef12fc (diff) | |
download | mariadb-git-374b9182af1f7a46bb6bde838f981e8ee84e4af9.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/opt/local/work/mysql-4.1-11458
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.cc | 29 | ||||
-rw-r--r-- | sql/item.h | 1 | ||||
-rw-r--r-- | sql/item_subselect.h | 1 | ||||
-rw-r--r-- | sql/mysql_priv.h | 2 | ||||
-rw-r--r-- | sql/sql_lex.h | 1 | ||||
-rw-r--r-- | sql/sql_parse.cc | 8 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 13 |
7 files changed, 21 insertions, 34 deletions
diff --git a/sql/item.cc b/sql/item.cc index 3bdaf856f2a..19b88c115b9 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -889,6 +889,7 @@ void Item_param::set_null() max_length= 0; decimals= 0; state= NULL_VALUE; + item_type= Item::NULL_ITEM; DBUG_VOID_RETURN; } @@ -1339,34 +1340,6 @@ bool Item_param::convert_str_value(THD *thd) return rc; } -bool Item_param::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) -{ - DBUG_ASSERT(fixed == 0); - SELECT_LEX *cursel= (SELECT_LEX *) thd->lex->current_select; - - /* - Parameters in a subselect should mark the subselect as not constant - during prepare - */ - if (state == NO_VALUE) - { - /* - SELECT_LEX_UNIT::item set only for subqueries, so test of it presence - can be barrier to stop before derived table SELECT or very outer SELECT - */ - for(; - cursel->master_unit()->item; - cursel= cursel->outer_select()) - { - Item_subselect *subselect_item= cursel->master_unit()->item; - subselect_item->used_tables_cache|= OUTER_REF_TABLE_BIT; - subselect_item->const_item_cache= 0; - } - } - fixed= 1; - return 0; -} - bool Item_param::basic_const_item() const { diff --git a/sql/item.h b/sql/item.h index 8de2adeb730..a8b0bfe9512 100644 --- a/sql/item.h +++ b/sql/item.h @@ -564,7 +564,6 @@ public: bool get_time(TIME *tm); bool get_date(TIME *tm, uint fuzzydate); int save_in_field(Field *field, bool no_conversions); - bool fix_fields(THD *, struct st_table_list *, Item **); void set_null(); void set_int(longlong i, uint32 max_length_arg); diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 20ba838e61c..dec32398a80 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -119,7 +119,6 @@ public: friend class Item_in_optimizer; friend bool Item_field::fix_fields(THD *, TABLE_LIST *, Item **); friend bool Item_ref::fix_fields(THD *, TABLE_LIST *, Item **); - friend bool Item_param::fix_fields(THD *, TABLE_LIST *, Item **); }; /* single value subselect */ diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 5c97269b5ce..722b76796b2 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -251,6 +251,8 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset; #define UNCACHEABLE_SIDEEFFECT 4 // forcing to save JOIN for explain #define UNCACHEABLE_EXPLAIN 8 +/* Don't evaluate subqueries in prepare even if they're not correlated */ +#define UNCACHEABLE_PREPARE 16 #ifdef EXTRA_DEBUG /* diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 927982e444f..07b5c9d8edf 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -257,6 +257,7 @@ public: UNCACHEABLE_RAND UNCACHEABLE_SIDEEFFECT UNCACHEABLE_EXPLAIN + UNCACHEABLE_PREPARE */ uint8 uncacheable; enum sub_select_type linkage; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d7fd3239df5..dc55a842263 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4123,6 +4123,14 @@ mysql_new_select(LEX *lex, bool move_down) select_lex->select_number= ++lex->thd->select_number; select_lex->init_query(); select_lex->init_select(); + /* + Don't evaluate this subquery during statement prepare even if + it's a constant one. The flag is switched off in the end of + mysql_stmt_prepare. + */ + if (lex->thd->current_arena->is_stmt_prepare()) + select_lex->uncacheable|= UNCACHEABLE_PREPARE; + if (move_down) { lex->subqueries= TRUE; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 9e2612c5661..f7e2bd0467e 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1657,13 +1657,18 @@ int mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, { stmt->setup_set_params(); SELECT_LEX *sl= stmt->lex->all_selects_list; - /* - Save WHERE clause pointers, because they may be changed during query - optimisation. - */ for (; sl; sl= sl->next_select_in_list()) { + /* + Save WHERE clause pointers, because they may be changed + during query optimisation. + */ sl->prep_where= sl->where; + /* + Switch off a temporary flag that prevents evaluation of + subqueries in statement prepare. + */ + sl->uncacheable&= ~UNCACHEABLE_PREPARE; } stmt->state= Item_arena::PREPARED; } |