diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.cc | 28 | ||||
-rw-r--r-- | sql/item.h | 1 | ||||
-rw-r--r-- | sql/item_subselect.h | 1 | ||||
-rw-r--r-- | sql/sql_parse.cc | 5 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 5 |
5 files changed, 10 insertions, 30 deletions
diff --git a/sql/item.cc b/sql/item.cc index c8d988c0ae9..88ac257fb4d 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1701,6 +1701,7 @@ void Item_param::set_null() max_length= 0; decimals= 0; state= NULL_VALUE; + item_type= Item::NULL_ITEM; DBUG_VOID_RETURN; } @@ -2246,33 +2247,6 @@ bool Item_param::convert_str_value(THD *thd) return rc; } -bool Item_param::fix_fields(THD *thd, 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 8a694a467ae..ce151ec85bf 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1039,7 +1039,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 *, 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 e05db4a00cc..0b5736169fa 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -121,7 +121,6 @@ public: friend class Item_in_optimizer; friend bool Item_field::fix_fields(THD *, Item **); friend bool Item_ref::fix_fields(THD *, Item **); - friend bool Item_param::fix_fields(THD *, Item **); friend void mark_select_range_as_dependent(THD*, st_select_lex*, st_select_lex*, Field*, Item*, Item_ident*); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 2fab847c4c3..a2e5501ad7d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5212,6 +5212,11 @@ mysql_new_select(LEX *lex, bool move_down) select_lex->init_query(); select_lex->init_select(); select_lex->parent_lex= lex; + /* + 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 (thd->current_arena->is_stmt_prepare()) select_lex->uncacheable|= UNCACHEABLE_PREPARE; if (move_down) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 53f706bd0f6..6d11518198c 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1825,7 +1825,10 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, void init_stmt_after_parse(THD *thd, LEX *lex) { SELECT_LEX *sl= lex->all_selects_list; - + /* + Switch off a temporary flag that prevents evaluation of + subqueries in statement prepare. + */ for (; sl; sl= sl->next_select_in_list()) sl->uncacheable&= ~UNCACHEABLE_PREPARE; } |