diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-06-05 10:50:08 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-06-05 10:50:08 +0400 |
commit | ab297744b7318645159cd5f9ec26378473cecf52 (patch) | |
tree | 28df98886259f9df535b84deff18a89e08064e58 /sql | |
parent | 8760acdda88cc5ead925024bc47df4d27f911bb0 (diff) | |
parent | 106f0b5798a2b5d13b7d67c3cc678fc0cc2184c2 (diff) | |
download | mariadb-git-ab297744b7318645159cd5f9ec26378473cecf52.tar.gz |
Merge remote-tracking branch 'origin/10.3' into 10.4
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.cc | 24 | ||||
-rw-r--r-- | sql/item.h | 23 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 12 | ||||
-rw-r--r-- | sql/item_func.cc | 9 | ||||
-rw-r--r-- | sql/item_row.cc | 3 | ||||
-rw-r--r-- | sql/item_subselect.cc | 18 | ||||
-rw-r--r-- | sql/item_sum.cc | 13 | ||||
-rw-r--r-- | sql/item_windowfunc.cc | 4 | ||||
-rw-r--r-- | sql/opt_subselect.cc | 25 | ||||
-rw-r--r-- | sql/set_var.cc | 6 | ||||
-rw-r--r-- | sql/sp_head.cc | 10 | ||||
-rw-r--r-- | sql/sql_analyse.cc | 2 | ||||
-rw-r--r-- | sql/sql_base.cc | 17 | ||||
-rw-r--r-- | sql/sql_class.h | 2 | ||||
-rw-r--r-- | sql/sql_derived.cc | 4 | ||||
-rw-r--r-- | sql/sql_get_diagnostics.cc | 3 | ||||
-rw-r--r-- | sql/sql_handler.cc | 8 | ||||
-rw-r--r-- | sql/sql_help.cc | 3 | ||||
-rw-r--r-- | sql/sql_insert.cc | 2 | ||||
-rw-r--r-- | sql/sql_lex.cc | 24 | ||||
-rw-r--r-- | sql/sql_lex.h | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 8 | ||||
-rw-r--r-- | sql/sql_partition.cc | 4 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 6 | ||||
-rw-r--r-- | sql/sql_select.cc | 34 | ||||
-rw-r--r-- | sql/sql_show.cc | 7 | ||||
-rw-r--r-- | sql/sql_signal.cc | 13 | ||||
-rw-r--r-- | sql/sql_trigger.cc | 3 | ||||
-rw-r--r-- | sql/sql_union.cc | 2 | ||||
-rw-r--r-- | sql/sql_view.cc | 2 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 5 | ||||
-rw-r--r-- | sql/table.cc | 20 | ||||
-rw-r--r-- | sql/table.h | 9 | ||||
-rw-r--r-- | sql/unireg.cc | 5 |
34 files changed, 132 insertions, 200 deletions
diff --git a/sql/item.cc b/sql/item.cc index 4f3f5087391..0a7972b6617 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1830,6 +1830,7 @@ Item_field *Item_splocal::get_variable(sp_rcontext *ctx) const bool Item_splocal::fix_fields(THD *thd, Item **ref) { + DBUG_ASSERT(!fixed); Item *item= get_variable(thd->spcont); set_handler(item->type_handler()); return fix_fields_from_item(thd, ref, item); @@ -1957,6 +1958,7 @@ bool Item_splocal::check_cols(uint n) bool Item_splocal_row_field::fix_fields(THD *thd, Item **ref) { + DBUG_ASSERT(!fixed); Item *item= get_variable(thd->spcont)->element_index(m_field_idx); return fix_fields_from_item(thd, ref, item); } @@ -2014,6 +2016,7 @@ bool Item_splocal_row_field::set_value(THD *thd, sp_rcontext *ctx, Item **it) bool Item_splocal_row_field_by_name::fix_fields(THD *thd, Item **it) { + DBUG_ASSERT(!fixed); m_thd= thd; if (get_rcontext(thd->spcont)->find_row_field_by_name_or_error(&m_field_idx, m_var_idx, @@ -2234,10 +2237,8 @@ bool Item_name_const::fix_fields(THD *thd, Item **ref) String s(buf, sizeof(buf), &my_charset_bin); s.length(0); - if ((!value_item->fixed && - value_item->fix_fields(thd, &value_item)) || - (!name_item->fixed && - name_item->fix_fields(thd, &name_item)) || + if (value_item->fix_fields_if_needed(thd, &value_item) || + name_item->fix_fields_if_needed(thd, &name_item) || !value_item->const_item() || !name_item->const_item() || !(item_name= name_item->val_str(&s))) // Can't have a NULL name @@ -9249,8 +9250,7 @@ bool Item_direct_view_ref::fix_fields(THD *thd, Item **reference) bitmap_set_bit(fld->table->read_set, fld->field_index); } } - else if (!(*ref)->fixed && - ((*ref)->fix_fields(thd, ref))) + else if ((*ref)->fix_fields_if_needed(thd, ref)) return TRUE; if (Item_direct_ref::fix_fields(thd, reference)) @@ -9278,7 +9278,7 @@ bool Item_outer_ref::fix_fields(THD *thd, Item **reference) { bool err; /* outer_ref->check_cols() will be made in Item_direct_ref::fix_fields */ - if ((*ref) && !(*ref)->fixed && ((*ref)->fix_fields(thd, reference))) + if ((*ref) && (*ref)->fix_fields_if_needed(thd, reference)) return TRUE; err= Item_direct_ref::fix_fields(thd, reference); if (!outer_ref) @@ -9517,7 +9517,7 @@ bool Item_default_value::fix_fields(THD *thd, Item **items) fixed= 1; return FALSE; } - if (!arg->fixed && arg->fix_fields(thd, &arg)) + if (arg->fix_fields_if_needed(thd, &arg)) goto error; @@ -9862,15 +9862,9 @@ bool Item_trigger_field::set_value(THD *thd, sp_rcontext * /*ctx*/, Item **it) { Item *item= thd->sp_prepare_func_item(it); - if (!item) + if (!item || fix_fields_if_needed(thd, NULL)) return true; - if (!fixed) - { - if (fix_fields(thd, NULL)) - return true; - } - // NOTE: field->table->copy_blobs should be false here, but let's // remember the value at runtime to avoid subtle bugs. bool copy_blobs_saved= field->table->copy_blobs; diff --git a/sql/item.h b/sql/item.h index b18da277c1e..94f1f6abdb4 100644 --- a/sql/item.h +++ b/sql/item.h @@ -902,6 +902,23 @@ public: void init_make_send_field(Send_field *tmp_field,enum enum_field_types type); virtual void cleanup(); virtual void make_send_field(THD *thd, Send_field *field); + + bool fix_fields_if_needed(THD *thd, Item **ref) + { + return fixed ? false : fix_fields(thd, ref); + } + bool fix_fields_if_needed_for_scalar(THD *thd, Item **ref) + { + return fix_fields_if_needed(thd, ref) || check_cols(1); + } + bool fix_fields_if_needed_for_bool(THD *thd, Item **ref) + { + return fix_fields_if_needed_for_scalar(thd, ref); + } + bool fix_fields_if_needed_for_order_by(THD *thd, Item **ref) + { + return fix_fields_if_needed_for_scalar(thd, ref); + } virtual bool fix_fields(THD *, Item **); /* Fix after some tables has been pulled out. Basically re-calculate all @@ -5164,8 +5181,7 @@ public: bool fix_fields(THD *thd, Item **it) { - if ((!(*ref)->fixed && (*ref)->fix_fields(thd, ref)) || - (*ref)->check_cols(1)) + if ((*ref)->fix_fields_if_needed_for_scalar(thd, ref)) return TRUE; return Item_ref::fix_fields(thd, it); } @@ -5203,8 +5219,7 @@ public: bool fix_fields(THD *thd, Item **it) { DBUG_ASSERT(ident->type() == FIELD_ITEM || ident->type() == REF_ITEM); - if ((!ident->fixed && ident->fix_fields(thd, ref)) || - ident->check_cols(1)) + if (ident->fix_fields_if_needed_for_scalar(thd, ref)) return TRUE; set_properties(); return FALSE; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 76f4788c1cf..3034636dca3 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1242,7 +1242,7 @@ bool Item_in_optimizer::fix_left(THD *thd) ref0= &(((Item_in_subselect *)args[1])->left_expr); args[0]= ((Item_in_subselect *)args[1])->left_expr; } - if ((!(*ref0)->fixed && (*ref0)->fix_fields(thd, ref0)) || + if ((*ref0)->fix_fields_if_needed(thd, ref0) || (!cache && !(cache= (*ref0)->get_cache(thd)))) DBUG_RETURN(1); /* @@ -1327,7 +1327,7 @@ bool Item_in_optimizer::fix_fields(THD *thd, Item **ref) if (args[0]->maybe_null) maybe_null=1; - if (!args[1]->fixed && args[1]->fix_fields(thd, args+1)) + if (args[1]->fix_fields_if_needed(thd, args + 1)) return TRUE; if (!invisible_mode() && ((sub && ((col= args[0]->cols()) != sub->engine->cols())) || @@ -4586,11 +4586,9 @@ Item_cond::fix_fields(THD *thd, Item **ref) thd->restore_active_arena(arena, &backup); } - // item can be substituted in fix_fields - if ((!item->fixed && - item->fix_fields(thd, li.ref())) || - (item= *li.ref())->check_cols(1)) + if (item->fix_fields_if_needed_for_bool(thd, li.ref())) return TRUE; /* purecov: inspected */ + item= *li.ref(); // item can be substituted in fix_fields used_tables_cache|= item->used_tables(); if (item->const_item() && !item->with_param && !item->is_expensive() && !cond_has_datetime_is_null(item)) @@ -5306,7 +5304,7 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref) { DBUG_ASSERT(fixed == 0); if (Item_bool_func2::fix_fields(thd, ref) || - escape_item->fix_fields(thd, &escape_item) || + escape_item->fix_fields_if_needed_for_scalar(thd, &escape_item) || fix_escape_item(thd, escape_item, &cmp_value1, escape_used_in_parsing, cmp_collation.collation, &escape)) return TRUE; diff --git a/sql/item_func.cc b/sql/item_func.cc index 4df3d5c102a..5567e733288 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -360,7 +360,7 @@ Item_func::fix_fields(THD *thd, Item **ref) We can't yet set item to *arg as fix_fields may change *arg We shouldn't call fix_fields() twice, so check 'fixed' field first */ - if ((!(*arg)->fixed && (*arg)->fix_fields(thd, arg))) + if ((*arg)->fix_fields_if_needed(thd, arg)) return TRUE; /* purecov: inspected */ item= *arg; @@ -3279,13 +3279,10 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func, arg != arg_end ; arg++,i++) { - if (!(*arg)->fixed && - (*arg)->fix_fields(thd, arg)) - DBUG_RETURN(1); + if ((*arg)->fix_fields_if_needed_for_scalar(thd, arg)) + DBUG_RETURN(true); // we can't assign 'item' before, because fix_fields() can change arg Item *item= *arg; - if (item->check_cols(1)) - DBUG_RETURN(TRUE); /* TODO: We should think about this. It is not always right way just to set an UDF result to return my_charset_bin diff --git a/sql/item_row.cc b/sql/item_row.cc index 74ea9ecc0c2..8233ba00f06 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -41,8 +41,7 @@ bool Item_row::fix_fields(THD *thd, Item **ref) Item **arg, **arg_end; for (arg= args, arg_end= args + arg_count; arg != arg_end ; arg++) { - if (!(*arg)->fixed && - (*arg)->fix_fields(thd, arg)) + if ((*arg)->fix_fields_if_needed(thd, arg)) return TRUE; // we can't assign 'item' before, because fix_fields() can change arg Item *item= *arg; diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index ba54605d1a3..048ec6a4fa1 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -302,8 +302,7 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref) engine->exclude(); substitution= 0; thd->where= "checking transformed subquery"; - if (!(*ref)->fixed) - res= (*ref)->fix_fields(thd, ref); + res= (*ref)->fix_fields_if_needed(thd, ref); goto end; } @@ -2181,7 +2180,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join, row_value_transformer? */ item->name= in_additional_cond; - if (!item->fixed && item->fix_fields(thd, 0)) + if (item->fix_fields_if_needed(thd, 0)) DBUG_RETURN(true); *where_item= item; } @@ -2504,7 +2503,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join, if (*where_item) { - if (!(*where_item)->fixed && (*where_item)->fix_fields(thd, 0)) + if ((*where_item)->fix_fields_if_needed(thd, 0)) DBUG_RETURN(true); (*where_item)->top_level_item(); } @@ -2651,7 +2650,7 @@ bool Item_in_subselect::inject_in_to_exists_cond(JOIN *join_arg) } where_item= and_items(thd, join_arg->conds, where_item); - if (!where_item->fixed && where_item->fix_fields(thd, 0)) + if (where_item->fix_fields_if_needed(thd, 0)) DBUG_RETURN(true); // TIMOUR TODO: call optimize_cond() for the new where clause thd->change_item_tree(&select_lex->where, where_item); @@ -3117,7 +3116,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg) exp= optimizer; } upper_not->arguments()[0]= exp; - if (!exp->fixed && exp->fix_fields(thd, upper_not->arguments())) + if (exp->fix_fields_if_needed(thd, upper_not->arguments())) { res= TRUE; goto out; @@ -3315,8 +3314,7 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref) } } - if (left_expr && !left_expr->fixed && - left_expr->fix_fields(thd_arg, &left_expr)) + if (left_expr && left_expr->fix_fields_if_needed(thd_arg, &left_expr)) goto err; else if (Item_subselect::fix_fields(thd_arg, ref)) @@ -4999,8 +4997,8 @@ bool subselect_hash_sj_engine::init(List<Item> *tmp_columns, uint subquery_id) Repeat name resolution for 'cond' since cond is not part of any clause of the query, and it is not 'fixed' during JOIN::prepare. */ - if (semi_join_conds && !semi_join_conds->fixed && - semi_join_conds->fix_fields(thd, (Item**)&semi_join_conds)) + if (semi_join_conds && + semi_join_conds->fix_fields_if_needed(thd, (Item**)&semi_join_conds)) DBUG_RETURN(TRUE); /* Let our engine reuse this query plan for materialization. */ materialize_join= materialize_engine->join; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 19e94be7882..c206e71ed9a 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1129,7 +1129,7 @@ Item_sum_num::fix_fields(THD *thd, Item **ref) maybe_null= sum_func() != COUNT_FUNC; for (uint i=0 ; i < arg_count ; i++) { - if (args[i]->fix_fields(thd, args + i) || args[i]->check_cols(1)) + if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i])) return TRUE; set_if_bigger(decimals, args[i]->decimals); m_with_subquery|= args[i]->with_subquery(); @@ -1156,14 +1156,11 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref) DBUG_ENTER("Item_sum_hybrid::fix_fields"); DBUG_ASSERT(fixed == 0); - Item *item= args[0]; - if (init_sum_func_check(thd)) DBUG_RETURN(TRUE); // 'item' can be changed during fix_fields - if ((!item->fixed && item->fix_fields(thd, args)) || - (item= args[0])->check_cols(1)) + if (args[0]->fix_fields_if_needed_for_scalar(thd, &args[0])) DBUG_RETURN(TRUE); m_with_subquery= args[0]->with_subquery(); @@ -1300,7 +1297,7 @@ Item_sum_sp::fix_fields(THD *thd, Item **ref) for (uint i= 0 ; i < arg_count ; i++) { - if (args[i]->fix_fields(thd, args + i) || args[i]->check_cols(1)) + if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i])) return TRUE; set_if_bigger(decimals, args[i]->decimals); m_with_subquery|= args[i]->with_subquery(); @@ -3911,9 +3908,7 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref) for (i=0 ; i < arg_count ; i++) { - if ((!args[i]->fixed && - args[i]->fix_fields(thd, args + i)) || - args[i]->check_cols(1)) + if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i])) return TRUE; m_with_subquery|= args[i]->with_subquery(); with_param|= args[i]->with_param; diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc index 85ca8b0624e..a7f8ef09f08 100644 --- a/sql/item_windowfunc.cc +++ b/sql/item_windowfunc.cc @@ -327,10 +327,8 @@ bool Item_sum_hybrid_simple::fix_fields(THD *thd, Item **ref) for (uint i= 0; i < arg_count; i++) { - Item *item= args[i]; // 'item' can be changed during fix_fields - if ((!item->fixed && item->fix_fields(thd, args)) || - (item= args[i])->check_cols(1)) + if (args[i]->fix_fields_if_needed_for_scalar(thd, &args[i])) return TRUE; } Type_std_attributes::set(args[0]); diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 800ee65fe26..7f7bb07d279 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -620,8 +620,8 @@ int check_and_do_in_subquery_rewrites(JOIN *join) char const *save_where= thd->where; thd->where= "IN/ALL/ANY subquery"; - bool failure= !in_subs->left_expr->fixed && - in_subs->left_expr->fix_fields(thd, &in_subs->left_expr); + bool failure= in_subs->left_expr->fix_fields_if_needed(thd, + &in_subs->left_expr); thd->lex->current_select= current; thd->where= save_where; if (failure) @@ -1666,8 +1666,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) */ SELECT_LEX *save_lex= thd->lex->current_select; thd->lex->current_select=subq_lex; - if (!subq_pred->left_expr->fixed && - subq_pred->left_expr->fix_fields(thd, &subq_pred->left_expr)) + if (subq_pred->left_expr->fix_fields_if_needed(thd, &subq_pred->left_expr)) DBUG_RETURN(TRUE); thd->lex->current_select=save_lex; @@ -1777,8 +1776,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) to check for this at name resolution stage, but as a legacy of IN->EXISTS we have in here). */ - if (!sj_nest->sj_on_expr->fixed && - sj_nest->sj_on_expr->fix_fields(thd, &sj_nest->sj_on_expr)) + if (sj_nest->sj_on_expr->fix_fields_if_needed(thd, &sj_nest->sj_on_expr)) { DBUG_RETURN(TRUE); } @@ -1804,9 +1802,8 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) emb_tbl_nest->on_expr= and_items(thd, emb_tbl_nest->on_expr, sj_nest->sj_on_expr); emb_tbl_nest->on_expr->top_level_item(); - if (!emb_tbl_nest->on_expr->fixed && - emb_tbl_nest->on_expr->fix_fields(thd, - &emb_tbl_nest->on_expr)) + if (emb_tbl_nest->on_expr->fix_fields_if_needed(thd, + &emb_tbl_nest->on_expr)) { DBUG_RETURN(TRUE); } @@ -1822,9 +1819,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) */ save_lex= thd->lex->current_select; thd->lex->current_select=parent_join->select_lex; - if (!parent_join->conds->fixed && - parent_join->conds->fix_fields(thd, - &parent_join->conds)) + if (parent_join->conds->fix_fields_if_needed(thd, &parent_join->conds)) { DBUG_RETURN(1); } @@ -3724,7 +3719,7 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab) re-executing it will not be prepared. To use the Items from its select list we have to prepare (fix_fields) them */ - if (!item->fixed && item->fix_fields(thd, it.ref())) + if (item->fix_fields_if_needed(thd, it.ref())) DBUG_RETURN(TRUE); item= *(it.ref()); // it can be changed by fix_fields DBUG_ASSERT(!item->name.length || item->name.length == strlen(item->name.str)); @@ -5587,7 +5582,7 @@ Item *and_new_conditions_to_optimized_cond(THD *thd, Item *cond, li.rewind(); while ((item=li++)) { - if (!item->fixed && item->fix_fields(thd, NULL)) + if (item->fix_fields_if_needed(thd, NULL)) return NULL; if (item->const_item() && !item->val_int()) is_simplified_cond= true; @@ -5648,7 +5643,7 @@ Item *and_new_conditions_to_optimized_cond(THD *thd, Item *cond, cond= iter++; } - if (!cond->fixed && cond->fix_fields(thd, NULL)) + if (cond->fix_fields_if_needed(thd, NULL)) return NULL; if (new_cond_equal.current_level.elements > 0) diff --git a/sql/set_var.cc b/sql/set_var.cc index 7bf6b9f928d..c9dfeb3e211 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -768,8 +768,7 @@ int set_var::check(THD *thd) if (!value) return 0; - if ((!value->fixed && - value->fix_fields(thd, &value)) || value->check_cols(1)) + if (value->fix_fields_if_needed_for_scalar(thd, &value)) return -1; if (var->check_update_type(value)) { @@ -803,8 +802,7 @@ int set_var::light_check(THD *thd) if (type == OPT_GLOBAL && check_global_access(thd, SUPER_ACL)) return 1; - if (value && ((!value->fixed && value->fix_fields(thd, &value)) || - value->check_cols(1))) + if (value && value->fix_fields_if_needed_for_scalar(thd, &value)) return -1; return 0; } diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 5fa1a76fbe4..ea3ddcf617d 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -98,7 +98,7 @@ sp_map_item_type(const Type_handler *handler) bool Item_splocal::append_for_log(THD *thd, String *str) { - if (fix_fields(thd, NULL)) + if (fix_fields_if_needed(thd, NULL)) return true; if (limit_clause_param) @@ -136,7 +136,7 @@ bool Item_splocal::append_value_for_log(THD *thd, String *str) bool Item_splocal_row_field::append_for_log(THD *thd, String *str) { - if (fix_fields(thd, NULL)) + if (fix_fields_if_needed(thd, NULL)) return true; if (limit_clause_param) @@ -372,16 +372,14 @@ Item *THD::sp_prepare_func_item(Item **it_addr, uint cols) Item *THD::sp_fix_func_item(Item **it_addr) { DBUG_ENTER("THD::sp_fix_func_item"); - if (!(*it_addr)->fixed && - (*it_addr)->fix_fields(this, it_addr)) + if ((*it_addr)->fix_fields_if_needed(this, it_addr)) { DBUG_PRINT("info", ("fix_fields() failed")); DBUG_RETURN(NULL); } it_addr= (*it_addr)->this_item_addr(this, it_addr); - if (!(*it_addr)->fixed && - (*it_addr)->fix_fields(this, it_addr)) + if ((*it_addr)->fix_fields_if_needed(this, it_addr)) { DBUG_PRINT("info", ("fix_fields() failed")); DBUG_RETURN(NULL); diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index ce1c136fb44..0990379add7 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -71,7 +71,7 @@ int compare_decimal2(int* len, const char *s, const char *t) static bool prepare_param(THD *thd, Item **item, const char *proc_name, uint pos) { - if (!(*item)->fixed && (*item)->fix_fields(thd, item)) + if ((*item)->fix_fields_if_needed(thd, item)) { DBUG_PRINT("info", ("fix_fields() for the parameter %u failed", pos)); return true; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index d494d4e16c2..00f45b1edf1 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5625,8 +5625,7 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name, si calls fix_fields on that item), it's just a check during table reopening for columns that was dropped by the concurrent connection. */ - if (!nj_col->table_field->fixed && - nj_col->table_field->fix_fields(thd, &ref)) + if (nj_col->table_field->fix_fields_if_needed(thd, &ref)) { DBUG_PRINT("info", ("column '%s' was dropped by the concurrent connection", nj_col->table_field->name.str)); @@ -7327,8 +7326,7 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, if (make_pre_fix) pre_fix->push_back(item, thd->stmt_arena->mem_root); - if ((!item->fixed && item->fix_fields(thd, it.ref())) || - (item= *(it.ref()))->check_cols(1)) + if (item->fix_fields_if_needed_for_scalar(thd, it.ref())) { thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; thd->lex->allow_sum_func= save_allow_sum_func; @@ -7336,6 +7334,7 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage)); DBUG_RETURN(TRUE); /* purecov: inspected */ } + item= *(it.ref()); // Item might have changed in fix_fields() if (!ref.is_null()) { ref[0]= item; @@ -7957,9 +7956,8 @@ bool setup_on_expr(THD *thd, TABLE_LIST *table, bool is_update) { thd->where="on clause"; embedded->on_expr->mark_as_condition_AND_part(embedded); - if ((!embedded->on_expr->fixed && - embedded->on_expr->fix_fields(thd, &embedded->on_expr)) || - embedded->on_expr->check_cols(1)) + if (embedded->on_expr->fix_fields_if_needed_for_bool(thd, + &embedded->on_expr)) return TRUE; } /* @@ -7969,7 +7967,7 @@ bool setup_on_expr(THD *thd, TABLE_LIST *table, bool is_update) if (embedded->sj_subq_pred) { Item **left_expr= &embedded->sj_subq_pred->left_expr; - if (!(*left_expr)->fixed && (*left_expr)->fix_fields(thd, left_expr)) + if ((*left_expr)->fix_fields_if_needed(thd, left_expr)) return TRUE; } @@ -8067,8 +8065,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves, if ((*conds)->type() == Item::FIELD_ITEM && !derived) wrap_ident(thd, conds); (*conds)->mark_as_condition_AND_part(NO_JOIN_NEST); - if ((!(*conds)->fixed && (*conds)->fix_fields(thd, conds)) || - (*conds)->check_cols(1)) + if ((*conds)->fix_fields_if_needed_for_bool(thd, conds)) goto err_no_arena; } diff --git a/sql/sql_class.h b/sql/sql_class.h index 64b75dbe7be..5adb5bf3823 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1007,8 +1007,6 @@ public: { return state == STMT_PREPARED || state == STMT_EXECUTED; } inline bool is_conventional() const { return state == STMT_CONVENTIONAL_EXECUTION; } - inline bool is_sp_execute() const - { return is_stored_procedure; } inline void* alloc(size_t size) { return alloc_root(mem_root,size); } inline void* calloc(size_t size) diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 944fc837572..39630293c20 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -465,9 +465,7 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived) derived->prep_on_expr= expr->copy_andor_structure(thd); } if (derived->on_expr && - ((!derived->on_expr->fixed && - derived->on_expr->fix_fields(thd, &derived->on_expr)) || - derived->on_expr->check_cols(1))) + derived->on_expr->fix_fields_if_needed_for_bool(thd, &derived->on_expr)) { res= TRUE; /* purecov: inspected */ goto exit_merge; diff --git a/sql/sql_get_diagnostics.cc b/sql/sql_get_diagnostics.cc index 6a3cec79160..1b64819732c 100644 --- a/sql/sql_get_diagnostics.cc +++ b/sql/sql_get_diagnostics.cc @@ -217,8 +217,7 @@ Condition_information::aggregate(THD *thd, const Diagnostics_area *da) DBUG_ENTER("Condition_information::aggregate"); /* Prepare the expression for evaluation. */ - if (!m_cond_number_expr->fixed && - m_cond_number_expr->fix_fields(thd, &m_cond_number_expr)) + if (m_cond_number_expr->fix_fields_if_needed(thd, &m_cond_number_expr)) DBUG_RETURN(true); cond_number= m_cond_number_expr->val_int(); diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index c03a004e669..7c2ccf1b155 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -628,8 +628,7 @@ mysql_ha_fix_cond_and_key(SQL_HANDLER *handler, /* This can only be true for temp tables */ if (table->query_id != thd->query_id) cond->cleanup(); // File was reopened - if ((!cond->fixed && - cond->fix_fields(thd, &cond)) || cond->check_cols(1)) + if (cond->fix_fields_if_needed_for_bool(thd, &cond)) return 1; } @@ -693,10 +692,9 @@ mysql_ha_fix_cond_and_key(SQL_HANDLER *handler, { my_bitmap_map *old_map; /* note that 'item' can be changed by fix_fields() call */ - if ((!item->fixed && - item->fix_fields(thd, it_ke.ref())) || - (item= *it_ke.ref())->check_cols(1)) + if (item->fix_fields_if_needed_for_scalar(thd, it_ke.ref())) return 1; + item= *it_ke.ref(); if (item->used_tables() & ~(RAND_TABLE_BIT | PARAM_TABLE_BIT)) { my_error(ER_WRONG_ARGUMENTS,MYF(0),"HANDLER ... READ"); diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 085e54dbc90..aa9f3fedd6d 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -611,8 +611,7 @@ int send_variant_2_list(MEM_ROOT *mem_root, Protocol *protocol, SQL_SELECT *prepare_simple_select(THD *thd, Item *cond, TABLE *table, int *error) { - if (!cond->fixed) - cond->fix_fields(thd, &cond); // can never fail + cond->fix_fields_if_needed(thd, &cond); // can never fail /* Assume that no indexes cover all required fields */ table->covering_keys.clear_all(); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 80d84caf456..6eefa322bf2 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1317,7 +1317,7 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view) /* check simplicity and prepare unique test of view */ for (trans= trans_start; trans != trans_end; trans++) { - if (!trans->item->fixed && trans->item->fix_fields(thd, &trans->item)) + if (trans->item->fix_fields_if_needed(thd, &trans->item)) { thd->column_usage= saved_column_usage; DBUG_RETURN(TRUE); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 1dd209e3627..9922bdf7e59 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2682,15 +2682,9 @@ ha_rows st_select_lex::get_offset() if (offset_limit) { // see comment for st_select_lex::get_limit() - bool fix_fields_successful= true; - if (!offset_limit->fixed) - { - fix_fields_successful= !offset_limit->fix_fields(master_unit()->thd, - NULL); - - DBUG_ASSERT(fix_fields_successful); - } - val= fix_fields_successful ? offset_limit->val_uint() : HA_POS_ERROR; + bool err= offset_limit->fix_fields_if_needed(master_unit()->thd, NULL); + DBUG_ASSERT(!err); + val= err ? HA_POS_ERROR : offset_limit->val_uint(); } return (ha_rows)val; @@ -2729,15 +2723,9 @@ ha_rows st_select_lex::get_limit() fix_fields() implementation. Also added runtime check against a result of fix_fields() in order to handle error condition in non-debug build. */ - bool fix_fields_successful= true; - if (!select_limit->fixed) - { - fix_fields_successful= !select_limit->fix_fields(master_unit()->thd, - NULL); - - DBUG_ASSERT(fix_fields_successful); - } - val= fix_fields_successful ? select_limit->val_uint() : HA_POS_ERROR; + bool err= select_limit->fix_fields_if_needed(master_unit()->thd, NULL); + DBUG_ASSERT(!err); + val= err ? HA_POS_ERROR : select_limit->val_uint(); } return (ha_rows)val; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index c3ef33ea9dd..ebf643a5aa1 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -3333,7 +3333,7 @@ public: List_iterator_fast<Item> param_it(prepared_stmt_params); while (Item *param= param_it++) { - if (param->fix_fields(thd, 0) || param->check_cols(1)) + if (param->fix_fields_if_needed_for_scalar(thd, 0)) return true; } return false; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 280f9e65c29..a722bebe7bc 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3709,8 +3709,7 @@ mysql_execute_command(THD *thd) Item **it= lex->value_list.head_ref(); if (!(*it)->basic_const_item() || - (!(*it)->fixed && (*it)->fix_fields(lex->thd, it)) || - (*it)->check_cols(1)) + (*it)->fix_fields_if_needed_for_scalar(lex->thd, it)) { my_message(ER_SET_CONSTANTS_ONLY, ER_THD(thd, ER_SET_CONSTANTS_ONLY), MYF(0)); @@ -3819,8 +3818,7 @@ mysql_execute_command(THD *thd) goto error; /* PURGE MASTER LOGS BEFORE 'data' */ it= (Item *)lex->value_list.head(); - if ((!it->fixed && it->fix_fields(lex->thd, &it)) || - it->check_cols(1)) + if (it->fix_fields_if_needed_for_scalar(lex->thd, &it)) { my_error(ER_WRONG_ARGUMENTS, MYF(0), "PURGE LOGS BEFORE"); goto error; @@ -5680,7 +5678,7 @@ end_with_restore_list: if (lex->kill_type == KILL_TYPE_ID || lex->kill_type == KILL_TYPE_QUERY) { Item *it= (Item *)lex->value_list.head(); - if ((!it->fixed && it->fix_fields(lex->thd, &it)) || it->check_cols(1)) + if (it->fix_fields_if_needed_for_scalar(lex->thd, &it)) { my_message(ER_SET_CONSTANTS_ONLY, ER_THD(thd, ER_SET_CONSTANTS_ONLY), MYF(0)); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 813bb8e03eb..54907c0edbc 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -146,7 +146,7 @@ Item* convert_charset_partition_constant(Item *item, CHARSET_INFO *cs) item= item->safe_charset_converter(thd, cs); context->table_list= NULL; thd->where= "convert character set partition constant"; - if (!item || item->fix_fields(thd, (Item**)NULL)) + if (item->fix_fields_if_needed(thd, (Item**)NULL)) item= NULL; thd->where= save_where; context->table_list= save_list; @@ -854,7 +854,7 @@ static bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, const nesting_map saved_allow_sum_func= thd->lex->allow_sum_func; thd->lex->allow_sum_func= 0; - if (likely(!(error= func_expr->fix_fields(thd, (Item**)&func_expr)))) + if (likely(!(error= func_expr->fix_fields_if_needed(thd, (Item**)&func_expr)))) func_expr->walk(&Item::post_fix_fields_part_expr_processor, 0, NULL); /* diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 49e22b1e0e4..8d8047601d5 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1656,8 +1656,7 @@ static bool mysql_test_call_fields(Prepared_statement *stmt, while ((item= it++)) { - if ((!item->fixed && item->fix_fields(thd, it.ref())) || - item->check_cols(1)) + if (item->fix_fields_if_needed_for_scalar(thd, it.ref())) goto err; } DBUG_RETURN(FALSE); @@ -2665,8 +2664,7 @@ end: bool LEX::get_dynamic_sql_string(LEX_CSTRING *dst, String *buffer) { - if (prepared_stmt_code->fix_fields(thd, NULL) || - prepared_stmt_code->check_cols(1)) + if (prepared_stmt_code->fix_fields_if_needed_for_scalar(thd, NULL)) return true; const String *str= prepared_stmt_code->val_str(buffer); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 640ee072ca6..652949201f0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -531,7 +531,7 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select, ref->outer_ref= new_ref; ref->ref= &ref->outer_ref; - if (!ref->fixed && ref->fix_fields(thd, 0)) + if (ref->fix_fields_if_needed(thd, 0)) return TRUE; thd->lex->used_tables|= item->used_tables(); thd->lex->current_select->select_list_tables|= item->used_tables(); @@ -678,7 +678,6 @@ bool vers_select_conds_t::init_from_sysvar(THD *thd) vers_asof_timestamp_t &in= thd->variables.vers_asof_timestamp; type= (vers_system_time_t) in.type; start.unit= VERS_TIMESTAMP; - from_query= false; if (type != SYSTEM_TIME_UNSPECIFIED && type != SYSTEM_TIME_ALL) { DBUG_ASSERT(type == SYSTEM_TIME_AS_OF); @@ -726,7 +725,7 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables) TABLE_LIST *table; if (!thd->stmt_arena->is_conventional() && - !thd->stmt_arena->is_stmt_prepare() && !thd->stmt_arena->is_sp_execute()) + !thd->stmt_arena->is_stmt_prepare_or_first_sp_execute()) { // statement is already prepared DBUG_RETURN(0); @@ -741,7 +740,7 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables) { if (table->table && table->table->versioned()) versioned_tables++; - else if (table->vers_conditions.user_defined() && + else if (table->vers_conditions.is_set() && (table->is_non_derived() || !table->vers_conditions.used)) { my_error(ER_VERS_NOT_VERSIONED, MYF(0), table->alias.str); @@ -1141,9 +1140,7 @@ JOIN::prepare(TABLE_LIST *tables_init, if (having->type() == Item::REF_ITEM && ((Item_ref *)having)->ref_type() == Item_ref::REF) wrap_ident(thd, &having); - bool having_fix_rc= (!having->fixed && - (having->fix_fields(thd, &having) || - having->check_cols(1))); + bool having_fix_rc= having->fix_fields_if_needed_for_bool(thd, &having); select_lex->having_fix_field= 0; if (unlikely(having_fix_rc || thd->is_error())) @@ -2713,10 +2710,10 @@ bool JOIN::add_having_as_table_cond(JOIN_TAB *tab) sort_table_cond))) DBUG_RETURN(true); } - if (tab->select->cond && !tab->select->cond->fixed) - tab->select->cond->fix_fields(thd, 0); - if (tab->pre_idx_push_select_cond && !tab->pre_idx_push_select_cond->fixed) - tab->pre_idx_push_select_cond->fix_fields(thd, 0); + if (tab->select->cond) + tab->select->cond->fix_fields_if_needed(thd, 0); + if (tab->pre_idx_push_select_cond) + tab->pre_idx_push_select_cond->fix_fields_if_needed(thd, 0); tab->select->pre_idx_push_select_cond= tab->pre_idx_push_select_cond; tab->set_select_cond(tab->select->cond, __LINE__); tab->select_cond->top_level_item(); @@ -9386,7 +9383,7 @@ bool JOIN::inject_cond_into_where(Item *injected_cond) } where_item= and_items(thd, conds, where_item); - if (!where_item->fixed && where_item->fix_fields(thd, 0)) + if (where_item->fix_fields_if_needed(thd, 0)) return true; thd->change_item_tree(&select_lex->where, where_item); select_lex->where->top_level_item(); @@ -22872,8 +22869,8 @@ find_order_in_list(THD *thd, Ref_ptr_array ref_pointer_array, original field name, we should additionally check if we have conflict for this name (in case if we would perform lookup in all tables). */ - if (resolution == RESOLVED_BEHIND_ALIAS && !order_item->fixed && - order_item->fix_fields(thd, order->item)) + if (resolution == RESOLVED_BEHIND_ALIAS && + order_item->fix_fields_if_needed_for_order_by(thd, order->item)) return TRUE; /* Lookup the current GROUP field in the FROM clause. */ @@ -22954,11 +22951,10 @@ find_order_in_list(THD *thd, Ref_ptr_array ref_pointer_array, We check order_item->fixed because Item_func_group_concat can put arguments for which fix_fields already was called. */ - if (!order_item->fixed && - (order_item->fix_fields(thd, order->item) || - (order_item= *order->item)->check_cols(1) || - thd->is_error())) + if (order_item->fix_fields_if_needed_for_order_by(thd, order->item) || + thd->is_error()) return TRUE; /* Wrong field. */ + order_item= *order->item; // Item can change during fix_fields() if (!add_to_all_fields) return FALSE; @@ -24256,7 +24252,7 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab) { Item *new_cond= and_conds(thd, cond_copy, join_tab->select->pre_idx_push_select_cond); - if (!new_cond->fixed && new_cond->fix_fields(thd, &new_cond)) + if (new_cond->fix_fields_if_needed(thd, &new_cond)) error= 1; join_tab->pre_idx_push_select_cond= join_tab->select->pre_idx_push_select_cond= new_cond; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 95144b8c76e..4923c628bf9 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -8455,8 +8455,7 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list) Field_translator *end= table_list->field_translation_end; for (transl= table_list->field_translation; transl < end; transl++) { - if (!transl->item->fixed && - transl->item->fix_fields(thd, &transl->item)) + if (transl->item->fix_fields_if_needed(thd, &transl->item)) DBUG_RETURN(1); } DBUG_RETURN(0); @@ -8473,10 +8472,8 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list) { transl->item= item; transl->name= item->name; - if (!item->fixed && item->fix_fields(thd, &transl->item)) - { + if (item->fix_fields_if_needed(thd, &transl->item)) DBUG_RETURN(1); - } } table_list->field_translation= org_transl; table_list->field_translation_end= transl; diff --git a/sql/sql_signal.cc b/sql/sql_signal.cc index 7a28ba65ba2..a92d40f6bb3 100644 --- a/sql/sql_signal.cc +++ b/sql/sql_signal.cc @@ -218,16 +218,9 @@ int Sql_cmd_common_signal::eval_signal_informations(THD *thd, Sql_condition *con i <= LAST_DIAG_SET_PROPERTY; i++) { - set= m_set_signal_information.m_item[i]; - if (set) - { - if (! set->fixed) - { - if (set->fix_fields(thd, & set)) - goto end; - m_set_signal_information.m_item[i]= set; - } - } + if ((set= m_set_signal_information.m_item[i]) && + set->fix_fields_if_needed(thd, &m_set_signal_information.m_item[i])) + goto end; } /* diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 1a71b558bc2..7db4c6c3821 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -797,8 +797,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, */ trg_field->setup_field(thd, table, NULL); - if (!trg_field->fixed && - trg_field->fix_fields(thd, (Item **)0)) + if (trg_field->fix_fields_if_needed(thd, (Item **)0)) DBUG_RETURN(true); } diff --git a/sql/sql_union.cc b/sql/sql_union.cc index a1963c33a42..266f221ca78 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -1008,7 +1008,7 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg, { if (with_element) { - if (derived_arg->with->rename_columns_of_derived_unit(thd, this)) + if (with_element->rename_columns_of_derived_unit(thd, this)) goto err; if (check_duplicate_names(thd, sl->item_list, 0)) goto err; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 6679334552b..783c655d007 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1938,7 +1938,7 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view) DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage)); for (Field_translator *fld= trans; fld < end_of_trans; fld++) { - if (!fld->item->fixed && fld->item->fix_fields(thd, &fld->item)) + if (fld->item->fix_fields_if_needed(thd, &fld->item)) { thd->column_usage= saved_column_usage; DBUG_RETURN(TRUE); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 049b2c0cac9..b53a89ecc94 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -11788,9 +11788,10 @@ table_primary_ident: pop_index_hints(), $3)))) MYSQL_YYABORT; - Select->add_joined_table($$); + TABLE_LIST *tl= $$; + Select->add_joined_table(tl); if ($4) - $$->vers_conditions= Lex->vers_conditions; + tl->vers_conditions= Lex->vers_conditions; } ; diff --git a/sql/table.cc b/sql/table.cc index 3ba229b9af0..fc53ac9d821 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -4915,10 +4915,8 @@ bool TABLE_LIST::prep_where(THD *thd, Item **conds, { if (where->fixed) where->update_used_tables(); - if (!where->fixed && where->fix_fields(thd, &where)) - { + else if (where->fix_fields(thd, &where)) DBUG_RETURN(TRUE); - } /* check that it is not VIEW in which we insert with INSERT SELECT @@ -4948,12 +4946,12 @@ bool TABLE_LIST::prep_where(THD *thd, Item **conds, } if (tbl == 0) { - if (*conds && !(*conds)->fixed) - res= (*conds)->fix_fields(thd, conds); + if (*conds) + res= (*conds)->fix_fields_if_needed_for_bool(thd, conds); if (!res) *conds= and_conds(thd, *conds, where->copy_andor_structure(thd)); - if (*conds && !(*conds)->fixed && !res) - res= (*conds)->fix_fields(thd, conds); + if (*conds && !res) + res= (*conds)->fix_fields_if_needed_for_bool(thd, conds); } if (arena) thd->restore_active_arena(arena, &backup); @@ -5100,12 +5098,8 @@ bool TABLE_LIST::prep_check_option(THD *thd, uint8 check_opt_type) { const char *save_where= thd->where; thd->where= "check option"; - if ((!check_option->fixed && - check_option->fix_fields(thd, &check_option)) || - check_option->check_cols(1)) - { + if (check_option->fix_fields_if_needed_for_bool(thd, &check_option)) DBUG_RETURN(TRUE); - } thd->where= save_where; } DBUG_RETURN(FALSE); @@ -8736,7 +8730,7 @@ bool Vers_history_point::resolve_unit(THD *thd) { if (!item) return false; - if (!item->fixed && item->fix_fields(thd, &item)) + if (item->fix_fields_if_needed(thd, &item)) return true; return item->this_item()->type_handler_for_system_time()-> Vers_history_point_resolve_unit(thd, this); diff --git a/sql/table.h b/sql/table.h index e61fb246d4e..785fd9f3427 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1830,7 +1830,6 @@ public: struct vers_select_conds_t { vers_system_time_t type; - bool from_query:1; bool used:1; Vers_history_point start; Vers_history_point end; @@ -1838,7 +1837,7 @@ struct vers_select_conds_t void empty() { type= SYSTEM_TIME_UNSPECIFIED; - used= from_query= false; + used= false; start.empty(); end.empty(); } @@ -1848,7 +1847,7 @@ struct vers_select_conds_t Vers_history_point _end= Vers_history_point()) { type= _type; - used= from_query= false; + used= false; start= _start; end= _end; } @@ -1862,10 +1861,6 @@ struct vers_select_conds_t return type != SYSTEM_TIME_UNSPECIFIED; } bool resolve_units(THD *thd); - bool user_defined() const - { - return !from_query && type != SYSTEM_TIME_UNSPECIFIED; - } bool eq(const vers_select_conds_t &conds) const; }; diff --git a/sql/unireg.cc b/sql/unireg.cc index 796101e0efb..4692b2d74d1 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -1057,9 +1057,8 @@ static bool make_empty_rec(THD *thd, uchar *buff, uint table_options, field->real_field_type() == MYSQL_TYPE_GEOMETRY)) { Item *expr= field->default_value->expr; - - int res= !expr->fixed && // may be already fixed if ALTER TABLE - expr->fix_fields(thd, &expr); + // may be already fixed if ALTER TABLE + int res= expr->fix_fields_if_needed(thd, &expr); if (!res) res= expr->save_in_field(regfield, 1); if (!res && (field->flags & BLOB_FLAG)) |