diff options
author | Alexander Barkov <bar@mariadb.org> | 2016-07-03 13:52:06 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2016-07-03 13:52:06 +0400 |
commit | 1ec91803aca76c999d34d9f17938b976093cb67a (patch) | |
tree | 026fbfd1746e0aa432b42bacbc887defa454a5f7 /sql/item_timefunc.h | |
parent | 3ccf8218bc03a9cc598cd2da5c5a98ea2412cc05 (diff) | |
download | mariadb-git-1ec91803aca76c999d34d9f17938b976093cb67a.tar.gz |
MDEV-10317 EXCTACT(MINUTE_MICROSECOND) truncates data
Diffstat (limited to 'sql/item_timefunc.h')
-rw-r--r-- | sql/item_timefunc.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 2c1a0943699..0e9329d501c 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -835,10 +835,57 @@ public: class Item_extract :public Item_int_func { bool date_value; + void set_date_length(uint32 length) + { + /* + Although DATE components (e.g. YEAR, YEAR_MONTH, QUARTER, MONTH, WEEK) + cannot have a sign, we should probably still add +1, + because all around the code we assume that max_length is sign inclusive. + Another options is to set unsigned_flag to "true". + */ + max_length= length; //QQ: see above + date_value= true; + } + void set_time_length(uint32 length) + { + max_length= length + 1/*sign*/; + date_value= false; + } public: const interval_type int_type; // keep it public Item_extract(THD *thd, interval_type type_arg, Item *a): Item_int_func(thd, a), int_type(type_arg) {} + enum_field_types field_type() const + { + switch (int_type) { + case INTERVAL_YEAR: + case INTERVAL_YEAR_MONTH: + case INTERVAL_QUARTER: + case INTERVAL_MONTH: + case INTERVAL_WEEK: + case INTERVAL_DAY: + case INTERVAL_DAY_HOUR: + case INTERVAL_DAY_MINUTE: + case INTERVAL_DAY_SECOND: + case INTERVAL_HOUR: + case INTERVAL_HOUR_MINUTE: + case INTERVAL_HOUR_SECOND: + case INTERVAL_MINUTE: + case INTERVAL_MINUTE_SECOND: + case INTERVAL_SECOND: + case INTERVAL_MICROSECOND: + case INTERVAL_SECOND_MICROSECOND: + return MYSQL_TYPE_LONG; + case INTERVAL_DAY_MICROSECOND: + case INTERVAL_HOUR_MICROSECOND: + case INTERVAL_MINUTE_MICROSECOND: + return MYSQL_TYPE_LONGLONG; + case INTERVAL_LAST: + break; + } + DBUG_ASSERT(0); + return MYSQL_TYPE_LONGLONG; + } longlong val_int(); enum Functype functype() const { return EXTRACT_FUNC; } const char *func_name() const { return "extract"; } @@ -883,6 +930,8 @@ class Item_extract :public Item_int_func } return true; } + Field *create_field_for_create_select(TABLE *table) + { return tmp_table_field_from_field_type(table, false, false); } }; |