diff options
-rw-r--r-- | plugin/func_test/plugin.cc | 2 | ||||
-rw-r--r-- | plugin/type_inet/item_inetfunc.h | 8 | ||||
-rw-r--r-- | plugin/type_uuid/item_uuidfunc.h | 2 | ||||
-rw-r--r-- | sql/item.h | 2 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 47 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 42 | ||||
-rw-r--r-- | sql/item_func.cc | 61 | ||||
-rw-r--r-- | sql/item_func.h | 130 | ||||
-rw-r--r-- | sql/item_geofunc.cc | 6 | ||||
-rw-r--r-- | sql/item_geofunc.h | 48 | ||||
-rw-r--r-- | sql/item_jsonfunc.cc | 50 | ||||
-rw-r--r-- | sql/item_jsonfunc.h | 46 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 74 | ||||
-rw-r--r-- | sql/item_strfunc.h | 156 | ||||
-rw-r--r-- | sql/item_sum.cc | 20 | ||||
-rw-r--r-- | sql/item_sum.h | 26 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 24 | ||||
-rw-r--r-- | sql/item_timefunc.h | 90 | ||||
-rw-r--r-- | sql/item_vers.h | 8 | ||||
-rw-r--r-- | sql/item_windowfunc.cc | 6 | ||||
-rw-r--r-- | sql/item_windowfunc.h | 12 | ||||
-rw-r--r-- | sql/item_xmlfunc.cc | 10 | ||||
-rw-r--r-- | sql/item_xmlfunc.h | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 | ||||
-rw-r--r-- | sql/sql_type_fixedbin.h | 2 |
25 files changed, 432 insertions, 444 deletions
diff --git a/plugin/func_test/plugin.cc b/plugin/func_test/plugin.cc index f59ee82388c..5cbf05f4f24 100644 --- a/plugin/func_test/plugin.cc +++ b/plugin/func_test/plugin.cc @@ -29,7 +29,7 @@ public: null_value= str->copy(STRING_WITH_LEN("sysconst_test"), system_charset_info); return null_value ? NULL : str; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen; set_maybe_null(); diff --git a/plugin/type_inet/item_inetfunc.h b/plugin/type_inet/item_inetfunc.h index 4acb42d2175..da87c7b3309 100644 --- a/plugin/type_inet/item_inetfunc.h +++ b/plugin/type_inet/item_inetfunc.h @@ -37,7 +37,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("inet_aton") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals= 0; max_length= 21; @@ -65,7 +65,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("inet_ntoa") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals= 0; fix_length_and_charset(3 * 8 + 7, default_charset()); @@ -111,7 +111,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("inet6_aton") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals= 0; fix_length_and_charset(16, &my_charset_bin); @@ -143,7 +143,7 @@ public: return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals= 0; diff --git a/plugin/type_uuid/item_uuidfunc.h b/plugin/type_uuid/item_uuidfunc.h index 296b6592f10..aa6ff999b99 100644 --- a/plugin/type_uuid/item_uuidfunc.h +++ b/plugin/type_uuid/item_uuidfunc.h @@ -27,7 +27,7 @@ protected: { return MY_UUID_BARE_STRING_LENGTH + with_dashes*MY_UUID_SEPARATORS; } public: Item_func_sys_guid(THD *thd): Item_str_func(thd), with_dashes(false) {} - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { collation.set(DTCollation_numeric()); fix_char_length(uuid_len()); diff --git a/sql/item.h b/sql/item.h index 46a513023dd..d8f2b62c743 100644 --- a/sql/item.h +++ b/sql/item.h @@ -5458,7 +5458,7 @@ public: inline const char *func_name() const { return (char*) func_name_cstring().str; } virtual LEX_CSTRING func_name_cstring() const= 0; - virtual bool fix_length_and_dec()= 0; + virtual bool fix_length_and_dec(THD *thd)= 0; bool const_item() const override { return const_item_cache; } table_map used_tables() const override { return used_tables_cache; } Item* build_clone(THD *thd) override; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 034833a0ba2..dbfbc07a600 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -436,7 +436,7 @@ Item_bool_rowready_func2::value_depends_on_sql_mode() const } -bool Item_bool_rowready_func2::fix_length_and_dec() +bool Item_bool_rowready_func2::fix_length_and_dec(THD *thd) { max_length= 1; // Function returns 0 or 1 @@ -1137,7 +1137,7 @@ int Arg_comparator::compare_e_str_json() } -bool Item_func_truth::fix_length_and_dec() +bool Item_func_truth::fix_length_and_dec(THD *thd) { base_flags&= ~item_base_t::MAYBE_NULL; null_value= 0; @@ -1766,9 +1766,9 @@ longlong Item_func_eq::val_int() /** Same as Item_func_eq, but NULL = NULL. */ -bool Item_func_equal::fix_length_and_dec() +bool Item_func_equal::fix_length_and_dec(THD *thd) { - bool rc= Item_bool_rowready_func2::fix_length_and_dec(); + bool rc= Item_bool_rowready_func2::fix_length_and_dec(thd); base_flags&= ~item_base_t::MAYBE_NULL; null_value=0; return rc; @@ -1865,7 +1865,7 @@ bool Item_func_interval::fix_fields(THD *thd, Item **ref) } -bool Item_func_interval::fix_length_and_dec() +bool Item_func_interval::fix_length_and_dec(THD *thd) { uint rows= row->cols(); @@ -2099,7 +2099,7 @@ void Item_func_between::fix_after_pullout(st_select_lex *new_parent, eval_not_null_tables(NULL); } -bool Item_func_between::fix_length_and_dec() +bool Item_func_between::fix_length_and_dec(THD *thd) { max_length= 1; @@ -2113,7 +2113,7 @@ bool Item_func_between::fix_length_and_dec() func_name_cstring(), args, 3, false)) { - DBUG_ASSERT(current_thd->is_error()); + DBUG_ASSERT(thd->is_error()); return TRUE; } @@ -2555,7 +2555,7 @@ void Item_func_nullif::update_used_tables() bool -Item_func_nullif::fix_length_and_dec() +Item_func_nullif::fix_length_and_dec(THD *thd) { /* If this is the first invocation of fix_length_and_dec(), create the @@ -2567,7 +2567,6 @@ Item_func_nullif::fix_length_and_dec() if (arg_count == 2) args[arg_count++]= m_arg0 ? m_arg0 : args[0]; - THD *thd= current_thd; /* At prepared statement EXECUTE time, args[0] can already point to a different Item, created during PREPARE time fix_length_and_dec(). @@ -3177,24 +3176,21 @@ bool Item_func_case_simple::prepare_predicant_and_values(THD *thd, } -bool Item_func_case_searched::fix_length_and_dec() +bool Item_func_case_searched::fix_length_and_dec(THD *thd) { - THD *thd= current_thd; return aggregate_then_and_else_arguments(thd, when_count()); } -bool Item_func_case_simple::fix_length_and_dec() +bool Item_func_case_simple::fix_length_and_dec(THD *thd) { - THD *thd= current_thd; return (aggregate_then_and_else_arguments(thd, when_count() + 1) || aggregate_switch_and_when_arguments(thd, false)); } -bool Item_func_decode_oracle::fix_length_and_dec() +bool Item_func_decode_oracle::fix_length_and_dec(THD *thd) { - THD *thd= current_thd; return (aggregate_then_and_else_arguments(thd, when_count() + 1) || aggregate_switch_and_when_arguments(thd, true)); } @@ -4394,9 +4390,8 @@ bool Item_func_in::prepare_predicant_and_values(THD *thd, uint *found_types) } -bool Item_func_in::fix_length_and_dec() +bool Item_func_in::fix_length_and_dec(THD *thd) { - THD *thd= current_thd; uint found_types; m_comparator.set_handler(type_handler_varchar.type_handler_for_comparison()); max_length= 1; @@ -4752,7 +4747,7 @@ public: }; -bool Item_func_bit_or::fix_length_and_dec() +bool Item_func_bit_or::fix_length_and_dec(THD *thd) { static Func_handler_bit_or_int_to_ulonglong ha_int_to_ull; static Func_handler_bit_or_dec_to_ulonglong ha_dec_to_ull; @@ -4787,7 +4782,7 @@ public: }; -bool Item_func_bit_and::fix_length_and_dec() +bool Item_func_bit_and::fix_length_and_dec(THD *thd) { static Func_handler_bit_and_int_to_ulonglong ha_int_to_ull; static Func_handler_bit_and_dec_to_ulonglong ha_dec_to_ull; @@ -4938,7 +4933,7 @@ Item_cond::fix_fields(THD *thd, Item **ref) base_flags|= item->base_flags & item_base_t::MAYBE_NULL; with_flags|= item->with_flags; } - if (fix_length_and_dec()) + if (fix_length_and_dec(thd)) return TRUE; base_flags|= item_base_t::FIXED; return FALSE; @@ -6098,9 +6093,9 @@ void Regexp_processor_pcre::fix_owner(Item_func *owner, bool -Item_func_regex::fix_length_and_dec() +Item_func_regex::fix_length_and_dec(THD *thd) { - if (Item_bool_func::fix_length_and_dec() || + if (Item_bool_func::fix_length_and_dec(thd) || agg_arg_charsets_for_comparison(cmp_collation, args, 2)) return TRUE; @@ -6124,7 +6119,7 @@ longlong Item_func_regex::val_int() bool -Item_func_regexp_instr::fix_length_and_dec() +Item_func_regexp_instr::fix_length_and_dec(THD *thd) { if (agg_arg_charsets_for_comparison(cmp_collation, args, 2)) return TRUE; @@ -7067,7 +7062,7 @@ bool Item_equal::fix_fields(THD *thd, Item **ref) } if (prev_equal_field && last_equal_field != first_equal_field) last_equal_field->next_equal_field= first_equal_field; - if (fix_length_and_dec()) + if (fix_length_and_dec(thd)) return TRUE; base_flags|= item_base_t::FIXED; return FALSE; @@ -7196,11 +7191,11 @@ longlong Item_equal::val_int() } -bool Item_equal::fix_length_and_dec() +bool Item_equal::fix_length_and_dec(THD *thd) { Item *item= get_first(NO_PARTICULAR_TAB, NULL); const Type_handler *handler= item->type_handler(); - eval_item= handler->make_cmp_item(current_thd, item->collation.collation); + eval_item= handler->make_cmp_item(thd, item->collation.collation); return eval_item == NULL; } diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index fe55f524f89..59caca827c7 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -227,7 +227,7 @@ public: const Type_handler *fixed_type_handler() const override { return &type_handler_bool; } CHARSET_INFO *compare_collation() const override { return NULL; } - bool fix_length_and_dec() override { decimals=0; max_length=1; return FALSE; } + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=1; return FALSE; } decimal_digits_t decimal_precision() const override { return 1; } bool need_parentheses_in_default() override { return true; } }; @@ -243,7 +243,7 @@ class Item_func_truth : public Item_bool_func public: bool val_bool() override; longlong val_int() override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; void print(String *str, enum_query_type query_type) override; enum precedence precedence() const override { return CMP_PRECEDENCE; } @@ -562,7 +562,7 @@ public: cond); return this; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; int set_cmp_func(THD *thd) { return cmp.set_cmp_func(thd, this, tmp_arg, tmp_arg + 1, true); @@ -796,7 +796,7 @@ public: Item_func_equal(THD *thd, Item *a, Item *b): Item_bool_rowready_func2(thd, a, b) {} longlong val_int() override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; table_map not_null_tables() const override { return 0; } bool find_not_null_fields(table_map allowed) override { return false; } enum Functype functype() const override { return EQUAL_FUNC; } @@ -991,7 +991,7 @@ public: return name; } enum precedence precedence() const override { return BETWEEN_PRECEDENCE; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool fix_length_and_dec_string(THD *) { return agg_arg_charsets_for_comparison(cmp_collation, args, 3); @@ -1047,7 +1047,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("strcmp") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { if (agg_arg_charsets_for_comparison(cmp_collation, args, 2)) return TRUE; @@ -1081,7 +1081,7 @@ public: { } bool fix_fields(THD *, Item **) override; longlong val_int() override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("interval") }; @@ -1112,7 +1112,7 @@ public: bool date_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override; bool time_op(THD *thd, MYSQL_TIME *ltime) override; bool native_op(THD *thd, Native *to) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { if (aggregate_for_result(func_name_cstring(), args, arg_count, true)) return TRUE; @@ -1196,7 +1196,7 @@ public: bool date_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override; bool time_op(THD *thd, MYSQL_TIME *ltime) override; bool native_op(THD *thd, Native *to) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { /* Set nullability from args[1] by default. @@ -1287,7 +1287,7 @@ public: Item_func_case_abbreviation2_switch(thd, a, b, c) {} bool fix_fields(THD *, Item **) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { return fix_length_and_dec2_eliminate_null(args + 1); } @@ -1321,7 +1321,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("nvl2") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { return fix_length_and_dec2_eliminate_null(args + 1); } @@ -1384,7 +1384,7 @@ public: String *str_op(String *str) override; my_decimal *decimal_op(my_decimal *) override; bool native_op(THD *thd, Native *to) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool walk(Item_processor processor, bool walk_subquery, void *arg) override; LEX_CSTRING func_name_cstring() const override { @@ -2344,7 +2344,7 @@ public: } enum Functype functype() const override { return CASE_SEARCHED_FUNC; } void print(String *str, enum_query_type query_type) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond) override { @@ -2399,7 +2399,7 @@ public: } enum Functype functype() const override { return CASE_SIMPLE_FUNC; } void print(String *str, enum_query_type query_type) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond) override; Item *find_item() override; @@ -2429,7 +2429,7 @@ public: return name; } void print(String *str, enum_query_type query_type) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *find_item() override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_decode_oracle>(thd, this); } @@ -2519,7 +2519,7 @@ public: { } longlong val_int() override; bool fix_fields(THD *, Item **) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool compatible_types_scalar_bisection_possible() { DBUG_ASSERT(m_comparator.cmp_type() != ROW_RESULT); @@ -2695,7 +2695,7 @@ public: } CHARSET_INFO *compare_collation() const override { return args[0]->collation.collation; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=1; @@ -2944,7 +2944,7 @@ public: } enum precedence precedence() const override { return IN_PRECEDENCE; } bool fix_fields(THD *thd, Item **ref) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= 1; return agg_arg_charsets_for_comparison(cmp_collation, args, 2); @@ -3056,7 +3056,7 @@ public: DBUG_VOID_RETURN; } longlong val_int() override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("regexp") }; @@ -3101,7 +3101,7 @@ public: DBUG_VOID_RETURN; } longlong val_int() override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("regexp_instr") }; @@ -3347,7 +3347,7 @@ public: return name; } void sort(Item_field_cmpfunc compare, void *arg); - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool fix_fields(THD *thd, Item **ref) override; void cleanup() override { diff --git a/sql/item_func.cc b/sql/item_func.cc index cbf25ddf791..7609157bf96 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -356,7 +356,7 @@ Item_func::fix_fields(THD *thd, Item **ref) } if (check_arguments()) return true; - if (fix_length_and_dec()) + if (fix_length_and_dec(thd)) return TRUE; base_flags|= item_base_t::FIXED; return FALSE; @@ -757,9 +757,9 @@ String *Item_int_func::val_str(String *str) } -bool Item_func_connection_id::fix_length_and_dec() +bool Item_func_connection_id::fix_length_and_dec(THD *thd) { - if (Item_long_func::fix_length_and_dec()) + if (Item_long_func::fix_length_and_dec(thd)) return TRUE; max_length= 10; return FALSE; @@ -789,7 +789,7 @@ bool Item_num_op::fix_type_handler(const Type_aggregator *aggregator) } -bool Item_func_plus::fix_length_and_dec(void) +bool Item_func_plus::fix_length_and_dec(THD *thd) { DBUG_ENTER("Item_func_plus::fix_length_and_dec"); DBUG_PRINT("info", ("name %s", func_name())); @@ -1229,7 +1229,7 @@ void Item_func_minus::fix_unsigned_flag() } -bool Item_func_minus::fix_length_and_dec() +bool Item_func_minus::fix_length_and_dec(THD *thd) { DBUG_ENTER("Item_func_minus::fix_length_and_dec"); DBUG_PRINT("info", ("name %s", func_name())); @@ -1472,7 +1472,7 @@ void Item_func_mul::result_precision() } -bool Item_func_mul::fix_length_and_dec(void) +bool Item_func_mul::fix_length_and_dec(THD *thd) { DBUG_ENTER("Item_func_mul::fix_length_and_dec"); DBUG_PRINT("info", ("name %s", func_name())); @@ -1573,11 +1573,11 @@ void Item_func_div::fix_length_and_dec_int(void) } -bool Item_func_div::fix_length_and_dec() +bool Item_func_div::fix_length_and_dec(THD *thd) { DBUG_ENTER("Item_func_div::fix_length_and_dec"); DBUG_PRINT("info", ("name %s", func_name())); - prec_increment= current_thd->variables.div_precincrement; + prec_increment= thd->variables.div_precincrement; set_maybe_null(); // division by zero const Type_aggregator *aggregator= &type_handler_data->m_type_aggregator_for_div; @@ -1651,7 +1651,7 @@ longlong Item_func_int_div::val_int() } -bool Item_func_int_div::fix_length_and_dec() +bool Item_func_int_div::fix_length_and_dec(THD *thd) { uint32 prec= args[0]->decimal_int_part(); set_if_smaller(prec, MY_INT64_NUM_DECIMAL_DIGITS); @@ -1732,7 +1732,7 @@ void Item_func_mod::result_precision() } -bool Item_func_mod::fix_length_and_dec() +bool Item_func_mod::fix_length_and_dec(THD *thd) { DBUG_ENTER("Item_func_mod::fix_length_and_dec"); DBUG_PRINT("info", ("name %s", func_name())); @@ -1780,7 +1780,7 @@ longlong Item_func_hash::val_int() } -bool Item_func_hash::fix_length_and_dec() +bool Item_func_hash::fix_length_and_dec(THD *thd) { decimals= 0; max_length= 8; @@ -1883,7 +1883,7 @@ void Item_func_neg::fix_length_and_dec_decimal() } -bool Item_func_neg::fix_length_and_dec() +bool Item_func_neg::fix_length_and_dec(THD *thd) { DBUG_ENTER("Item_func_neg::fix_length_and_dec"); DBUG_PRINT("info", ("name %s", func_name())); @@ -1956,7 +1956,7 @@ void Item_func_abs::fix_length_and_dec_decimal() } -bool Item_func_abs::fix_length_and_dec() +bool Item_func_abs::fix_length_and_dec(THD *thd) { DBUG_ENTER("Item_func_abs::fix_length_and_dec"); DBUG_PRINT("info", ("name %s", func_name())); @@ -2179,7 +2179,7 @@ public: }; -bool Item_func_shift_left::fix_length_and_dec() +bool Item_func_shift_left::fix_length_and_dec(THD *thd) { static Func_handler_shift_left_int_to_ulonglong ha_int_to_ull; static Func_handler_shift_left_decimal_to_ulonglong ha_dec_to_ull; @@ -2213,7 +2213,7 @@ public: }; -bool Item_func_shift_right::fix_length_and_dec() +bool Item_func_shift_right::fix_length_and_dec(THD *thd) { static Func_handler_shift_right_int_to_ulonglong ha_int_to_ull; static Func_handler_shift_right_decimal_to_ulonglong ha_dec_to_ull; @@ -2245,7 +2245,7 @@ public: }; -bool Item_func_bit_neg::fix_length_and_dec() +bool Item_func_bit_neg::fix_length_and_dec(THD *thd) { static Func_handler_bit_neg_int_to_ulonglong ha_int_to_ull; static Func_handler_bit_neg_decimal_to_ulonglong ha_dec_to_ull; @@ -2317,7 +2317,7 @@ void Item_func_int_val::fix_length_and_dec_double() } -bool Item_func_int_val::fix_length_and_dec() +bool Item_func_int_val::fix_length_and_dec(THD *thd) { DBUG_ENTER("Item_func_int_val::fix_length_and_dec"); DBUG_PRINT("info", ("name %s", func_name())); @@ -3225,7 +3225,7 @@ longlong Item_func_field::val_int() } -bool Item_func_field::fix_length_and_dec() +bool Item_func_field::fix_length_and_dec(THD *thd) { base_flags&= ~item_base_t::MAYBE_NULL; max_length=3; @@ -3281,7 +3281,7 @@ longlong Item_func_ord::val_int() /* Returns number of found type >= 1 or 0 if not found */ /* This optimizes searching in enums to bit testing! */ -bool Item_func_find_in_set::fix_length_and_dec() +bool Item_func_find_in_set::fix_length_and_dec(THD *thd) { decimals=0; max_length=3; // 1-999 @@ -3410,7 +3410,7 @@ public: }; -bool Item_func_bit_count::fix_length_and_dec() +bool Item_func_bit_count::fix_length_and_dec(THD *thd) { static Func_handler_bit_count_int_to_slong ha_int_to_slong; static Func_handler_bit_count_decimal_to_slong ha_dec_to_slong; @@ -3524,7 +3524,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func, NullS)) goto err_exit; } - if (func->fix_length_and_dec()) + if (func->fix_length_and_dec(thd)) DBUG_RETURN(TRUE); initid.max_length=func->max_length; initid.maybe_null=func->maybe_null(); @@ -3823,7 +3823,7 @@ my_decimal *Item_func_udf_decimal::val_decimal(my_decimal *dec_buf) /* Default max_length is max argument length */ -bool Item_func_udf_str::fix_length_and_dec() +bool Item_func_udf_str::fix_length_and_dec(THD *thd) { DBUG_ENTER("Item_func_udf_str::fix_length_and_dec"); max_length=0; @@ -4773,7 +4773,7 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref) bool -Item_func_set_user_var::fix_length_and_dec() +Item_func_set_user_var::fix_length_and_dec(THD *thd) { base_flags|= (args[0]->base_flags & item_base_t::MAYBE_NULL); decimals=args[0]->decimals; @@ -5628,9 +5628,8 @@ err: return 1; } -bool Item_func_get_user_var::fix_length_and_dec() +bool Item_func_get_user_var::fix_length_and_dec(THD *thd) { - THD *thd=current_thd; int error; set_maybe_null(); decimals=NOT_FIXED_DEC; @@ -5839,7 +5838,7 @@ void Item_func_get_system_var::update_null_value() } -bool Item_func_get_system_var::fix_length_and_dec() +bool Item_func_get_system_var::fix_length_and_dec(THD *thd) { const char *cptr; set_maybe_null(); @@ -5876,9 +5875,9 @@ bool Item_func_get_system_var::fix_length_and_dec() case SHOW_CHAR_PTR: mysql_mutex_lock(&LOCK_global_system_variables); cptr= var->show_type() == SHOW_CHAR ? - reinterpret_cast<const char*>(var->value_ptr(current_thd, var_type, + reinterpret_cast<const char*>(var->value_ptr(thd, var_type, &component)) : - *reinterpret_cast<const char* const*>(var->value_ptr(current_thd, + *reinterpret_cast<const char* const*>(var->value_ptr(thd, var_type, &component)); if (cptr) @@ -6465,7 +6464,7 @@ public: }; -bool Item_func_bit_xor::fix_length_and_dec() +bool Item_func_bit_xor::fix_length_and_dec(THD *thd) { static const Func_handler_bit_xor_int_to_ulonglong ha_int_to_ull; static const Func_handler_bit_xor_dec_to_ulonglong ha_dec_to_ull; @@ -6604,7 +6603,7 @@ bool Item_func_sp::is_expensive() @note called from Item::fix_fields. */ -bool Item_func_sp::fix_length_and_dec() +bool Item_func_sp::fix_length_and_dec(THD *thd) { DBUG_ENTER("Item_func_sp::fix_length_and_dec"); @@ -6940,7 +6939,7 @@ bool Item_func_last_value::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuz } -bool Item_func_last_value::fix_length_and_dec() +bool Item_func_last_value::fix_length_and_dec(THD *thd) { last_value= args[arg_count -1]; Type_std_attributes::set(last_value); diff --git a/sql/item_func.h b/sql/item_func.h index 23879f0a733..185242b7901 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -413,7 +413,7 @@ public: { return get_date_from_real(thd, ltime, fuzzydate); } const Type_handler *type_handler() const override { return &type_handler_double; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals= NOT_FIXED_DEC; max_length= float_length(decimals); @@ -1168,7 +1168,7 @@ public: bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override { return get_date_from_int(thd, ltime, fuzzydate); } const Type_handler *type_handler() const override= 0; - bool fix_length_and_dec() override { return FALSE; } + bool fix_length_and_dec(THD *thd) override { return FALSE; } }; @@ -1187,7 +1187,7 @@ public: return &type_handler_ulong; return &type_handler_slong; } - bool fix_length_and_dec() override { max_length= 11; return FALSE; } + bool fix_length_and_dec(THD *thd) override { max_length= 11; return FALSE; } }; @@ -1197,7 +1197,7 @@ public: Item_func_hash(THD *thd, List<Item> &item): Item_int_func(thd, item) {} longlong val_int() override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; const Type_handler *type_handler() const override { return &type_handler_slong; } Item *get_copy(THD *thd) override @@ -1283,7 +1283,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("connection_id") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool fix_fields(THD *thd, Item **ref) override; longlong val_int() override { DBUG_ASSERT(fixed()); return value; } bool check_vcol_func_processor(void *arg) override @@ -1348,7 +1348,7 @@ public: set_if_bigger(char_length, 1U + (unsigned_flag ? 0 : 1)); fix_char_length(char_length); } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { return args[0]->type_handler()->Item_func_signed_fix_length_and_dec(this); } @@ -1385,7 +1385,7 @@ public: null_value= args[0]->null_value; return value; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { return args[0]->type_handler()->Item_func_unsigned_fix_length_and_dec(this); } @@ -1420,7 +1420,7 @@ public: const Type_handler *type_handler() const override { return &type_handler_newdecimal; } void fix_length_and_dec_generic() {} - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { return args[0]->type_handler()->Item_decimal_typecast_fix_length_and_dec(this); @@ -1465,7 +1465,7 @@ public: { } const Type_handler *type_handler() const override { return &type_handler_float; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { return args[0]->type_handler()->Item_float_typecast_fix_length_and_dec(this); @@ -1498,7 +1498,7 @@ public: Item_double_typecast(THD *thd, Item *a, uint len, uint dec): Item_real_typecast(thd, a, len, dec) { } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { return args[0]->type_handler()->Item_double_typecast_fix_length_and_dec(this); @@ -1535,7 +1535,7 @@ public: return name; } enum precedence precedence() const override { return ADD_PRECEDENCE; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; longlong int_op() override; double real_op() override; my_decimal *decimal_op(my_decimal *) override; @@ -1561,7 +1561,7 @@ public: longlong int_op() override; double real_op() override; my_decimal *decimal_op(my_decimal *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; void fix_unsigned_flag(); void fix_length_and_dec_double() { @@ -1598,7 +1598,7 @@ public: double real_op() override; my_decimal *decimal_op(my_decimal *) override; void result_precision() override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool check_partition_func_processor(void *int_arg) override {return FALSE;} bool check_vcol_func_processor(void *arg) override { return FALSE;} Item *get_copy(THD *thd) override @@ -1620,7 +1620,7 @@ public: return name; } enum precedence precedence() const override { return MUL_PRECEDENCE; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; void fix_length_and_dec_double(); void fix_length_and_dec_int(); void result_precision() override; @@ -1643,7 +1643,7 @@ public: enum precedence precedence() const override { return MUL_PRECEDENCE; } const Type_handler *type_handler() const override { return type_handler_long_or_longlong(); } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; void print(String *str, enum_query_type query_type) override { print_op(str, query_type); @@ -1671,7 +1671,7 @@ public: } enum precedence precedence() const override { return MUL_PRECEDENCE; } void result_precision() override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; void fix_length_and_dec_double() { Item_num_op::fix_length_and_dec_double(); @@ -1717,7 +1717,7 @@ public: void fix_length_and_dec_int(); void fix_length_and_dec_double(); void fix_length_and_dec_decimal(); - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; decimal_digits_t decimal_precision() const override { return args[0]->decimal_precision(); } bool need_parentheses_in_default() override { return true; } @@ -1741,7 +1741,7 @@ public: void fix_length_and_dec_int(); void fix_length_and_dec_double(); void fix_length_and_dec_decimal(); - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_abs>(thd, this); } }; @@ -1755,7 +1755,7 @@ class Item_dec_func :public Item_real_func public: Item_dec_func(THD *thd, Item *a): Item_real_func(thd, a) {} Item_dec_func(THD *thd, Item *a, Item *b): Item_real_func(thd, a, b) {} - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals= NOT_FIXED_DEC; max_length= float_length(decimals); @@ -1991,7 +1991,7 @@ public: // Thinks like CEILING(TIMESTAMP'0000-01-01 23:59:59.9') returns NULL set_maybe_null(); } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; String *str_op(String *str) override { DBUG_ASSERT(0); return 0; } bool native_op(THD *thd, Native *to) override { @@ -2081,7 +2081,7 @@ public: void fix_arg_time(); void fix_arg_datetime(); void fix_arg_temporal(const Type_handler *h, uint int_part_length); - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { /* We don't want to translate ENUM/SET to CHAR here. @@ -2145,7 +2145,7 @@ public: void update_used_tables() override {} bool const_item() const override { return 0; } void fix_after_optimize(THD *thd) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { unsigned_flag= 1; used_tables_cache= RAND_TABLE_BIT; @@ -2192,7 +2192,7 @@ public: return name; } decimal_digits_t decimal_precision() const override { return 1; } - bool fix_length_and_dec() override { fix_char_length(2); return FALSE; } + bool fix_length_and_dec(THD *thd) override { fix_char_length(2); return FALSE; } longlong val_int() override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_sign>(thd, this); } @@ -2215,7 +2215,7 @@ public: } double val_real() override; LEX_CSTRING func_name_cstring() const override { return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals= NOT_FIXED_DEC; max_length= float_length(decimals); @@ -2309,7 +2309,7 @@ public: Item_func::aggregate_attributes_real(items, nitems); max_length= float_length(decimals); } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { if (aggregate_for_min_max(func_name_cstring(), args, arg_count)) return true; @@ -2375,7 +2375,7 @@ public: bool const_item() const override { return 0; } const Type_handler *type_handler() const override { return args[0]->type_handler(); } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { Type_std_attributes::set(*args[0]); return FALSE; @@ -2391,7 +2391,7 @@ class Item_long_func_length: public Item_long_func { return args[0]->check_type_can_return_str(func_name_cstring()); } public: Item_long_func_length(THD *thd, Item *a): Item_long_func(thd, a) {} - bool fix_length_and_dec() override { max_length=10; return FALSE; } + bool fix_length_and_dec(THD *thd) override { max_length=10; return FALSE; } }; @@ -2415,7 +2415,7 @@ class Item_func_bit_length :public Item_longlong_func String value; public: Item_func_bit_length(THD *thd, Item *a): Item_longlong_func(thd, a) {} - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= 11; // 0x100000000*8 = 34,359,738,368 return FALSE; @@ -2457,7 +2457,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("coercibility") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length=10; base_flags&= ~item_base_t::MAYBE_NULL; @@ -2507,7 +2507,7 @@ public: return name; } longlong val_int() override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= MY_INT32_NUM_DECIMAL_DIGITS; return agg_arg_charsets_for_comparison(cmp_collation, args, 2); @@ -2531,7 +2531,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("field") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_field>(thd, this); } }; @@ -2550,7 +2550,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("ascii") }; return name; } - bool fix_length_and_dec() override { max_length=3; return FALSE; } + bool fix_length_and_dec(THD *thd) override { max_length=3; return FALSE; } Item *get_copy(THD *thd) override { return get_item_copy<Item_func_ascii>(thd, this); } }; @@ -2562,7 +2562,7 @@ class Item_func_ord :public Item_long_func String value; public: Item_func_ord(THD *thd, Item *a): Item_long_func(thd, a) {} - bool fix_length_and_dec() override { fix_char_length(7); return FALSE; } + bool fix_length_and_dec(THD *thd) override { fix_char_length(7); return FALSE; } longlong val_int() override; LEX_CSTRING func_name_cstring() const override { @@ -2590,7 +2590,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("find_in_set") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_find_in_set>(thd, this); } }; @@ -2630,7 +2630,7 @@ class Item_func_bit_or :public Item_func_bit_operator public: Item_func_bit_or(THD *thd, Item *a, Item *b) :Item_func_bit_operator(thd, a, b) {} - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("|") }; @@ -2646,7 +2646,7 @@ class Item_func_bit_and :public Item_func_bit_operator public: Item_func_bit_and(THD *thd, Item *a, Item *b) :Item_func_bit_operator(thd, a, b) {} - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("&") }; @@ -2668,7 +2668,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("bit_count") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_bit_count>(thd, this); } }; @@ -2678,7 +2678,7 @@ class Item_func_shift_left :public Item_func_bit_operator public: Item_func_shift_left(THD *thd, Item *a, Item *b) :Item_func_bit_operator(thd, a, b) {} - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("<<") }; @@ -2694,7 +2694,7 @@ class Item_func_shift_right :public Item_func_bit_operator public: Item_func_shift_right(THD *thd, Item *a, Item *b) :Item_func_bit_operator(thd, a, b) {} - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN(">>") }; @@ -2709,7 +2709,7 @@ class Item_func_bit_neg :public Item_func_bit_operator { public: Item_func_bit_neg(THD *thd, Item *a): Item_func_bit_operator(thd, a) {} - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("~") }; @@ -2739,7 +2739,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("last_insert_id") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { unsigned_flag= true; if (arg_count) @@ -2773,7 +2773,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("benchmark") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length=1; base_flags&= ~item_base_t::MAYBE_NULL; @@ -2798,7 +2798,7 @@ class Item_func_sleep :public Item_long_func { return args[0]->check_type_can_return_real(func_name_cstring()); } public: Item_func_sleep(THD *thd, Item *a): Item_long_func(thd, a) {} - bool fix_length_and_dec() override { fix_char_length(1); return FALSE; } + bool fix_length_and_dec(THD *thd) override { fix_char_length(1); return FALSE; } bool const_item() const override { return 0; } LEX_CSTRING func_name_cstring() const override { @@ -2971,7 +2971,7 @@ class Item_func_udf_float :public Item_udf_func String *val_str(String *str) override; const Type_handler *type_handler() const override { return &type_handler_double; } - bool fix_length_and_dec() override { fix_num_length_and_dec(); return FALSE; } + bool fix_length_and_dec(THD *thd) override { fix_num_length_and_dec(); return FALSE; } Item *get_copy(THD *thd) override { return get_item_copy<Item_func_udf_float>(thd, this); } }; @@ -2998,7 +2998,7 @@ public: return &type_handler_ulonglong; return &type_handler_slonglong; } - bool fix_length_and_dec() override { decimals= 0; max_length= 21; return FALSE; } + bool fix_length_and_dec(THD *thd) override { decimals= 0; max_length= 21; return FALSE; } Item *get_copy(THD *thd) override { return get_item_copy<Item_func_udf_int>(thd, this); } }; @@ -3026,7 +3026,7 @@ public: } const Type_handler *type_handler() const override { return &type_handler_newdecimal; } - bool fix_length_and_dec() override { fix_num_length_and_dec(); return FALSE; } + bool fix_length_and_dec(THD *thd) override { fix_num_length_and_dec(); return FALSE; } Item *get_copy(THD *thd) override { return get_item_copy<Item_func_udf_decimal>(thd, this); } }; @@ -3066,7 +3066,7 @@ public: } const Type_handler *type_handler() const override { return string_type_handler(); } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_udf_str>(thd, this); } }; @@ -3121,7 +3121,7 @@ public: { DBUG_ASSERT(fixed()); null_value=1; return 0; } double val_real() { DBUG_ASSERT(fixed()); null_value= 1; return 0.0; } longlong val_int() { DBUG_ASSERT(fixed()); null_value=1; return 0; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { base_flags|= item_base_t::MAYBE_NULL; max_length=0; return FALSE; } }; @@ -3166,7 +3166,7 @@ class Item_func_get_lock final :public Item_func_lock static LEX_CSTRING name= {STRING_WITH_LEN("get_lock") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= 1; set_maybe_null(); @@ -3206,7 +3206,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("release_lock") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= 1; set_maybe_null(); @@ -3243,7 +3243,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("master_pos_wait") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length=21; set_maybe_null(); @@ -3277,7 +3277,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("master_gtid_wait") }; return name; } - bool fix_length_and_dec() override { max_length=2; return FALSE; } + bool fix_length_and_dec(THD *thd) override { max_length=2; return FALSE; } bool check_vcol_func_processor(void *arg) override { return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE); @@ -3380,7 +3380,7 @@ public: void save_item_result(Item *item); bool update(); bool fix_fields(THD *thd, Item **ref) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; void print(String *str, enum_query_type query_type) override; enum precedence precedence() const override { return ASSIGN_PRECEDENCE; } void print_as_stmt(String *str, enum_query_type query_type); @@ -3421,7 +3421,7 @@ public: longlong val_int() override; my_decimal *val_decimal(my_decimal*) override; String *val_str(String* str) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; void print(String *str, enum_query_type query_type) override; /* We must always return variables as strings to guard against selects of type @@ -3549,7 +3549,7 @@ public: size_t name_len_arg); enum Functype functype() const override { return GSYSVAR_FUNC; } void update_null_value() override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; void print(String *str, enum_query_type query_type) override; bool const_item() const override { return true; } table_map used_tables() const override { return 0; } @@ -3690,7 +3690,7 @@ class Item_func_bit_xor : public Item_func_bit_operator public: Item_func_bit_xor(THD *thd, Item *a, Item *b) :Item_func_bit_operator(thd, a, b) {} - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("^") }; @@ -3714,7 +3714,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("is_free_lock") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=1; @@ -3742,7 +3742,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("is_used_lock") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=10; set_maybe_null(); @@ -3809,7 +3809,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("row_count") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals= 0; base_flags&= ~item_base_t::MAYBE_NULL; @@ -3941,7 +3941,7 @@ public: enum Functype functype() const override { return FUNC_SP; } bool fix_fields(THD *thd, Item **ref) override; - bool fix_length_and_dec(void) override; + bool fix_length_and_dec(THD *thd) override; bool is_expensive() override; inline Field *get_sp_result_field() @@ -3983,7 +3983,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("found_rows") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals= 0; base_flags&= ~item_base_t::MAYBE_NULL; @@ -4039,7 +4039,7 @@ public: { return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE); } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { base_flags&= ~item_base_t::MAYBE_NULL; null_value= false; @@ -4065,7 +4065,7 @@ public: } longlong val_int() override; bool const_item() const override { return false; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= 21; unsigned_flag=1; return FALSE; } table_map used_tables() const override { return RAND_TABLE_BIT; } bool check_vcol_func_processor(void *arg) override @@ -4090,7 +4090,7 @@ public: my_decimal *val_decimal(my_decimal *) override; bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override; bool val_native(THD *thd, Native *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("last_value") }; @@ -4135,7 +4135,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("nextval") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { unsigned_flag= 0; max_length= MAX_BIGINT_WIDTH; diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 0fdcf9e94e2..ad26eda990f 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -42,7 +42,7 @@ #include "item_create.h" -bool Item_geometry_func::fix_length_and_dec() +bool Item_geometry_func::fix_length_and_dec(THD *thd) { collation.set(&my_charset_bin); decimals=0; @@ -214,7 +214,7 @@ String *Item_func_as_wkt::val_str_ascii(String *str) } -bool Item_func_as_wkt::fix_length_and_dec() +bool Item_func_as_wkt::fix_length_and_dec(THD *thd) { collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); max_length= (uint32) UINT_MAX32; @@ -241,7 +241,7 @@ String *Item_func_as_wkb::val_str(String *str) } -bool Item_func_as_geojson::fix_length_and_dec() +bool Item_func_as_geojson::fix_length_and_dec(THD *thd) { collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); max_length=MAX_BLOB_WIDTH; diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index e7f465170ab..40f4b924d09 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -42,7 +42,7 @@ public: Item_geometry_func(THD *thd, Item *a, Item *b, Item *c): Item_str_func(thd, a, b, c) {} Item_geometry_func(THD *thd, List<Item> &list): Item_str_func(thd, list) {} - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; const Type_handler *type_handler() const override { return &type_handler_geometry; } }; @@ -283,7 +283,7 @@ public: return name; } String *val_str_ascii(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_as_wkt>(thd, this); } }; @@ -301,7 +301,7 @@ public: String *val_str(String *) override; const Type_handler *type_handler() const override { return &type_handler_long_blob; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { collation.set(&my_charset_bin); decimals=0; @@ -334,7 +334,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("st_asgeojson") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; String *val_str_ascii(String *) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_as_geojson>(thd, this); } @@ -352,7 +352,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("st_geometrytype") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { // "GeometryCollection" is the longest fix_length_and_charset(20, default_charset()); @@ -586,9 +586,9 @@ public: item_type=it; } String *val_str(String *) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - if (Item_geometry_func::fix_length_and_dec()) + if (Item_geometry_func::fix_length_and_dec(thd)) return TRUE; for (unsigned int i= 0; i < arg_count; ++i) { @@ -951,7 +951,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("st_isempty") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { set_maybe_null(); return FALSE; } bool need_parentheses_in_default() override { return false; } Item *get_copy(THD *thd) override @@ -973,7 +973,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("st_issimple") }; return name; } - bool fix_length_and_dec() override { decimals=0; max_length=2; return FALSE; } + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=2; return FALSE; } decimal_digits_t decimal_precision() const override { return 1; } Item *get_copy(THD *thd) override { return get_item_copy<Item_func_issimple>(thd, this); } @@ -990,7 +990,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("st_isclosed") }; return name; } - bool fix_length_and_dec() override { decimals=0; max_length=2; return FALSE; } + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=2; return FALSE; } decimal_digits_t decimal_precision() const override { return 1; } Item *get_copy(THD *thd) override { return get_item_copy<Item_func_isclosed>(thd, this); } @@ -1021,7 +1021,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("st_dimension") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= 10; set_maybe_null(); return FALSE; } Item *get_copy(THD *thd) override { return get_item_copy<Item_func_dimension>(thd, this); } @@ -1038,9 +1038,9 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("st_x") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - if (Item_real_func::fix_length_and_dec()) + if (Item_real_func::fix_length_and_dec(thd)) return TRUE; set_maybe_null(); return FALSE; @@ -1060,9 +1060,9 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("st_y") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - if (Item_real_func::fix_length_and_dec()) + if (Item_real_func::fix_length_and_dec(thd)) return TRUE; set_maybe_null(); return FALSE; @@ -1083,7 +1083,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("st_numgeometries") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= 10; set_maybe_null(); return FALSE; } Item *get_copy(THD *thd) override { return get_item_copy<Item_func_numgeometries>(thd, this); } @@ -1101,7 +1101,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("st_numinteriorrings") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= 10; set_maybe_null(); return FALSE; } Item *get_copy(THD *thd) override { return get_item_copy<Item_func_numinteriorring>(thd, this); } @@ -1119,7 +1119,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("st_numpoints") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= 10; set_maybe_null(); return FALSE; } Item *get_copy(THD *thd) override { return get_item_copy<Item_func_numpoints>(thd, this); } @@ -1136,9 +1136,9 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("st_area") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - if (Item_real_func::fix_length_and_dec()) + if (Item_real_func::fix_length_and_dec(thd)) return TRUE; set_maybe_null(); return FALSE; @@ -1160,9 +1160,9 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("st_length") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - if (Item_real_func::fix_length_and_dec()) + if (Item_real_func::fix_length_and_dec(thd)) return TRUE; set_maybe_null(); return FALSE; @@ -1183,7 +1183,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("srid") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= 10; set_maybe_null(); return FALSE; } Item *get_copy(THD *thd) override { return get_item_copy<Item_func_srid>(thd, this); } @@ -1259,7 +1259,7 @@ class Item_func_gis_debug: public Item_long_func public: Item_func_gis_debug(THD *thd, Item *a): Item_long_func(thd, a) { null_value= false; } - bool fix_length_and_dec() override { fix_char_length(10); return FALSE; } + bool fix_length_and_dec(THD *thd) override { fix_char_length(10); return FALSE; } LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("st_gis_debug") }; diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index bf151baf9c4..561bc529ce4 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -394,9 +394,9 @@ longlong Item_func_json_valid::val_int() } -bool Item_func_json_equals::fix_length_and_dec() +bool Item_func_json_equals::fix_length_and_dec(THD *thd) { - if (Item_bool_func::fix_length_and_dec()) + if (Item_bool_func::fix_length_and_dec(thd)) return TRUE; set_maybe_null(); return FALSE; @@ -454,9 +454,9 @@ end: } -bool Item_func_json_exists::fix_length_and_dec() +bool Item_func_json_exists::fix_length_and_dec(THD *thd) { - if (Item_bool_func::fix_length_and_dec()) + if (Item_bool_func::fix_length_and_dec(thd)) return TRUE; set_maybe_null(); path.set_constant_flag(args[1]->const_item()); @@ -507,7 +507,7 @@ err_return: } -bool Item_func_json_value::fix_length_and_dec() +bool Item_func_json_value::fix_length_and_dec(THD *thd) { collation.set(args[0]->collation); max_length= args[0]->max_length; @@ -517,7 +517,7 @@ bool Item_func_json_value::fix_length_and_dec() } -bool Item_func_json_query::fix_length_and_dec() +bool Item_func_json_query::fix_length_and_dec(THD *thd) { collation.set(args[0]->collation); max_length= args[0]->max_length; @@ -629,7 +629,7 @@ bool Json_engine_scan::check_and_get_value_complex(String *res, int *error) } -bool Item_func_json_quote::fix_length_and_dec() +bool Item_func_json_quote::fix_length_and_dec(THD *thd) { collation.set(&my_charset_utf8mb4_bin); /* @@ -665,7 +665,7 @@ String *Item_func_json_quote::val_str(String *str) } -bool Item_func_json_unquote::fix_length_and_dec() +bool Item_func_json_unquote::fix_length_and_dec(THD *thd) { collation.set(&my_charset_utf8mb3_general_ci, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); @@ -785,7 +785,7 @@ void Item_json_str_multipath::cleanup() } -bool Item_func_json_extract::fix_length_and_dec() +bool Item_func_json_extract::fix_length_and_dec(THD *thd) { collation.set(args[0]->collation); max_length= args[0]->max_length * (arg_count - 1); @@ -1055,14 +1055,14 @@ my_decimal *Item_func_json_extract::val_decimal(my_decimal *to) -bool Item_func_json_contains::fix_length_and_dec() +bool Item_func_json_contains::fix_length_and_dec(THD *thd) { a2_constant= args[1]->const_item(); a2_parsed= FALSE; set_maybe_null(); if (arg_count > 2) path.set_constant_flag(args[2]->const_item()); - return Item_bool_func::fix_length_and_dec(); + return Item_bool_func::fix_length_and_dec(thd); } @@ -1306,13 +1306,13 @@ bool Item_func_json_contains_path::fix_fields(THD *thd, Item **ref) } -bool Item_func_json_contains_path::fix_length_and_dec() +bool Item_func_json_contains_path::fix_length_and_dec(THD *thd) { ooa_constant= args[1]->const_item(); ooa_parsed= FALSE; set_maybe_null(); mark_constant_paths(paths, args+2, arg_count-2); - return Item_bool_func::fix_length_and_dec(); + return Item_bool_func::fix_length_and_dec(thd); } @@ -1643,7 +1643,7 @@ append_null: } -bool Item_func_json_array::fix_length_and_dec() +bool Item_func_json_array::fix_length_and_dec(THD *thd) { ulonglong char_length= 2; uint n_arg; @@ -1712,7 +1712,7 @@ err_return: } -bool Item_func_json_array_append::fix_length_and_dec() +bool Item_func_json_array_append::fix_length_and_dec(THD *thd) { uint n_arg; ulonglong char_length; @@ -2651,7 +2651,7 @@ null_return: } -bool Item_func_json_length::fix_length_and_dec() +bool Item_func_json_length::fix_length_and_dec(THD *thd) { if (arg_count > 1) path.set_constant_flag(args[1]->const_item()); @@ -2797,7 +2797,7 @@ longlong Item_func_json_depth::val_int() } -bool Item_func_json_type::fix_length_and_dec() +bool Item_func_json_type::fix_length_and_dec(THD *thd) { collation.set(&my_charset_utf8mb3_general_ci); max_length= 12; @@ -2855,7 +2855,7 @@ error: } -bool Item_func_json_insert::fix_length_and_dec() +bool Item_func_json_insert::fix_length_and_dec(THD *thd) { uint n_arg; ulonglong char_length; @@ -3119,7 +3119,7 @@ return_null: } -bool Item_func_json_remove::fix_length_and_dec() +bool Item_func_json_remove::fix_length_and_dec(THD *thd) { collation.set(args[0]->collation); max_length= args[0]->max_length; @@ -3308,7 +3308,7 @@ null_return: } -bool Item_func_json_keys::fix_length_and_dec() +bool Item_func_json_keys::fix_length_and_dec(THD *thd) { collation.set(args[0]->collation); max_length= args[0]->max_length; @@ -3476,7 +3476,7 @@ bool Item_func_json_search::fix_fields(THD *thd, Item **ref) static const uint SQR_MAX_BLOB_WIDTH= (uint) sqrt(MAX_BLOB_WIDTH); -bool Item_func_json_search::fix_length_and_dec() +bool Item_func_json_search::fix_length_and_dec(THD *thd) { collation.set(args[0]->collation); @@ -3676,7 +3676,7 @@ LEX_CSTRING Item_func_json_format::func_name_cstring() const } -bool Item_func_json_format::fix_length_and_dec() +bool Item_func_json_format::fix_length_and_dec(THD *thd) { decimals= 0; collation.set(args[0]->collation); @@ -4023,7 +4023,7 @@ end: } -bool Item_func_json_normalize::fix_length_and_dec() +bool Item_func_json_normalize::fix_length_and_dec(THD *thd) { collation.set(&my_charset_utf8mb4_bin); /* 0 becomes 0.0E0, thus one character becomes 5 chars */ @@ -4390,11 +4390,11 @@ error: return 0; } -bool Item_func_json_overlaps::fix_length_and_dec() +bool Item_func_json_overlaps::fix_length_and_dec(THD *thd) { a2_constant= args[1]->const_item(); a2_parsed= FALSE; set_maybe_null(); - return Item_bool_func::fix_length_and_dec(); + return Item_bool_func::fix_length_and_dec(thd); } diff --git a/sql/item_jsonfunc.h b/sql/item_jsonfunc.h index db2fd3da78f..82efddb5a5a 100644 --- a/sql/item_jsonfunc.h +++ b/sql/item_jsonfunc.h @@ -101,9 +101,9 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("json_valid") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - if (Item_bool_func::fix_length_and_dec()) + if (Item_bool_func::fix_length_and_dec(thd)) return TRUE; set_maybe_null(); return FALSE; @@ -130,7 +130,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("json_equals") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_json_equals>(thd, this); } longlong val_int() override; @@ -151,7 +151,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("json_exists") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_json_exists>(thd, this); } longlong val_int() override; @@ -188,7 +188,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("json_value") }; return name; } - bool fix_length_and_dec() override ; + bool fix_length_and_dec(THD *thd) override ; String *val_str(String *to) override { null_value= Json_path_extractor::extract(to, args[0], args[1], @@ -216,7 +216,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("json_query") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; String *val_str(String *to) override { null_value= Json_path_extractor::extract(to, args[0], args[1], @@ -245,7 +245,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("json_quote") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; String *val_str(String *) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_json_quote>(thd, this); } @@ -264,7 +264,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("json_unquote") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; String *val_str(String *) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_json_unquote>(thd, this); } @@ -300,7 +300,7 @@ public: return name; } enum Functype functype() const override { return JSON_EXTRACT_FUNC; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; String *val_str(String *) override; longlong val_int() override; double val_real() override; @@ -327,7 +327,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("json_contains") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; longlong val_int() override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_json_contains>(thd, this); } @@ -353,7 +353,7 @@ public: return name; } bool fix_fields(THD *thd, Item **ref) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; void cleanup() override; longlong val_int() override; Item *get_copy(THD *thd) override @@ -372,7 +372,7 @@ public: Item_func_json_array(THD *thd, List<Item> &list): Item_json_func(thd, list) {} String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("json_array") }; @@ -391,7 +391,7 @@ protected: public: Item_func_json_array_append(THD *thd, List<Item> &list): Item_json_str_multipath(thd, list) {} - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; String *val_str(String *) override; uint get_n_paths() const override { return arg_count/2; } LEX_CSTRING func_name_cstring() const override @@ -482,7 +482,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("json_normalize") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_json_normalize>(thd, this); } }; @@ -508,7 +508,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("json_length") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; longlong val_int() override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_json_length>(thd, this); } @@ -528,7 +528,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("json_depth") }; return name; } - bool fix_length_and_dec() override { max_length= 10; return FALSE; } + bool fix_length_and_dec(THD *thd) override { max_length= 10; return FALSE; } longlong val_int() override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_json_depth>(thd, this); } @@ -546,7 +546,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("json_type") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; String *val_str(String *) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_json_type>(thd, this); } @@ -563,7 +563,7 @@ public: Item_func_json_insert(bool i_mode, bool r_mode, THD *thd, List<Item> &list): Item_json_str_multipath(thd, list), mode_insert(i_mode), mode_replace(r_mode) {} - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; String *val_str(String *) override; uint get_n_paths() const override { return arg_count/2; } LEX_CSTRING func_name_cstring() const override @@ -586,7 +586,7 @@ protected: public: Item_func_json_remove(THD *thd, List<Item> &list): Item_json_str_multipath(thd, list) {} - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; String *val_str(String *) override; uint get_n_paths() const override { return arg_count - 1; } LEX_CSTRING func_name_cstring() const override @@ -613,7 +613,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("json_keys") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; String *val_str(String *) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_json_keys>(thd, this); } @@ -641,7 +641,7 @@ public: return name; } bool fix_fields(THD *thd, Item **ref) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; String *val_str(String *) override; uint get_n_paths() const override { return arg_count > 4 ? arg_count - 4 : 0; } Item *get_copy(THD *thd) override @@ -669,7 +669,7 @@ public: Item_json_func(thd, list), fmt(DETAILED) {} LEX_CSTRING func_name_cstring() const override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; String *val_str(String *str) override; String *val_json(String *str) override; Item *get_copy(THD *thd) override @@ -785,7 +785,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("json_overlaps") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; longlong val_int() override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_json_overlaps>(thd, this); } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index b8c01e5af41..0291ddcd5b3 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -210,7 +210,7 @@ String *Item_func_sha::val_str_ascii(String *str) return 0; } -bool Item_func_sha::fix_length_and_dec() +bool Item_func_sha::fix_length_and_dec(THD *thd) { // size of hex representation of hash fix_length_and_charset(MY_SHA1_HASH_SIZE * 2, default_charset()); @@ -290,7 +290,7 @@ String *Item_func_sha2::val_str_ascii(String *str) } -bool Item_func_sha2::fix_length_and_dec() +bool Item_func_sha2::fix_length_and_dec(THD *thd) { set_maybe_null(); max_length = 0; @@ -370,7 +370,7 @@ String *Item_aes_crypt::val_str(String *str2) return 0; } -bool Item_func_aes_encrypt::fix_length_and_dec() +bool Item_func_aes_encrypt::fix_length_and_dec(THD *thd) { max_length=my_aes_get_size(MY_AES_ECB, args[0]->max_length); what= ENCRYPTION_FLAG_ENCRYPT; @@ -379,7 +379,7 @@ bool Item_func_aes_encrypt::fix_length_and_dec() -bool Item_func_aes_decrypt::fix_length_and_dec() +bool Item_func_aes_decrypt::fix_length_and_dec(THD *thd) { max_length=args[0]->max_length; set_maybe_null(); @@ -388,7 +388,7 @@ bool Item_func_aes_decrypt::fix_length_and_dec() } -bool Item_func_to_base64::fix_length_and_dec() +bool Item_func_to_base64::fix_length_and_dec(THD *thd) { base_flags|= args[0]->base_flags & item_base_t::MAYBE_NULL; collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); @@ -439,7 +439,7 @@ String *Item_func_to_base64::val_str_ascii(String *str) } -bool Item_func_from_base64::fix_length_and_dec() +bool Item_func_from_base64::fix_length_and_dec(THD *thd) { if (args[0]->max_length > (uint) my_base64_decode_max_arg_length()) { @@ -709,7 +709,7 @@ bool Item_func_concat::append_value(THD *thd, String *res, const String *app) } -bool Item_func_concat::fix_length_and_dec() +bool Item_func_concat::fix_length_and_dec(THD *thd) { ulonglong char_length= 0; @@ -1071,7 +1071,7 @@ null: } -bool Item_func_concat_ws::fix_length_and_dec() +bool Item_func_concat_ws::fix_length_and_dec(THD *thd) { ulonglong char_length; @@ -1141,7 +1141,7 @@ String *Item_func_reverse::val_str(String *str) } -bool Item_func_reverse::fix_length_and_dec() +bool Item_func_reverse::fix_length_and_dec(THD *thd) { if (agg_arg_charsets_for_string_result(collation, args, 1)) return TRUE; @@ -1300,7 +1300,7 @@ null: } -bool Item_func_replace::fix_length_and_dec() +bool Item_func_replace::fix_length_and_dec(THD *thd) { ulonglong char_length= (ulonglong) args[0]->max_char_length(); int diff=(int) (args[2]->max_char_length() - 1); @@ -1327,7 +1327,7 @@ Item_func_sformat::Item_func_sformat(THD *thd, List<Item> &list) } -bool Item_func_sformat::fix_length_and_dec() +bool Item_func_sformat::fix_length_and_dec(THD *thd) { if (!val_arg) return TRUE; @@ -1450,7 +1450,7 @@ String *Item_func_sformat::val_str(String *res) } /*********************************************************************/ -bool Item_func_regexp_replace::fix_length_and_dec() +bool Item_func_regexp_replace::fix_length_and_dec(THD *thd) { if (agg_arg_charsets_for_string_result_with_comparison(collation, args, 3)) return TRUE; @@ -1588,7 +1588,7 @@ err: } -bool Item_func_regexp_substr::fix_length_and_dec() +bool Item_func_regexp_substr::fix_length_and_dec(THD *thd) { if (agg_arg_charsets_for_string_result_with_comparison(collation, args, 2)) return TRUE; @@ -1703,7 +1703,7 @@ null: } -bool Item_func_insert::fix_length_and_dec() +bool Item_func_insert::fix_length_and_dec(THD *thd) { ulonglong char_length; @@ -1736,7 +1736,7 @@ String *Item_str_conv::val_str(String *str) } -bool Item_func_lcase::fix_length_and_dec() +bool Item_func_lcase::fix_length_and_dec(THD *thd) { if (agg_arg_charsets_for_string_result(collation, args, 1)) return TRUE; @@ -1747,7 +1747,7 @@ bool Item_func_lcase::fix_length_and_dec() return FALSE; } -bool Item_func_ucase::fix_length_and_dec() +bool Item_func_ucase::fix_length_and_dec(THD *thd) { if (agg_arg_charsets_for_string_result(collation, args, 1)) return TRUE; @@ -1795,7 +1795,7 @@ void Item_str_func::left_right_max_length() } -bool Item_func_left::fix_length_and_dec() +bool Item_func_left::fix_length_and_dec(THD *thd) { if (agg_arg_charsets_for_string_result(collation, args, 1)) return TRUE; @@ -1831,7 +1831,7 @@ String *Item_func_right::val_str(String *str) } -bool Item_func_right::fix_length_and_dec() +bool Item_func_right::fix_length_and_dec(THD *thd) { if (agg_arg_charsets_for_string_result(collation, args, 1)) return TRUE; @@ -1888,7 +1888,7 @@ String *Item_func_substr::val_str(String *str) } -bool Item_func_substr::fix_length_and_dec() +bool Item_func_substr::fix_length_and_dec(THD *thd) { max_length=args[0]->max_length; @@ -1918,7 +1918,7 @@ bool Item_func_substr::fix_length_and_dec() } -bool Item_func_substr_index::fix_length_and_dec() +bool Item_func_substr_index::fix_length_and_dec(THD *thd) { if (agg_arg_charsets_for_string_result_with_comparison(collation, args, 2)) return TRUE; @@ -2263,7 +2263,7 @@ String *Item_func_trim::val_str(String *str) return trimmed_value(res, (uint32) (ptr - res->ptr()), (uint32) (end - ptr)); } -bool Item_func_trim::fix_length_and_dec() +bool Item_func_trim::fix_length_and_dec(THD *thd) { if (arg_count == 1) { @@ -2459,7 +2459,7 @@ bool Item_func_encode::seed() return FALSE; } -bool Item_func_encode::fix_length_and_dec() +bool Item_func_encode::fix_length_and_dec(THD *thd) { max_length=args[0]->max_length; base_flags|= ((args[0]->base_flags | args[1]->base_flags) & @@ -2635,7 +2635,7 @@ bool Item_func_current_role::fix_fields(THD *thd, Item **ref) return 0; } -bool Item_func_soundex::fix_length_and_dec() +bool Item_func_soundex::fix_length_and_dec(THD *thd) { uint32 char_length= args[0]->max_char_length(); if (agg_arg_charsets_for_string_result(collation, args, 1)) @@ -2805,7 +2805,7 @@ String *Item_func_soundex::val_str(String *str) const int FORMAT_MAX_DECIMALS= 38; -bool Item_func_format::fix_length_and_dec() +bool Item_func_format::fix_length_and_dec(THD *thd) { uint32 char_length= args[0]->type_handler()->Item_decimal_notation_int_digits(args[0]); uint dec= FORMAT_MAX_DECIMALS; @@ -2952,7 +2952,7 @@ String *Item_func_format::val_str_ascii(String *str) } -bool Item_func_elt::fix_length_and_dec() +bool Item_func_elt::fix_length_and_dec(THD *thd) { uint32 char_length= 0; decimals=0; @@ -3014,7 +3014,7 @@ String *Item_func_elt::val_str(String *str) } -bool Item_func_make_set::fix_length_and_dec() +bool Item_func_make_set::fix_length_and_dec(THD *thd) { uint32 char_length= arg_count - 2; /* Separators */ @@ -3177,7 +3177,7 @@ inline String* alloc_buffer(String *res,String *str,String *tmp_value, } -bool Item_func_repeat::fix_length_and_dec() +bool Item_func_repeat::fix_length_and_dec(THD *thd) { if (agg_arg_charsets_for_string_result(collation, args, 1)) return TRUE; @@ -3253,7 +3253,7 @@ err: } -bool Item_func_space::fix_length_and_dec() +bool Item_func_space::fix_length_and_dec(THD *thd) { collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); if (args[0]->can_eval_in_optimize()) @@ -3313,7 +3313,7 @@ err: } -bool Item_func_binlog_gtid_pos::fix_length_and_dec() +bool Item_func_binlog_gtid_pos::fix_length_and_dec(THD *thd) { collation.set(system_charset_info); max_length= MAX_BLOB_WIDTH; @@ -3362,7 +3362,7 @@ static String *default_pad_str(String *pad_str, CHARSET_INFO *collation) return pad_str; } -bool Item_func_pad::fix_length_and_dec() +bool Item_func_pad::fix_length_and_dec(THD *thd) { if (arg_count == 3) { @@ -3698,7 +3698,7 @@ String *Item_func_conv_charset::val_str(String *str) 0 : str; } -bool Item_func_conv_charset::fix_length_and_dec() +bool Item_func_conv_charset::fix_length_and_dec(THD *thd) { DBUG_ASSERT(collation.derivation == DERIVATION_IMPLICIT); fix_char_length(args[0]->max_char_length()); @@ -3724,7 +3724,7 @@ String *Item_func_set_collation::val_str(String *str) return str; } -bool Item_func_set_collation::fix_length_and_dec() +bool Item_func_set_collation::fix_length_and_dec(THD *thd) { if (agg_arg_charsets_for_string_result(collation, args, 1)) return true; @@ -3781,7 +3781,7 @@ String *Item_func_collation::val_str(String *str) } -bool Item_func_weight_string::fix_length_and_dec() +bool Item_func_weight_string::fix_length_and_dec(THD *thd) { CHARSET_INFO *cs= args[0]->collation.collation; collation.set(&my_charset_bin, args[0]->collation.derivation); @@ -4171,7 +4171,7 @@ String* Item_func_export_set::val_str(String* str) return str; } -bool Item_func_export_set::fix_length_and_dec() +bool Item_func_export_set::fix_length_and_dec(THD *thd) { uint32 length= MY_MAX(args[1]->max_char_length(), args[2]->max_char_length()); uint32 sep_length= (arg_count > 3 ? args[3]->max_char_length() : 1); @@ -4583,7 +4583,7 @@ bool Item_func_dyncol_create::fix_fields(THD *thd, Item **ref) } -bool Item_func_dyncol_create::fix_length_and_dec() +bool Item_func_dyncol_create::fix_length_and_dec(THD *thd) { max_length= MAX_BLOB_WIDTH; set_maybe_null(); @@ -5434,7 +5434,7 @@ Item_temptable_rowid::Item_temptable_rowid(TABLE *table_arg) max_length= table->file->ref_length; } -bool Item_temptable_rowid::fix_length_and_dec() +bool Item_temptable_rowid::fix_length_and_dec(THD *thd) { used_tables_cache= table->map; const_item_cache= false; @@ -5700,7 +5700,7 @@ error_exit: return nullptr; } -bool Item_func_natural_sort_key::fix_length_and_dec(void) +bool Item_func_natural_sort_key::fix_length_and_dec(THD *thd) { if (agg_arg_charsets_for_string_result(collation, args, 1)) return true; diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index de127445a23..68b6f954b0a 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -145,7 +145,7 @@ class Item_func_md5 :public Item_str_ascii_checksum_func public: Item_func_md5(THD *thd, Item *a): Item_str_ascii_checksum_func(thd, a) {} String *val_str_ascii(String *) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { fix_length_and_charset(32, default_charset()); return FALSE; @@ -165,7 +165,7 @@ class Item_func_sha :public Item_str_ascii_checksum_func public: Item_func_sha(THD *thd, Item *a): Item_str_ascii_checksum_func(thd, a) {} String *val_str_ascii(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("sha") }; @@ -181,7 +181,7 @@ public: Item_func_sha2(THD *thd, Item *a, Item *b) :Item_str_ascii_checksum_func(thd, a, b) {} String *val_str_ascii(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("sha2") }; @@ -198,7 +198,7 @@ public: Item_func_to_base64(THD *thd, Item *a) :Item_str_ascii_checksum_func(thd, a) {} String *val_str_ascii(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("to_base64") }; @@ -215,7 +215,7 @@ public: Item_func_from_base64(THD *thd, Item *a) :Item_str_binary_checksum_func(thd, a) { } String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("from_base64") }; @@ -246,7 +246,7 @@ class Item_func_aes_encrypt :public Item_aes_crypt public: Item_func_aes_encrypt(THD *thd, Item *a, Item *b) :Item_aes_crypt(thd, a, b) {} - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("aes_encrypt") }; @@ -261,7 +261,7 @@ class Item_func_aes_decrypt :public Item_aes_crypt public: Item_func_aes_decrypt(THD *thd, Item *a, Item *b): Item_aes_crypt(thd, a, b) {} - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("aes_decrypt") }; @@ -282,7 +282,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("natural_sort_key")}; return name; } - bool fix_length_and_dec(void) override; + bool fix_length_and_dec(THD *thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_natural_sort_key>(thd, this); @@ -308,7 +308,7 @@ public: Item_func_concat(THD *thd, List<Item> &list): Item_str_func(thd, list) {} Item_func_concat(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("concat") }; @@ -351,7 +351,7 @@ public: Item_func_decode_histogram(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} String *val_str(String *) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { collation.set(system_charset_info); max_length= MAX_BLOB_WIDTH; @@ -373,7 +373,7 @@ class Item_func_concat_ws :public Item_str_func public: Item_func_concat_ws(THD *thd, List<Item> &list): Item_str_func(thd, list) {} String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("concat_ws") }; @@ -390,7 +390,7 @@ class Item_func_reverse :public Item_str_func public: Item_func_reverse(THD *thd, Item *a): Item_str_func(thd, a) {} String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("reverse") }; @@ -408,7 +408,7 @@ public: Item_func_replace(THD *thd, Item *org, Item *find, Item *replace): Item_str_func(thd, org, find, replace) {} String *val_str(String *to) override { return val_str_internal(to, NULL); }; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; String *val_str_internal(String *str, String *empty_string_for_null); LEX_CSTRING func_name_cstring() const override { @@ -456,7 +456,7 @@ public: DBUG_VOID_RETURN; } String *val_str(String *str) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("regexp_replace") }; @@ -481,7 +481,7 @@ public: DBUG_VOID_RETURN; } String *val_str(String *str) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("regexp_substr") }; @@ -499,7 +499,7 @@ public: Item *new_str): Item_str_func(thd, org, start, length, new_str) {} String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("insert") }; @@ -531,7 +531,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("lcase") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_lcase>(thd, this); } }; @@ -545,7 +545,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("ucase") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_ucase>(thd, this); } }; @@ -557,7 +557,7 @@ class Item_func_left :public Item_str_func public: Item_func_left(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("left") }; @@ -574,7 +574,7 @@ class Item_func_right :public Item_str_func public: Item_func_right(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("right") }; @@ -595,7 +595,7 @@ public: Item_func_substr(THD *thd, Item *a, Item *b, Item *c): Item_str_func(thd, a, b, c) {} String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("substr") }; @@ -612,7 +612,7 @@ public: Item_func_sformat(THD *thd, List<Item> &list); ~Item_func_sformat() { delete [] val_arg; } String *val_str(String*) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("sformat") }; @@ -634,9 +634,9 @@ public: Item_func_substr(thd, a, b) {} Item_func_substr_oracle(THD *thd, Item *a, Item *b, Item *c): Item_func_substr(thd, a, b, c) {} - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - bool res= Item_func_substr::fix_length_and_dec(); + bool res= Item_func_substr::fix_length_and_dec(thd); set_maybe_null(); return res; } @@ -656,7 +656,7 @@ public: Item_func_substr_index(THD *thd, Item *a,Item *b,Item *c): Item_str_func(thd, a, b, c) {} String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("substring_index") }; @@ -701,7 +701,7 @@ public: Item_func_trim(THD *thd, Item *a): Item_str_func(thd, a) {} Sql_mode_dependency value_depends_on_sql_mode() const override; String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("trim") }; @@ -733,9 +733,9 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("trim_oracle") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - bool res= Item_func_trim::fix_length_and_dec(); + bool res= Item_func_trim::fix_length_and_dec(thd); set_maybe_null(); return res; } @@ -785,9 +785,9 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("ltrim_oracle") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - bool res= Item_func_ltrim::fix_length_and_dec(); + bool res= Item_func_ltrim::fix_length_and_dec(thd); set_maybe_null(); return res; } @@ -833,9 +833,9 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("rtrim_oracle") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - bool res= Item_func_rtrim::fix_length_and_dec(); + bool res= Item_func_rtrim::fix_length_and_dec(thd); set_maybe_null(); return res; } @@ -866,7 +866,7 @@ public: Item_str_ascii_checksum_func(thd, a), alg(al), deflt(0) {} String *val_str_ascii(String *str) override; bool fix_fields(THD *thd, Item **ref) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { fix_length_and_charset((alg == 1 ? SCRAMBLED_PASSWORD_CHAR_LENGTH : @@ -897,7 +897,7 @@ public: Item_func_des_encrypt(THD *thd, Item *a, Item *b) :Item_str_binary_checksum_func(thd, a, b) {} String *val_str(String *) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { set_maybe_null(); /* 9 = MAX ((8- (arg_len % 8)) + 1) */ @@ -922,7 +922,7 @@ public: Item_func_des_decrypt(THD *thd, Item *a, Item *b) :Item_str_binary_checksum_func(thd, a, b) {} String *val_str(String *) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { set_maybe_null(); /* 9 = MAX ((8- (arg_len % 8)) + 1) */ @@ -966,7 +966,7 @@ public: constructor_helper(); } String *val_str(String *) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { set_maybe_null(); max_length = 13; @@ -999,7 +999,7 @@ public: Item_func_encode(THD *thd, Item *a, Item *seed_arg): Item_str_binary_checksum_func(thd, a, seed_arg) {} String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("encode") }; @@ -1057,7 +1057,7 @@ class Item_func_database :public Item_func_sysconst public: Item_func_database(THD *thd): Item_func_sysconst(thd) {} String *val_str(String *) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= NAME_CHAR_LEN * system_charset_info->mbmaxlen; set_maybe_null(); @@ -1091,7 +1091,7 @@ public: { str->append(func_name_cstring()); } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= 512 * system_charset_info->mbmaxlen; null_value= false; @@ -1119,7 +1119,7 @@ public: return (null_value ? 0 : &str_value); } bool fix_fields(THD *thd, Item **ref) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= (uint32) (username_char_length + HOSTNAME_LENGTH + 1) * SYSTEM_CHARSET_MBMAXLEN; @@ -1173,7 +1173,7 @@ public: Item_func_current_role(THD *thd, Name_resolution_context *context_arg): Item_func_sysconst(thd), context(context_arg) {} bool fix_fields(THD *thd, Item **ref) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= (uint32) username_char_length * SYSTEM_CHARSET_MBMAXLEN; return FALSE; @@ -1209,7 +1209,7 @@ class Item_func_soundex :public Item_str_func public: Item_func_soundex(THD *thd, Item *a): Item_str_func(thd, a) {} String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("soundex") }; @@ -1227,7 +1227,7 @@ public: double val_real() override; longlong val_int() override; String *val_str(String *str) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("elt") }; @@ -1245,7 +1245,7 @@ class Item_func_make_set :public Item_str_func public: Item_func_make_set(THD *thd, List<Item> &list): Item_str_func(thd, list) {} String *val_str(String *str) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("make_set") }; @@ -1266,7 +1266,7 @@ public: Item_str_ascii_func(thd, org, dec, lang) {} String *val_str_ascii(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("format") }; @@ -1290,7 +1290,7 @@ public: { collation.set(cs); } String *val_str(String *) override; void append_char(String * str, int32 num); - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= arg_count * 4; return FALSE; @@ -1311,7 +1311,7 @@ public: Item_func_chr(THD *thd, Item *arg1, CHARSET_INFO *cs): Item_func_char(thd, arg1, cs) {} String *val_str(String *) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= 4; return FALSE; @@ -1332,7 +1332,7 @@ public: Item_func_repeat(THD *thd, Item *arg1, Item *arg2): Item_str_func(thd, arg1, arg2) {} String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("repeat") }; @@ -1348,7 +1348,7 @@ class Item_func_space :public Item_str_func public: Item_func_space(THD *thd, Item *arg1): Item_str_func(thd, arg1) {} String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("space") }; @@ -1365,7 +1365,7 @@ public: Item_func_binlog_gtid_pos(THD *thd, Item *arg1, Item *arg2): Item_str_func(thd, arg1, arg2) {} String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("binlog_gtid_pos") }; @@ -1389,7 +1389,7 @@ public: Item_str_func(thd, arg1, arg2, arg3) {} Item_func_pad(THD *thd, Item *arg1, Item *arg2): Item_str_func(thd, arg1, arg2) {} - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; }; @@ -1421,9 +1421,9 @@ public: Item_func_rpad(thd, arg1, arg2, arg3) {} Item_func_rpad_oracle(THD *thd, Item *arg1, Item *arg2): Item_func_rpad(thd, arg1, arg2) {} - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - bool res= Item_func_rpad::fix_length_and_dec(); + bool res= Item_func_rpad::fix_length_and_dec(thd); set_maybe_null(); return res; } @@ -1464,9 +1464,9 @@ public: Item_func_lpad(thd, arg1, arg2, arg3) {} Item_func_lpad_oracle(THD *thd, Item *arg1, Item *arg2): Item_func_lpad(thd, arg1, arg2) {} - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - bool res= Item_func_lpad::fix_length_and_dec(); + bool res= Item_func_lpad::fix_length_and_dec(thd); set_maybe_null(); return res; } @@ -1491,7 +1491,7 @@ public: return name; } String *val_str(String *) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { collation.set(default_charset()); fix_char_length(64); @@ -1530,7 +1530,7 @@ public: DBUG_ASSERT(fixed()); return m_arg0_type_handler->Item_func_hex_val_str_ascii(this, str); } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); decimals=0; @@ -1557,7 +1557,7 @@ public: return name; } String *val_str(String *) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { collation.set(&my_charset_bin); decimals=0; @@ -1583,7 +1583,7 @@ public: set_maybe_null(); } String *val_str(String *) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { collation.set(args[0]->collation); decimals=0; @@ -1637,7 +1637,7 @@ public: tmp->set_charset(&my_charset_bin); return tmp; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { collation.set(&my_charset_bin); max_length=args[0]->max_length; @@ -1666,7 +1666,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("load_file") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { collation.set(&my_charset_bin, DERIVATION_COERCIBLE); set_maybe_null(); @@ -1692,7 +1692,7 @@ class Item_func_export_set: public Item_str_func Item_func_export_set(THD *thd, Item *a, Item *b, Item* c, Item* d, Item* e): Item_str_func(thd, a, b, c, d, e) {} String *val_str(String *str) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("export_set") }; @@ -1714,7 +1714,7 @@ public: return name; } String *val_str(String *) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { collation.set(args[0]->collation); ulonglong max_result_length= (ulonglong) args[0]->max_length * 2 + @@ -1811,7 +1811,7 @@ public: return 1; return res; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("convert") }; @@ -1830,7 +1830,7 @@ public: Item_func_set_collation(THD *thd, Item *a, CHARSET_INFO *set_collation): Item_str_func(thd, a), m_set_collation(set_collation) {} String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool eq(const Item *item, bool binary_cmp) const override; LEX_CSTRING func_name_cstring() const override { @@ -1855,7 +1855,7 @@ class Item_func_expr_str_metadata :public Item_str_func { public: Item_func_expr_str_metadata(THD *thd, Item *a): Item_str_func(thd, a) { } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { collation.set(system_charset_info); max_length= 64 * collation.collation->mbmaxlen; // should be enough @@ -1923,7 +1923,7 @@ public: return name; } String *val_str(String *) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool eq(const Item *item, bool binary_cmp) const override { if (!Item_str_func::eq(item, binary_cmp)) @@ -1966,7 +1966,7 @@ public: static LEX_CSTRING crc32c_name= {STRING_WITH_LEN("crc32c") }; return crc_func == my_crc32c ? crc32c_name : crc32_name; } - bool fix_length_and_dec() override { max_length=10; return FALSE; } + bool fix_length_and_dec(THD *thd) override { max_length=10; return FALSE; } longlong val_int() override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_crc32>(thd, this); } @@ -1983,7 +1983,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("uncompressed_length") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length=10; set_maybe_null(); @@ -2005,7 +2005,7 @@ class Item_func_compress: public Item_str_binary_checksum_func public: Item_func_compress(THD *thd, Item *a) :Item_str_binary_checksum_func(thd, a) {} - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= (args[0]->max_length * 120) / 100 + 12; return FALSE; @@ -2026,7 +2026,7 @@ class Item_func_uncompress: public Item_str_binary_checksum_func public: Item_func_uncompress(THD *thd, Item *a) :Item_str_binary_checksum_func(thd, a) {} - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { set_maybe_null(); max_length= MAX_BLOB_WIDTH; @@ -2056,7 +2056,7 @@ protected: public: Item_func_dyncol_create(THD *thd, List<Item> &args, DYNCALL_CREATE_DEF *dfs); bool fix_fields(THD *thd, Item **ref) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("column_create") }; @@ -2098,7 +2098,7 @@ public: return name; } String *val_str(String *) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= MAX_BLOB_WIDTH; set_maybe_null(); @@ -2118,7 +2118,7 @@ class Item_dyncol_get: public Item_str_func public: Item_dyncol_get(THD *thd, Item *str, Item *num): Item_str_func(thd, str, num) {} - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { set_maybe_null(); max_length= MAX_BLOB_WIDTH; @@ -2165,7 +2165,7 @@ class Item_func_dyncol_list: public Item_str_func public: Item_func_dyncol_list(THD *thd, Item *str): Item_str_func(thd, str) {collation.set(DYNCOL_UTF);} - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { set_maybe_null(); max_length= MAX_BLOB_WIDTH; @@ -2202,7 +2202,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("<rowid>") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_temptable_rowid>(thd, this); } }; @@ -2221,7 +2221,7 @@ public: return name; } String *val_str_ascii(String *) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= WSREP_GTID_STR_LEN; set_maybe_null(); @@ -2242,7 +2242,7 @@ public: return name; } String *val_str_ascii(String *) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= WSREP_GTID_STR_LEN; set_maybe_null(); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index c8a7aca5afb..5c8ba8d62d1 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1141,7 +1141,7 @@ Item_sum_num::fix_fields(THD *thd, Item **ref) result_field=0; max_length=float_length(decimals); null_value=1; - if (fix_length_and_dec() || + if (fix_length_and_dec(thd) || check_sum_func(thd, ref)) return TRUE; @@ -1167,7 +1167,7 @@ Item_sum_min_max::fix_fields(THD *thd, Item **ref) /* We should ignore FIELD's in arguments to sum functions */ with_flags|= (args[0]->with_flags & ~item_with_t::FIELD); - if (fix_length_and_dec()) + if (fix_length_and_dec(thd)) DBUG_RETURN(TRUE); if (!is_window_func_sum_expr()) @@ -1243,7 +1243,7 @@ bool Item_sum_hybrid::fix_length_and_dec_string() } -bool Item_sum_min_max::fix_length_and_dec() +bool Item_sum_min_max::fix_length_and_dec(THD *thd) { DBUG_ASSERT(args[0]->field_type() == args[0]->real_item()->field_type()); DBUG_ASSERT(args[0]->result_type() == args[0]->real_item()->result_type()); @@ -1372,7 +1372,7 @@ Item_sum_sp::fix_fields(THD *thd, Item **ref) result_field= NULL; max_length= float_length(decimals); null_value= 1; - if (fix_length_and_dec()) + if (fix_length_and_dec(thd)) return TRUE; if (check_sum_func(thd, ref)) @@ -1459,12 +1459,12 @@ Item_sum_sp::cleanup() */ bool -Item_sum_sp::fix_length_and_dec() +Item_sum_sp::fix_length_and_dec(THD *thd) { DBUG_ENTER("Item_sum_sp::fix_length_and_dec"); DBUG_ASSERT(sp_result_field); Type_std_attributes::set(sp_result_field->type_std_attributes()); - bool res= Item_sum::fix_length_and_dec(); + bool res= Item_sum::fix_length_and_dec(thd); DBUG_RETURN(res); } @@ -1560,7 +1560,7 @@ void Item_sum_sum::fix_length_and_dec_decimal() } -bool Item_sum_sum::fix_length_and_dec() +bool Item_sum_sum::fix_length_and_dec(THD *thd) { DBUG_ENTER("Item_sum_sum::fix_length_and_dec"); set_maybe_null(); @@ -1982,7 +1982,7 @@ void Item_sum_avg::fix_length_and_dec_double() } -bool Item_sum_avg::fix_length_and_dec() +bool Item_sum_avg::fix_length_and_dec(THD *thd) { DBUG_ENTER("Item_sum_avg::fix_length_and_dec"); prec_increment= current_thd->variables.div_precincrement; @@ -2214,7 +2214,7 @@ void Item_sum_variance::fix_length_and_dec_decimal() } -bool Item_sum_variance::fix_length_and_dec() +bool Item_sum_variance::fix_length_and_dec(THD *thd) { DBUG_ENTER("Item_sum_variance::fix_length_and_dec"); set_maybe_null(); @@ -3472,7 +3472,7 @@ my_decimal *Item_sum_udf_int::val_decimal(my_decimal *dec) /** Default max_length is max argument length. */ -bool Item_sum_udf_str::fix_length_and_dec() +bool Item_sum_udf_str::fix_length_and_dec(THD *thd) { DBUG_ENTER("Item_sum_udf_str::fix_length_and_dec"); max_length=0; diff --git a/sql/item_sum.h b/sql/item_sum.h index 82cfe5c72ea..e27e6787327 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -461,7 +461,7 @@ public: Updated value is then saved in the field. */ virtual void update_field()=0; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { set_maybe_null(); null_value=1; @@ -783,7 +783,7 @@ public: { return get_date_from_int(thd, ltime, fuzzydate); } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=21; @@ -805,7 +805,7 @@ protected: my_decimal direct_sum_decimal; my_decimal dec_buffs[2]; uint curr_dec_buff; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; public: Item_sum_sum(THD *thd, Item *item_par, bool distinct): @@ -950,7 +950,7 @@ public: void fix_length_and_dec_double(); void fix_length_and_dec_decimal(); - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; enum Sumfunctype sum_func () const override { return has_with_distinct() ? AVG_DISTINCT_FUNC : AVG_FUNC; @@ -1034,7 +1034,7 @@ public: class Item_sum_variance :public Item_sum_double { Stddev m_stddev; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; public: uint sample; @@ -1149,7 +1149,7 @@ public: cmp_sign(item->cmp_sign), was_values(item->was_values) { } bool fix_fields(THD *, Item **) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; void setup_hybrid(THD *thd, Item *item, Item *value_arg); void clear() override; void direct_add(Item *item); @@ -1240,7 +1240,7 @@ public: void update_field() override; const Type_handler *type_handler() const override { return &type_handler_ulonglong; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { if (args[0]->check_type_can_return_int(func_name_cstring())) return true; @@ -1430,7 +1430,7 @@ public: { return create_table_field_from_handler(root, table); } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool fix_fields(THD *thd, Item **ref) override; LEX_CSTRING func_name_cstring() const override; const Type_handler *type_handler() const override; @@ -1720,7 +1720,7 @@ class Item_sum_udf_float :public Item_udf_sum my_decimal *val_decimal(my_decimal *) override; const Type_handler *type_handler() const override { return &type_handler_double; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { fix_num_length_and_dec(); return FALSE; } Item *copy_or_same(THD* thd) override; Item *get_copy(THD *thd) override @@ -1748,7 +1748,7 @@ public: return &type_handler_ulonglong; return &type_handler_slonglong; } - bool fix_length_and_dec() override { decimals=0; max_length=21; return FALSE; } + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=21; return FALSE; } Item *copy_or_same(THD* thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_sum_udf_int>(thd, this); } @@ -1790,7 +1790,7 @@ public: my_decimal *val_decimal(my_decimal *dec) override; const Type_handler *type_handler() const override { return string_type_handler(); } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *copy_or_same(THD* thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_sum_udf_str>(thd, this); } @@ -1821,7 +1821,7 @@ public: my_decimal *val_decimal(my_decimal *) override; const Type_handler *type_handler() const override { return &type_handler_newdecimal; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { fix_num_length_and_dec(); return FALSE; } Item *copy_or_same(THD* thd) override; Item *get_copy(THD *thd) override @@ -1899,7 +1899,7 @@ public: { DBUG_ASSERT(fixed()); null_value=1; return 0; } double val_real() { DBUG_ASSERT(fixed()); null_value=1; return 0.0; } longlong val_int() { DBUG_ASSERT(fixed()); null_value=1; return 0; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { base_flags|= item_base_t::MAYBE_NULL; max_length=0; return FALSE; } enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } void clear() {} diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 148488680f0..8399e5dc0ac 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -971,9 +971,8 @@ longlong Item_func_month::val_int() } -bool Item_func_monthname::fix_length_and_dec() +bool Item_func_monthname::fix_length_and_dec(THD *thd) { - THD* thd= current_thd; CHARSET_INFO *cs= thd->variables.collation_connection; locale= thd->variables.lc_time_names; collation.set(cs, DERIVATION_COERCIBLE, locale->repertoire()); @@ -1116,9 +1115,8 @@ longlong Item_func_weekday::val_int() return dt.weekday(odbc_type) + MY_TEST(odbc_type); } -bool Item_func_dayname::fix_length_and_dec() +bool Item_func_dayname::fix_length_and_dec(THD *thd) { - THD* thd= current_thd; CHARSET_INFO *cs= thd->variables.collation_connection; locale= thd->variables.lc_time_names; collation.set(cs, DERIVATION_COERCIBLE, locale->repertoire()); @@ -1735,9 +1733,8 @@ bool Item_func_sec_to_time::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fu return false; } -bool Item_func_date_format::fix_length_and_dec() +bool Item_func_date_format::fix_length_and_dec(THD *thd) { - THD* thd= current_thd; if (!is_time_format) { if (arg_count < 3) @@ -2617,9 +2614,8 @@ err_exit: } -bool Item_func_tochar::fix_length_and_dec() +bool Item_func_tochar::fix_length_and_dec(THD *thd) { - thd= current_thd; CHARSET_INFO *cs= thd->variables.collation_connection; Item *arg1= args[1]->this_item(); my_repertoire_t repertoire= arg1->collation.repertoire; @@ -2683,6 +2679,7 @@ bool Item_func_tochar::fix_length_and_dec() String *Item_func_tochar::val_str(String* str) { + THD *thd= current_thd; StringBuffer<64> format_buffer; String *format; MYSQL_TIME l_time; @@ -2733,9 +2730,8 @@ null_date: } -bool Item_func_from_unixtime::fix_length_and_dec() +bool Item_func_from_unixtime::fix_length_and_dec(THD *thd) { - THD *thd= current_thd; thd->time_zone_used= 1; tz= thd->variables.time_zone; Type_std_attributes::set( @@ -2818,7 +2814,7 @@ void Item_func_convert_tz::cleanup() } -bool Item_date_add_interval::fix_length_and_dec() +bool Item_date_add_interval::fix_length_and_dec(THD *thd) { enum_field_types arg0_field_type; @@ -2947,7 +2943,7 @@ bool Item_extract::check_arguments() const } -bool Item_extract::fix_length_and_dec() +bool Item_extract::fix_length_and_dec(THD *thd) { set_maybe_null(); // If wrong date uint32 daylen= args[0]->cmp_type() == TIME_RESULT ? 2 : @@ -3441,7 +3437,7 @@ err: } -bool Item_func_add_time::fix_length_and_dec() +bool Item_func_add_time::fix_length_and_dec(THD *thd) { enum_field_types arg0_field_type; @@ -3852,7 +3848,7 @@ get_date_time_result_type(const char *format, uint length) } -bool Item_func_str_to_date::fix_length_and_dec() +bool Item_func_str_to_date::fix_length_and_dec(THD *thd) { if (!args[0]->type_handler()->is_traditional_scalar_type() || !args[1]->type_handler()->is_traditional_scalar_type()) diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 9b78d6c159e..a5f6d9307c6 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -62,7 +62,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("period_add") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length=6*MY_CHARSET_BIN_MB_MAXLEN; return FALSE; @@ -84,7 +84,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("period_diff") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=6*MY_CHARSET_BIN_MB_MAXLEN; @@ -105,7 +105,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("to_days") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=6*MY_CHARSET_BIN_MB_MAXLEN; @@ -137,7 +137,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("to_seconds") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; fix_char_length(12); @@ -168,7 +168,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("dayofmonth") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=2*MY_CHARSET_BIN_MB_MAXLEN; @@ -197,7 +197,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("month") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals= 0; fix_char_length(2); @@ -226,7 +226,7 @@ public: return name; } String *val_str(String *str) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool check_partition_func_processor(void *int_arg) override {return TRUE;} bool check_valid_arguments_processor(void *int_arg) override { @@ -251,7 +251,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("dayofyear") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals= 0; fix_char_length(3); @@ -279,7 +279,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("hour") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=2*MY_CHARSET_BIN_MB_MAXLEN; @@ -307,7 +307,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("minute") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=2*MY_CHARSET_BIN_MB_MAXLEN; @@ -335,7 +335,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("quarter") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=1*MY_CHARSET_BIN_MB_MAXLEN; @@ -363,7 +363,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("second") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=2*MY_CHARSET_BIN_MB_MAXLEN; @@ -397,7 +397,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("week") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=2*MY_CHARSET_BIN_MB_MAXLEN; @@ -434,7 +434,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("yearweek") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=6*MY_CHARSET_BIN_MB_MAXLEN; @@ -464,7 +464,7 @@ public: } enum_monotonicity_info get_monotonicity_info() const override; longlong val_int_endpoint(bool left_endp, bool *incl_endp) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; max_length=4*MY_CHARSET_BIN_MB_MAXLEN; @@ -499,7 +499,7 @@ public: { return type_handler()->Item_get_date_with_warn(thd, this, ltime, fuzzydate); } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals= 0; fix_char_length(1); @@ -529,7 +529,7 @@ class Item_func_dayname :public Item_str_func String *val_str(String *str) override; const Type_handler *type_handler() const override { return &type_handler_varchar; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool check_partition_func_processor(void *int_arg) override {return TRUE;} bool check_vcol_func_processor(void *arg) override { @@ -600,10 +600,10 @@ public: return FALSE; return mark_unsupported_function(func_name(), "()", arg, VCOL_TIME_FUNC); } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { fix_length_and_dec_generic(arg_count ? - args[0]->datetime_precision(current_thd) : 0); + args[0]->datetime_precision(thd) : 0); return FALSE; } longlong int_op() override; @@ -629,9 +629,9 @@ public: { return !has_time_args(); } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - fix_length_and_dec_generic(args[0]->time_precision(current_thd)); + fix_length_and_dec_generic(args[0]->time_precision(thd)); return FALSE; } longlong int_op() override; @@ -657,7 +657,7 @@ public: { return Date(this).to_string(to); } my_decimal *val_decimal(my_decimal *to) override { return Date(this).to_decimal(to); } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { fix_attributes_date(); set_maybe_null(arg_count > 0); @@ -717,7 +717,7 @@ public: Item_func_curtime(THD *thd, uint dec): Item_timefunc(thd), last_query_id(0) { decimals= dec; } bool fix_fields(THD *, Item **) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { fix_attributes_time(decimals); return FALSE; } bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) override; /* @@ -821,7 +821,7 @@ public: Item_func_now(THD *thd, uint dec): Item_datetimefunc(thd), last_query_id(0) { decimals= dec; } bool fix_fields(THD *, Item **) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { fix_attributes_datetime(decimals); return FALSE;} bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) override; virtual void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time)=0; @@ -949,7 +949,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("date_format") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; uint format_length(const String *format); bool eq(const Item *item, bool binary_cmp) const override; bool check_vcol_func_processor(void *arg) override @@ -1014,7 +1014,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("to_char") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool parse_format_string(const String *format, uint *fmt_len); bool check_vcol_func_processor(void *arg) override @@ -1041,7 +1041,7 @@ class Item_func_from_unixtime :public Item_datetimefunc static LEX_CSTRING name= {STRING_WITH_LEN("from_unixtime") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) override; bool check_vcol_func_processor(void *arg) override { @@ -1089,9 +1089,9 @@ class Item_func_convert_tz :public Item_datetimefunc static LEX_CSTRING name= {STRING_WITH_LEN("convert_tz") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - fix_attributes_datetime(args[0]->datetime_precision(current_thd)); + fix_attributes_datetime(args[0]->datetime_precision(thd)); set_maybe_null(); return FALSE; } @@ -1109,7 +1109,7 @@ class Item_func_sec_to_time :public Item_timefunc public: Item_func_sec_to_time(THD *thd, Item *item): Item_timefunc(thd, item) {} bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { fix_attributes_time(args[0]->decimals); set_maybe_null(); @@ -1139,7 +1139,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("date_add_interval") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool eq(const Item *item, bool binary_cmp) const override; void print(String *str, enum_query_type query_type) override; enum precedence precedence() const override { return INTERVAL_PRECEDENCE; } @@ -1205,7 +1205,7 @@ class Item_extract :public Item_int_func, return name; } bool check_arguments() const override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool eq(const Item *item, bool binary_cmp) const override; void print(String *str, enum_query_type query_type) override; bool check_partition_func_processor(void *int_arg) override {return FALSE;} @@ -1292,7 +1292,7 @@ public: void fix_length_and_dec_numeric(); void fix_length_and_dec_str(); void fix_length_and_dec_native_to_binary(uint32 octet_length); - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { return args[0]->type_handler()->Item_char_typecast_fix_length_and_dec(this); } @@ -1335,7 +1335,7 @@ public: print_cast_temporal(str, query_type); } bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { return args[0]->type_handler()->Item_date_typecast_fix_length_and_dec(this); } @@ -1359,7 +1359,7 @@ public: print_cast_temporal(str, query_type); } bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { return args[0]->type_handler()-> Item_time_typecast_fix_length_and_dec(this); @@ -1385,7 +1385,7 @@ public: print_cast_temporal(str, query_type); } bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { return args[0]->type_handler()-> Item_datetime_typecast_fix_length_and_dec(this); @@ -1430,9 +1430,8 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("timestamp") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - THD *thd= current_thd; uint dec0= args[0]->datetime_precision(thd); uint dec1= Interval_DDhhmmssff::fsp(thd, args[1]); fix_attributes_datetime(MY_MAX(dec0, dec1)); @@ -1476,7 +1475,7 @@ public: Item_func_add_time(THD *thd, Item *a, Item *b, bool neg_arg) :Item_handled_func(thd, a, b), sign(neg_arg ? -1 : 1) { } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING addtime= { STRING_WITH_LEN("addtime") }; @@ -1499,9 +1498,8 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("timediff") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - THD *thd= current_thd; uint dec= MY_MAX(args[0]->time_precision(thd), args[1]->time_precision(thd)); fix_attributes_time(dec); @@ -1524,7 +1522,7 @@ public: Item_func_maketime(THD *thd, Item *a, Item *b, Item *c): Item_timefunc(thd, a, b, c) {} - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { fix_attributes_time(args[2]->decimals); set_maybe_null(); @@ -1551,7 +1549,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("microsecond") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; set_maybe_null(); @@ -1586,7 +1584,7 @@ public: return name; } longlong val_int() override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals=0; set_maybe_null(); @@ -1616,7 +1614,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("get_format") }; return name; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { set_maybe_null(); decimals=0; @@ -1647,7 +1645,7 @@ public: static LEX_CSTRING name= {STRING_WITH_LEN("str_to_date") }; return name; } - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_str_to_date>(thd, this); } }; diff --git a/sql/item_vers.h b/sql/item_vers.h index 7cd5d847b15..88c8cea837a 100644 --- a/sql/item_vers.h +++ b/sql/item_vers.h @@ -35,7 +35,7 @@ public: bool val_bool() override; longlong val_int() override { return val_bool(); } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { set_maybe_null(); null_value= 0; @@ -67,7 +67,7 @@ public: bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) override; Item *get_copy(THD *thd) override { return get_item_copy<Item_func_trt_ts>(thd, this); } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { fix_attributes_datetime(decimals); return FALSE; } }; @@ -102,9 +102,9 @@ public: return NULL_clex_str; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { - bool res= Item_int_func::fix_length_and_dec(); + bool res= Item_int_func::fix_length_and_dec(thd); max_length= 20; return res; } diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc index 4fef4fa10b2..5438cade27a 100644 --- a/sql/item_windowfunc.cc +++ b/sql/item_windowfunc.cc @@ -126,7 +126,7 @@ Item_window_func::fix_fields(THD *thd, Item **ref) with_flags= (with_flags & ~item_with_t::SUM_FUNC) | item_with_t::WINDOW_FUNC; - if (fix_length_and_dec()) + if (fix_length_and_dec(thd)) return TRUE; max_length= window_func()->max_length; @@ -352,7 +352,7 @@ bool Item_sum_hybrid_simple::fix_fields(THD *thd, Item **ref) with_flags|= args[i]->with_flags; } - if (fix_length_and_dec()) + if (fix_length_and_dec(thd)) return TRUE; setup_hybrid(thd, args[0]); @@ -368,7 +368,7 @@ bool Item_sum_hybrid_simple::fix_fields(THD *thd, Item **ref) } -bool Item_sum_hybrid_simple::fix_length_and_dec() +bool Item_sum_hybrid_simple::fix_length_and_dec(THD *thd) { set_maybe_null(); null_value= true; diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h index ce9d89e62dd..0dfc683ccf1 100644 --- a/sql/item_windowfunc.h +++ b/sql/item_windowfunc.h @@ -317,7 +317,7 @@ class Item_sum_hybrid_simple : public Item_sum_hybrid bool add() override; bool fix_fields(THD *, Item **) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; void setup_hybrid(THD *thd, Item *item); double val_real() override; longlong val_int() override; @@ -554,7 +554,7 @@ class Item_sum_percent_rank: public Item_sum_double, const Type_handler *type_handler() const override { return &type_handler_double; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals = 10; // TODO-cvicentiu find out how many decimals the standard // requires. @@ -644,7 +644,7 @@ class Item_sum_cume_dist: public Item_sum_double, const Type_handler *type_handler() const override { return &type_handler_double; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals = 10; // TODO-cvicentiu find out how many decimals the standard // requires. @@ -885,7 +885,7 @@ public: const Type_handler *type_handler() const override {return Type_handler_hybrid_field_type::type_handler();} - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals = 10; // TODO-cvicentiu find out how many decimals the standard // requires. @@ -1022,7 +1022,7 @@ public: } void update_field() override {} - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { decimals = 10; // TODO-cvicentiu find out how many decimals the standard // requires. @@ -1373,7 +1373,7 @@ public: void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &fields, uint flags) override; - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { Type_std_attributes::set(window_func()); return FALSE; diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index a130be4f973..7c209060c37 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -189,7 +189,7 @@ public: } return str; } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= MAX_BLOB_WIDTH; collation.collation= pxml->charset(); @@ -469,7 +469,7 @@ public: { return nodeset->copy(*native_cache); } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { max_length= MAX_BLOB_WIDTH; return FALSE; } Item *get_copy(THD *thd) override { return get_item_copy<Item_nodeset_context_cache>(thd, this); } @@ -487,7 +487,7 @@ public: { return { STRING_WITH_LEN("xpath_position") }; } - bool fix_length_and_dec() override { max_length=10; return FALSE; } + bool fix_length_and_dec(THD *thd) override { max_length=10; return FALSE; } longlong val_int() override { args[0]->val_native(current_thd, &tmp_native_value); @@ -511,7 +511,7 @@ public: { return { STRING_WITH_LEN("xpath_count") }; } - bool fix_length_and_dec() override { max_length=10; return FALSE; } + bool fix_length_and_dec(THD *thd) override { max_length=10; return FALSE; } longlong val_int() override { uint predicate_supplied_context_size; @@ -2766,7 +2766,7 @@ my_xpath_parse(MY_XPATH *xpath, const char *str, const char *strend) } -bool Item_xml_str_func::fix_length_and_dec() +bool Item_xml_str_func::fix_length_and_dec(THD *thd) { max_length= MAX_BLOB_WIDTH; return agg_arg_charsets_for_comparison(collation, args, arg_count); diff --git a/sql/item_xmlfunc.h b/sql/item_xmlfunc.h index e2ffe2fa630..f6e153c9451 100644 --- a/sql/item_xmlfunc.h +++ b/sql/item_xmlfunc.h @@ -118,7 +118,7 @@ public: set_maybe_null(); } bool fix_fields(THD *thd, Item **ref) override; - bool fix_length_and_dec() override; + bool fix_length_and_dec(THD *thd) override; bool const_item() const override { return const_item_cache && (!nodeset_func || nodeset_func->const_item()); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c044656e916..ff27c4d64c4 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -15667,7 +15667,7 @@ COND *Item_func_eq::build_equal_items(THD *thd, List_iterator_fast<Item_equal> it(cond_equal.current_level); while ((item_equal= it++)) { - if (item_equal->fix_length_and_dec()) + if (item_equal->fix_length_and_dec(thd)) return NULL; item_equal->update_used_tables(); set_if_bigger(thd->lex->current_select->max_equal_elems, diff --git a/sql/sql_type_fixedbin.h b/sql/sql_type_fixedbin.h index 236241f67b7..8e9b43a3afc 100644 --- a/sql/sql_type_fixedbin.h +++ b/sql/sql_type_fixedbin.h @@ -1537,7 +1537,7 @@ public: str->append(type_handler_fbt()->name().lex_cstring()); str->append(')'); } - bool fix_length_and_dec() override + bool fix_length_and_dec(THD *thd) override { Type_std_attributes::operator=(Type_std_attributes_fbt()); if (Fbt::fix_fields_maybe_null_on_conversion_to_fbt(args[0])) |