diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-09-28 14:01:17 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-09-28 14:01:17 +0400 |
commit | ad8e02ac452dc94d64b65cb9855b6dba97b651d4 (patch) | |
tree | 7c355aab42a911476eaa10520d1adbabb7091243 /sql/item_func.h | |
parent | 492998c0d80aa7d5c4804ac7792a38333e3b83dd (diff) | |
download | mariadb-git-ad8e02ac452dc94d64b65cb9855b6dba97b651d4.tar.gz |
MDEV-17317 Add THD* parameter into Item::get_date() and stricter data type control to "fuzzydate"
Diffstat (limited to 'sql/item_func.h')
-rw-r--r-- | sql/item_func.h | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/sql/item_func.h b/sql/item_func.h index f3547444e9b..51929482b96 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -405,8 +405,8 @@ public: my_decimal *val_decimal(my_decimal *decimal_value); longlong val_int() { DBUG_ASSERT(fixed == 1); return (longlong) rint(val_real()); } - bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) - { return get_date_from_real(ltime, fuzzydate); } + bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) + { return get_date_from_real(thd, ltime, fuzzydate); } const Type_handler *type_handler() const { return &type_handler_double; } bool fix_length_and_dec() { @@ -458,7 +458,7 @@ public: virtual double val_real(Item_handled_func *) const= 0; virtual longlong val_int(Item_handled_func *) const= 0; virtual my_decimal *val_decimal(Item_handled_func *, my_decimal *) const= 0; - virtual bool get_date(Item_handled_func *, MYSQL_TIME *, ulonglong fuzzydate) const= 0; + virtual bool get_date(THD *thd, Item_handled_func *, MYSQL_TIME *, date_mode_t fuzzydate) const= 0; virtual const Type_handler *return_type_handler() const= 0; virtual bool fix_length_and_dec(Item_handled_func *) const= 0; }; @@ -626,9 +626,9 @@ public: { return m_func_handler->val_decimal(this, to); } - bool get_date(MYSQL_TIME *to, ulonglong fuzzydate) + bool get_date(THD *thd, MYSQL_TIME *to, date_mode_t fuzzydate) { - return m_func_handler->get_date(this, to, fuzzydate); + return m_func_handler->get_date(thd, this, to, fuzzydate); } }; @@ -655,15 +655,15 @@ class Item_func_hybrid_field_type: public Item_hybrid_func Helper methods to make sure that the result of decimal_op(), str_op() and date_op() is properly synched with null_value. */ - bool date_op_with_null_check(MYSQL_TIME *ltime) + bool date_op_with_null_check(THD *thd, MYSQL_TIME *ltime) { - bool rc= date_op(ltime, 0); + bool rc= date_op(thd, ltime, date_mode_t(0)); DBUG_ASSERT(!rc ^ null_value); return rc; } - bool time_op_with_null_check(MYSQL_TIME *ltime) + bool time_op_with_null_check(THD *thd, MYSQL_TIME *ltime) { - bool rc= time_op(ltime); + bool rc= time_op(thd, ltime); DBUG_ASSERT(!rc ^ null_value); DBUG_ASSERT(rc || ltime->time_type == MYSQL_TIMESTAMP_TIME); return rc; @@ -674,7 +674,7 @@ class Item_func_hybrid_field_type: public Item_hybrid_func DBUG_ASSERT((res != NULL) ^ null_value); return res; } - bool make_zero_mysql_time(MYSQL_TIME *ltime, ulonglong fuzzydate) + bool make_zero_mysql_time(MYSQL_TIME *ltime, date_mode_t fuzzydate) { bzero(ltime, sizeof(*ltime)); return null_value|= !(fuzzydate & TIME_FUZZY_DATES); @@ -717,9 +717,9 @@ public: double val_real_from_time_op(); double val_real_from_int_op(); - bool get_date_from_str_op(MYSQL_TIME *ltime, ulonglong fuzzydate); - bool get_date_from_real_op(MYSQL_TIME *ltime, ulonglong fuzzydate); - bool get_date_from_int_op(MYSQL_TIME *ltime, ulonglong fuzzydate); + bool get_date_from_str_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate); + bool get_date_from_real_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate); + bool get_date_from_int_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate); public: Item_func_hybrid_field_type(THD *thd): @@ -764,11 +764,11 @@ public: DBUG_ASSERT(null_value == (res == NULL)); return res; } - bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date) + bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) { DBUG_ASSERT(fixed); return Item_func_hybrid_field_type::type_handler()-> - Item_func_hybrid_field_type_get_date(this, res, fuzzy_date); + Item_func_hybrid_field_type_get_date(thd, this, res, fuzzydate); } /** @@ -812,14 +812,14 @@ public: field type is DATETIME or DATE. @return The result of the operation. */ - virtual bool date_op(MYSQL_TIME *res, ulonglong fuzzy_date)= 0; + virtual bool date_op(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate)= 0; /** @brief Performs the operation that this functions implements when field type is TIME. @return The result of the operation. */ - virtual bool time_op(MYSQL_TIME *res)= 0; + virtual bool time_op(THD *thd, MYSQL_TIME *res)= 0; }; @@ -878,12 +878,12 @@ public: Item_func_hybrid_field_type(thd, list) { } String *str_op(String *str) { DBUG_ASSERT(0); return 0; } - bool date_op(MYSQL_TIME *ltime, ulonglong fuzzydate) + bool date_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) { DBUG_ASSERT(0); return true; } - bool time_op(MYSQL_TIME *ltime) + bool time_op(THD *thd, MYSQL_TIME *ltime) { DBUG_ASSERT(0); return true; @@ -969,8 +969,8 @@ public: { collation.set_numeric(); } double val_real(); String *val_str(String*str); - bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) - { return get_date_from_int(ltime, fuzzydate); } + bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) + { return get_date_from_int(thd, ltime, fuzzydate); } const Type_handler *type_handler() const= 0; bool fix_length_and_dec() { return FALSE; } }; @@ -1164,8 +1164,8 @@ public: double val_real() { return VDec(this).to_double(); } longlong val_int() { return VDec(this).to_longlong(unsigned_flag); } my_decimal *val_decimal(my_decimal*); - bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) - { return VDec(this).to_datetime_with_warn(ltime, fuzzydate, this); } + bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) + { return VDec(this).to_datetime_with_warn(thd, ltime, fuzzydate, this); } const Type_handler *type_handler() const { return &type_handler_newdecimal; } void fix_length_and_dec_generic() {} bool fix_length_and_dec() @@ -1719,8 +1719,8 @@ public: double val_real_native(); longlong val_int_native(); my_decimal *val_decimal_native(my_decimal *); - bool get_date_native(MYSQL_TIME *res, ulonglong fuzzydate); - bool get_time_native(MYSQL_TIME *res); + bool get_date_native(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate); + bool get_time_native(THD *thd, MYSQL_TIME *res); double val_real() { @@ -1746,11 +1746,11 @@ public: return Item_func_min_max::type_handler()-> Item_func_min_max_val_decimal(this, dec); } - bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date) + bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) { DBUG_ASSERT(fixed); return Item_func_min_max::type_handler()-> - Item_func_min_max_get_date(this, res, fuzzy_date); + Item_func_min_max_get_date(thd, this, res, fuzzydate); } void aggregate_attributes_real(Item **items, uint nitems) { @@ -1817,8 +1817,8 @@ public: String *val_str(String *str) { return val_str_from_item(args[0], str); } my_decimal *val_decimal(my_decimal *dec) { return val_decimal_from_item(args[0], dec); } - bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) - { return get_date_from_item(args[0], ltime, fuzzydate); } + bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) + { return get_date_from_item(thd, args[0], ltime, fuzzydate); } const char *func_name() const { return "rollup_const"; } bool const_item() const { return 0; } const Type_handler *type_handler() const { return args[0]->type_handler(); } @@ -2274,9 +2274,9 @@ public: { return mark_unsupported_function(func_name(), "()", arg, VCOL_NON_DETERMINISTIC); } - bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) + bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) { - return type_handler()->Item_get_date(this, ltime, fuzzydate); + return type_handler()->Item_get_date(thd, this, ltime, fuzzydate); } }; @@ -2584,8 +2584,8 @@ public: Field *create_field_for_create_select(TABLE *table) { return create_table_field_from_handler(table); } bool check_vcol_func_processor(void *arg); - bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) - { return type_handler()->Item_get_date(this, ltime, fuzzydate); } + bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) + { return type_handler()->Item_get_date(thd, this, ltime, fuzzydate); } }; @@ -2766,7 +2766,7 @@ public: double val_real(); longlong val_int(); String *val_str(String *str); - bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate); + bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate); my_decimal *val_decimal(my_decimal *decimal_buffer); /* fix_fields() binds variable name with its entry structure */ bool fix_fields(THD *thd, Item **ref); @@ -2813,9 +2813,9 @@ public: String* val_str(String*); my_decimal *val_decimal(my_decimal *dec_buf) { return val_decimal_from_real(dec_buf); } - bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) + bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) { - return type_handler()->Item_get_date(this, ltime, fuzzydate); + return type_handler()->Item_get_date(thd, this, ltime, fuzzydate); } /* TODO: fix to support views */ const char *func_name() const { return "get_system_var"; } @@ -3105,7 +3105,7 @@ public: return sp_result_field->val_decimal(dec_buf); } - bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) + bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) { if (execute()) return true; @@ -3259,7 +3259,7 @@ public: longlong val_int(); String *val_str(String *); my_decimal *val_decimal(my_decimal *); - bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate); + bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate); bool fix_length_and_dec(); const char *func_name() const { return "last_value"; } const Type_handler *type_handler() const { return last_value->type_handler(); } |