Skip to content

Commit

Permalink
Adding tests for MDEV-9406 CREATE TABLE..SELECT creates different col…
Browse files Browse the repository at this point in the history
…umns for IFNULL() and equivalent COALESCE,CASE,IF

Recent changes in Type_handler fixed this problem as well.
Adding tests only.
  • Loading branch information
Alexander Barkov committed May 27, 2017
1 parent 13c6b0d commit 86b5be0
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
35 changes: 35 additions & 0 deletions mysql-test/r/func_hybrid_type.result
Original file line number Diff line number Diff line change
Expand Up @@ -3571,5 +3571,40 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
#
# MDEV-9406 CREATE TABLE..SELECT creates different columns for IFNULL() and equivalent COALESCE,CASE,IF
#
CREATE TABLE t1 (a SMALLINT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 AS SELECT
IFNULL(a,a) AS c1,
COALESCE(a,a) AS c2,
CASE WHEN a IS NOT NULL THEN a ELSE a END AS c3,
IF(a IS NULL,a,a) AS c4 FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`c1` smallint(6) DEFAULT NULL,
`c2` smallint(6) DEFAULT NULL,
`c3` smallint(6) DEFAULT NULL,
`c4` smallint(6) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2,t1;
CREATE TABLE t1 AS SELECT
connection_id() AS c0,
IFNULL(connection_id(),connection_id()) AS c1,
COALESCE(connection_id(), connection_id()) AS c2,
CASE WHEN 0 THEN connection_id() ELSE connection_id() END AS c3,
IF(0,connection_id(),connection_id()) AS c4;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c0` int(10) NOT NULL,
`c1` int(10) NOT NULL,
`c2` int(10) NOT NULL,
`c3` int(10) NOT NULL,
`c4` int(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
#
# End of 10.3 tests
#
22 changes: 22 additions & 0 deletions mysql-test/t/func_hybrid_type.test
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,28 @@ SELECT * FROM t1;
SHOW CREATE TABLE t1;
DROP TABLE t1;

--echo #
--echo # MDEV-9406 CREATE TABLE..SELECT creates different columns for IFNULL() and equivalent COALESCE,CASE,IF
--echo #
CREATE TABLE t1 (a SMALLINT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 AS SELECT
IFNULL(a,a) AS c1,
COALESCE(a,a) AS c2,
CASE WHEN a IS NOT NULL THEN a ELSE a END AS c3,
IF(a IS NULL,a,a) AS c4 FROM t1;
SHOW CREATE TABLE t2;
DROP TABLE t2,t1;

CREATE TABLE t1 AS SELECT
connection_id() AS c0,
IFNULL(connection_id(),connection_id()) AS c1,
COALESCE(connection_id(), connection_id()) AS c2,
CASE WHEN 0 THEN connection_id() ELSE connection_id() END AS c3,
IF(0,connection_id(),connection_id()) AS c4;
SHOW CREATE TABLE t1;
DROP TABLE t1;

--echo #
--echo # End of 10.3 tests
--echo #
Expand Down

0 comments on commit 86b5be0

Please sign in to comment.