Commit 9b79888d authored by Alexander Barkov's avatar Alexander Barkov

MDEV-12866 Out-of-range error with CREATE..SELECT..TO_SECONDS(NOW())

parent c84bbeda
......@@ -3282,3 +3282,15 @@ DROP TABLE t2;
DROP VIEW v1;
DROP TABLE t1;
SET sql_mode=DEFAULT;
#
# MDEV-12866 Out-of-range error with CREATE..SELECT..TO_SECONDS(NOW())
#
SET sql_mode=STRICT_ALL_TABLES;
CREATE TABLE t1 AS SELECT TO_SECONDS('9999-12-31 23:59:59');
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`TO_SECONDS('9999-12-31 23:59:59')` bigint(12) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
SET sql_mode=DEFAULT;
......@@ -476,7 +476,7 @@ def PERIOD_DIFF(200802,200703) 3 6 2 N 32897 0 63
def TO_DAYS('2007-10-07') 3 6 6 Y 32896 0 63
def DAYOFMONTH('2007-02-03') 3 2 1 Y 32896 0 63
def DAYOFWEEK('2007-02-03') 3 1 1 Y 32896 0 63
def TO_SECONDS('2013-06-13') 3 6 11 Y 32896 0 63
def TO_SECONDS('2013-06-13') 8 12 11 Y 32896 0 63
PERIOD_ADD(200801,2) PERIOD_DIFF(200802,200703) TO_DAYS('2007-10-07') DAYOFMONTH('2007-02-03') DAYOFWEEK('2007-02-03') TO_SECONDS('2013-06-13')
200803 11 733321 3 7 63538300800
SELECT
......
......@@ -542,7 +542,7 @@ create table t1 as select to_seconds(null) as to_seconds;
select data_type from information_schema.columns
where table_schema='test' and column_name='to_seconds';
data_type
int
bigint
drop table t1;
create table t1 (a int, b int)
partition by list columns(a,b)
......
......@@ -1871,3 +1871,12 @@ DROP TABLE t2;
DROP VIEW v1;
DROP TABLE t1;
SET sql_mode=DEFAULT;
--echo #
--echo # MDEV-12866 Out-of-range error with CREATE..SELECT..TO_SECONDS(NOW())
--echo #
SET sql_mode=STRICT_ALL_TABLES;
CREATE TABLE t1 AS SELECT TO_SECONDS('9999-12-31 23:59:59');
SHOW CREATE TABLE t1;
DROP TABLE t1;
SET sql_mode=DEFAULT;
......@@ -89,16 +89,16 @@ class Item_func_to_days :public Item_long_func
};
class Item_func_to_seconds :public Item_long_func
class Item_func_to_seconds :public Item_longlong_func
{
public:
Item_func_to_seconds(THD *thd, Item *a): Item_long_func(thd, a) {}
Item_func_to_seconds(THD *thd, Item *a): Item_longlong_func(thd, a) {}
longlong val_int();
const char *func_name() const { return "to_seconds"; }
void fix_length_and_dec()
{
decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
fix_char_length(12);
maybe_null= 1;
}
enum_monotonicity_info get_monotonicity_info() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment