diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-02-22 01:24:02 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2018-02-24 00:50:58 +0100 |
commit | f3088112cbe928f0ad57bb56146bcf1e58c27108 (patch) | |
tree | ee8405ebc7223e8c4ad21366e1278fa8651be595 /sql | |
parent | 33366b10981567cb147375a28522f5e29d23aa5d (diff) | |
download | mariadb-git-f3088112cbe928f0ad57bb56146bcf1e58c27108.tar.gz |
MDEV-14645: AS OF TIMESTAMP is misused as TRX_ID
Remove 1668efb722d that introduced a special magic
behavior for UNIX_TIMESTAMP() in the AS OF context
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_func.h | 25 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 21 | ||||
-rw-r--r-- | sql/item_timefunc.h | 14 | ||||
-rw-r--r-- | sql/sql_select.cc | 24 | ||||
-rw-r--r-- | sql/sql_type.cc | 8 | ||||
-rw-r--r-- | sql/sql_type.h | 3 | ||||
-rw-r--r-- | sql/table.cc | 22 | ||||
-rw-r--r-- | sql/table.h | 1 |
8 files changed, 5 insertions, 113 deletions
diff --git a/sql/item_func.h b/sql/item_func.h index 1b3f28c41be..38a40e71544 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1005,31 +1005,6 @@ public: }; -class Item_longlong_typecast :public Item_int_func -{ -public: - Item_longlong_typecast(THD *thd, Item *a): Item_int_func(thd, a) - { - } - const char *func_name() const { return "cast_as_longlong"; } - const char *cast_type() const { return "longlong"; } - const Type_handler *type_handler() const { return &type_handler_longlong; } - longlong val_int() - { - return args[0]->val_int(); - } - void fix_length_and_dec_generic() {} - void fix_length_and_dec() - { - args[0]->type_handler()->Item_longlong_typecast_fix_length_and_dec(this); - } - bool need_parentheses_in_default() { return true; } - Item *get_copy(THD *thd) - { return get_item_copy<Item_longlong_typecast>(thd, this); } -}; - - - class Item_func_additive_op :public Item_num_op { public: diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 06c3aaecd54..4ddeb83b163 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2642,27 +2642,6 @@ bool Item_datetime_typecast::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) } -void Item_datetime_from_unixtime_typecast::fix_length_and_dec() -{ - Item_datetime_typecast::fix_length_and_dec(); - - switch (args[0]->result_type()) - { - case INT_RESULT: - case REAL_RESULT: - case DECIMAL_RESULT: - { - Query_arena_stmt on_stmt_arena(thd); - Item_func_from_unixtime *a= new (thd->mem_root) Item_func_from_unixtime(thd, args[0]); - a->fix_length_and_dec(); - args[0]= a; - break; - } - default:; - } -} - - /** MAKEDATE(a,b) is a date function that creates a date value from a year and day value. diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 761f619def8..c3bda9d85ba 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -1192,20 +1192,6 @@ public: }; -class Item_datetime_from_unixtime_typecast :public Item_datetime_typecast -{ - THD *thd; -public: - Item_datetime_from_unixtime_typecast(THD *_thd, Item *a, uint dec_arg): - Item_datetime_typecast(_thd, a, dec_arg), thd(_thd) {} - const char *func_name() const { return "cast_as_datetime_from_unixtime"; } - const char *cast_type() const { return "datetime"; } - void fix_length_and_dec(); - Item *get_copy(THD *thd) - { return get_item_copy<Item_datetime_from_unixtime_typecast>(thd, this); } -}; - - class Item_func_makedate :public Item_datefunc { bool check_arguments() const diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3e8c2d41813..0fb3275ceea 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -867,28 +867,14 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables, COND **where_expr TABLE *t= table->table; if (t->versioned(VERS_TIMESTAMP)) { - if (vers_conditions) - { - vers_conditions.start.add_typecast(thd, t->s->versioned); - vers_conditions.end.add_typecast(thd, t->s->versioned); - } + MYSQL_TIME max_time; switch (vers_conditions.type) { case SYSTEM_TIME_UNSPECIFIED: - if (t->vers_start_field()->real_type() != MYSQL_TYPE_LONGLONG) - { - MYSQL_TIME max_time; - thd->variables.time_zone->gmt_sec_to_TIME(&max_time, TIMESTAMP_MAX_VALUE); - max_time.second_part= TIME_MAX_SECOND_PART; - curr= newx Item_datetime_literal(thd, &max_time, - TIME_SECOND_PART_DIGITS); - cond1= newx Item_func_eq(thd, row_end, curr); - } - else - { - curr= newx Item_int(thd, ULONGLONG_MAX); - cond1= newx Item_func_eq(thd, row_end, curr); - } + thd->variables.time_zone->gmt_sec_to_TIME(&max_time, TIMESTAMP_MAX_VALUE); + max_time.second_part= TIME_MAX_SECOND_PART; + curr= newx Item_datetime_literal(thd, &max_time, TIME_SECOND_PART_DIGITS); + cond1= newx Item_func_eq(thd, row_end, curr); cond1= or_items(thd, cond1, newx Item_func_isnull(thd, row_end)); break; case SYSTEM_TIME_AS_OF: diff --git a/sql/sql_type.cc b/sql/sql_type.cc index a11b5a7978f..09daca0806e 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -4590,14 +4590,6 @@ bool Type_handler:: } -bool Type_handler:: - Item_longlong_typecast_fix_length_and_dec(Item_longlong_typecast *item) const -{ - item->fix_length_and_dec_generic(); - return false; -} - - #ifdef HAVE_SPATIAL bool Type_handler_geometry:: diff --git a/sql/sql_type.h b/sql/sql_type.h index 0738ef40ce8..db03b77d48f 100644 --- a/sql/sql_type.h +++ b/sql/sql_type.h @@ -55,7 +55,6 @@ class Item_char_typecast; class Item_time_typecast; class Item_date_typecast; class Item_datetime_typecast; -class Item_longlong_typecast; class Item_func_plus; class Item_func_minus; class Item_func_mul; @@ -1332,8 +1331,6 @@ public: Item_date_typecast_fix_length_and_dec(Item_date_typecast *item) const; virtual bool Item_datetime_typecast_fix_length_and_dec(Item_datetime_typecast *item) const; - virtual bool - Item_longlong_typecast_fix_length_and_dec(Item_longlong_typecast *item) const; virtual bool Item_func_plus_fix_length_and_dec(Item_func_plus *func) const= 0; diff --git a/sql/table.cc b/sql/table.cc index 4bc8cce7e31..7d3d7412ba5 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -8910,28 +8910,6 @@ void Vers_history_point::fix_item() item->decimals= 6; } -void Vers_history_point::add_typecast(THD *thd, enum vers_sys_type_t defunit) -{ - if (item) - { - if (!unit) - unit= defunit; - switch (unit) - { - case VERS_TIMESTAMP: - item= new (thd->mem_root) Item_datetime_from_unixtime_typecast( - thd, item, MAX_DATETIME_PRECISION); - break; - case VERS_TRX_ID: - item= new (thd->mem_root) Item_longlong_typecast(thd, item); - break; - default: - DBUG_ASSERT(0); - break; - } - } -} - void Vers_history_point::print(String *str, enum_query_type query_type, const char *prefix, size_t plen) { diff --git a/sql/table.h b/sql/table.h index f759ea221f5..b149bfc0f51 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1840,7 +1840,6 @@ public: void empty() { unit= VERS_UNDEFINED; item= NULL; } void print(String *str, enum_query_type, const char *prefix, size_t plen); void resolve_unit(bool timestamps_only); - void add_typecast(THD *thd, enum vers_sys_type_t defunit); }; struct vers_select_conds_t |