Commit feb15f4e authored by Alexander Barkov's avatar Alexander Barkov

MDEV-12860 Out-of-range error on CREATE..SELECT with a view using MAX and...

MDEV-12860 Out-of-range error on CREATE..SELECT with a view using MAX and EXTRACT(MINUTE_MICROSECOND..)
parent 8c479820
......@@ -3255,3 +3255,30 @@ a
10
DROP TABLE t2;
SET sql_mode=DEFAULT;
#
# MDEV-12860 Out-of-range error on CREATE..SELECT with a view using MAX and EXTRACT(MINUTE_MICROSECOND..)
#
SET sql_mode=STRICT_ALL_TABLES;
CREATE TABLE t1 (
id bigint(11) NOT NULL PRIMARY KEY,
dt datetime(6)
);
INSERT INTO t1 VALUES (1,'2001-01-01 11:22:33.123456');
CREATE OR REPLACE VIEW v1 AS SELECT EXTRACT(MINUTE_MICROSECOND FROM dt) AS dt2 FROM t1;
DESCRIBE v1;
Field Type Null Key Default Extra
dt2 bigint(11) YES NULL
SELECT * FROM v1;
dt2
2233123456
CREATE TABLE t2 AS SELECT MAX(dt2) FROM v1;
DESCRIBE t2;
Field Type Null Key Default Extra
MAX(dt2) bigint(11) YES NULL
SELECT * FROM t2;
MAX(dt2)
2233123456
DROP TABLE t2;
DROP VIEW v1;
DROP TABLE t1;
SET sql_mode=DEFAULT;
......@@ -1849,3 +1849,25 @@ SELECT * FROM t2;
DROP TABLE t2;
SET sql_mode=DEFAULT;
--echo #
--echo # MDEV-12860 Out-of-range error on CREATE..SELECT with a view using MAX and EXTRACT(MINUTE_MICROSECOND..)
--echo #
SET sql_mode=STRICT_ALL_TABLES;
CREATE TABLE t1 (
id bigint(11) NOT NULL PRIMARY KEY,
dt datetime(6)
);
INSERT INTO t1 VALUES (1,'2001-01-01 11:22:33.123456');
CREATE OR REPLACE VIEW v1 AS SELECT EXTRACT(MINUTE_MICROSECOND FROM dt) AS dt2 FROM t1;
DESCRIBE v1;
SELECT * FROM v1;
CREATE TABLE t2 AS SELECT MAX(dt2) FROM v1;
DESCRIBE t2;
SELECT * FROM t2;
DROP TABLE t2;
DROP VIEW v1;
DROP TABLE t1;
SET sql_mode=DEFAULT;
......@@ -1210,7 +1210,7 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table)
field->flags&= ~NOT_NULL_FLAG;
return field;
}
return Item_sum::create_tmp_field(group, table);
return tmp_table_field_from_field_type(table);
}
......
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