mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
Merge from 5.3
pending merges: Alexander Barkov 2013-09-16 MDEV-4870 Wrong values of CASE, COALESCE, IF...
This commit is contained in:
commit
6a5f07ee87
2 changed files with 74 additions and 0 deletions
|
@ -2060,6 +2060,56 @@ t1 CREATE TABLE `t1` (
|
|||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-4870 Wrong values of CASE, COALESCE, IFNULL on a combination of different temporal types
|
||||
#
|
||||
CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE);
|
||||
INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01');
|
||||
SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1;
|
||||
CASE WHEN 0 THEN dt2 ELSE t3 END
|
||||
0000-00-00 00:00:00.567
|
||||
CREATE TABLE t2 AS SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1;
|
||||
SELECT * FROM t2;
|
||||
CASE WHEN 0 THEN dt2 ELSE t3 END
|
||||
0000-00-00 00:00:00.567
|
||||
SHOW COLUMNS FROM t2;
|
||||
Field Type Null Key Default Extra
|
||||
CASE WHEN 0 THEN dt2 ELSE t3 END datetime(3) YES NULL
|
||||
DROP TABLE t2;
|
||||
SELECT CASE WHEN 1 THEN dt2 ELSE t3 END FROM t1;
|
||||
CASE WHEN 1 THEN dt2 ELSE t3 END
|
||||
2001-01-01 00:00:00.120
|
||||
SELECT CONCAT(CASE WHEN 1 THEN dt2 ELSE t3 END) FROM t1;
|
||||
CONCAT(CASE WHEN 1 THEN dt2 ELSE t3 END)
|
||||
2001-01-01 00:00:00.120
|
||||
SELECT CONCAT(CASE WHEN 0 THEN t3 ELSE dt2 END) FROM t1;
|
||||
CONCAT(CASE WHEN 0 THEN t3 ELSE dt2 END)
|
||||
2001-01-01 00:00:00.120
|
||||
SELECT CONCAT(CASE WHEN 1 THEN d ELSE t3 END) FROM t1;
|
||||
CONCAT(CASE WHEN 1 THEN d ELSE t3 END)
|
||||
2002-01-01 00:00:00.000
|
||||
SELECT CASE WHEN 1 THEN t3 ELSE d END FROM t1;
|
||||
CASE WHEN 1 THEN t3 ELSE d END
|
||||
0000-00-00 00:00:00.567
|
||||
SELECT COALESCE(d, t3) FROM t1;
|
||||
COALESCE(d, t3)
|
||||
2002-01-01 00:00:00.000
|
||||
SELECT CONCAT(COALESCE(d, t3)) FROM t1;
|
||||
CONCAT(COALESCE(d, t3))
|
||||
2002-01-01 00:00:00.000
|
||||
SELECT COALESCE(dt2, t3) FROM t1;
|
||||
COALESCE(dt2, t3)
|
||||
2001-01-01 00:00:00.120
|
||||
SELECT CONCAT(COALESCE(dt2, t3)) FROM t1;
|
||||
CONCAT(COALESCE(dt2, t3))
|
||||
2001-01-01 00:00:00.120
|
||||
SELECT IFNULL(dt2, t3), CONCAT(IFNULL(dt2, t3)) FROM t1;
|
||||
IFNULL(dt2, t3) CONCAT(IFNULL(dt2, t3))
|
||||
2001-01-01 00:00:00.120 2001-01-01 00:00:00.120
|
||||
SELECT IFNULL(d, t3), CONCAT(IFNULL(d, t3)) FROM t1;
|
||||
IFNULL(d, t3) CONCAT(IFNULL(d, t3))
|
||||
2002-01-01 00:00:00.000 2002-01-01 00:00:00.000
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-4724 Some temporal functions do not preserve microseconds
|
||||
#
|
||||
SELECT MAKETIME(10,10,10.231);
|
||||
|
|
|
@ -1287,6 +1287,30 @@ SHOW CREATE TABLE t1;
|
|||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-4870 Wrong values of CASE, COALESCE, IFNULL on a combination of different temporal types
|
||||
--echo #
|
||||
CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE);
|
||||
INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01');
|
||||
SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1;
|
||||
CREATE TABLE t2 AS SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1;
|
||||
SELECT * FROM t2;
|
||||
SHOW COLUMNS FROM t2;
|
||||
DROP TABLE t2;
|
||||
SELECT CASE WHEN 1 THEN dt2 ELSE t3 END FROM t1;
|
||||
SELECT CONCAT(CASE WHEN 1 THEN dt2 ELSE t3 END) FROM t1;
|
||||
SELECT CONCAT(CASE WHEN 0 THEN t3 ELSE dt2 END) FROM t1;
|
||||
SELECT CONCAT(CASE WHEN 1 THEN d ELSE t3 END) FROM t1;
|
||||
SELECT CASE WHEN 1 THEN t3 ELSE d END FROM t1;
|
||||
SELECT COALESCE(d, t3) FROM t1;
|
||||
SELECT CONCAT(COALESCE(d, t3)) FROM t1;
|
||||
SELECT COALESCE(dt2, t3) FROM t1;
|
||||
SELECT CONCAT(COALESCE(dt2, t3)) FROM t1;
|
||||
SELECT IFNULL(dt2, t3), CONCAT(IFNULL(dt2, t3)) FROM t1;
|
||||
SELECT IFNULL(d, t3), CONCAT(IFNULL(d, t3)) FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-4724 Some temporal functions do not preserve microseconds
|
||||
--echo #
|
||||
|
|
Loading…
Add table
Reference in a new issue