summaryrefslogtreecommitdiff
path: root/mysql-test/t/win.test
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <vicentiu@mariadb.org>2017-09-11 12:03:16 +0300
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2017-09-19 15:14:10 +0300
commit02eda36e4e75170b2cf228f65faf3c32ede83626 (patch)
treebc61c87ecc6220aea125cbb482ac40fd7dd51cac /mysql-test/t/win.test
parent5b9c32ede096e19d751537c6421563a7fb71c0db (diff)
downloadmariadb-git-02eda36e4e75170b2cf228f65faf3c32ede83626.tar.gz
MDEV-13358: FIRST_V throw SQL Fehler (1292): Incorrect datetime value
This is backport of 25ad623d64e for 10.2. The issue is similar to the one from MDEV-13240. Item::save_in_field() returns an error during tmp table population in a create table from select query as we try to save an empty string as a date value when force_return_blank is set to true for window functions. MDEV-13240 Wrong warning with MAX(datetime_field) OVER (...) The problem resided in Item_window_func implementation, and it was revealed by bb-10.2-ext specific changes: Item_window_func::save_in_field() works differently in bb-10.2-ext vs 10.2: - 10.2 goes through val_str() - bb-10.2-ext goes through get_date(), due to Type_handler related changes. get_date() tries to convert empty string to DATETIME, hence the warning. During a discussion with Vicentiu, it was decided to fix Item_window_func::val_xxx() to return NULL (instead of an "empty" value, such as 0 for numbers and '' for strings) when force_return_blank is set.
Diffstat (limited to 'mysql-test/t/win.test')
-rw-r--r--mysql-test/t/win.test28
1 files changed, 28 insertions, 0 deletions
diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test
index 3dedc1227fd..83427e4edf8 100644
--- a/mysql-test/t/win.test
+++ b/mysql-test/t/win.test
@@ -1965,3 +1965,31 @@ INSERT INTO t1 VALUES (1),(2);
SELECT i AS fld FROM t1 UNION SELECT COUNT(*) AS fld FROM t1;
DROP TABLE t1;
+--echo #
+--echo # MDEV-13240 Wrong warning with MAX(datetime_field) OVER (...)
+--echo #
+
+CREATE TABLE t1 (dt DATETIME);
+INSERT INTO t1 VALUES ('2017-05-17');
+SELECT MAX(dt) OVER (ORDER BY dt ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING) FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-13358 FIRST_VALUE throws SQL Error (1292): Incorrect datetime value
+--echo #
+CREATE TABLE IF NOT EXISTS `fv_test` (
+ `SOME_DATE` datetime NOT NULL
+ );
+
+INSERT INTO `fv_test` (`SOME_DATE`) VALUES ('2017-07-20 12:47:56');
+
+CREATE TABLE fv_result
+SELECT
+FIRST_VALUE(SOME_DATE) OVER(ORDER BY SOME_DATE DESC) AS somedate
+FROM fv_test;
+
+SHOW CREATE TABLE fv_result;
+
+SELECT * FROM fv_result;
+
+DROP TABLE fv_test, fv_result;