Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
969f4918
Commit
969f4918
authored
Nov 20, 2014
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-7005 NULLIF does not work as documented
MDEV-7146 NULLIF returns unexpected result with a YEAR field
parent
9f4abde6
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1595 additions
and
62 deletions
+1595
-62
mysql-test/r/ctype_binary.result
mysql-test/r/ctype_binary.result
+1
-1
mysql-test/r/ctype_cp1251.result
mysql-test/r/ctype_cp1251.result
+1
-1
mysql-test/r/ctype_latin1.result
mysql-test/r/ctype_latin1.result
+1
-1
mysql-test/r/ctype_ucs.result
mysql-test/r/ctype_ucs.result
+1
-1
mysql-test/r/ctype_utf8.result
mysql-test/r/ctype_utf8.result
+1
-1
mysql-test/r/null.result
mysql-test/r/null.result
+959
-1
mysql-test/t/null.test
mysql-test/t/null.test
+545
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+66
-47
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+19
-9
sql/item_func.h
sql/item_func.h
+1
-0
No files found.
mysql-test/r/ctype_binary.result
View file @
969f4918
...
...
@@ -2900,7 +2900,7 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`d` date DEFAULT NULL,
`bad`
varbinary(10)
DEFAULT NULL
`bad`
date
DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1, t2;
SET NAMES latin1;
...
...
mysql-test/r/ctype_cp1251.result
View file @
969f4918
...
...
@@ -3292,7 +3292,7 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`d` date DEFAULT NULL,
`bad`
varchar(10) CHARACTER SET cp1251
DEFAULT NULL
`bad`
date
DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1, t2;
SET NAMES latin1;
...
...
mysql-test/r/ctype_latin1.result
View file @
969f4918
...
...
@@ -3576,7 +3576,7 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`d` date DEFAULT NULL,
`bad`
varchar(10)
DEFAULT NULL
`bad`
date
DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1, t2;
SET NAMES latin1;
...
...
mysql-test/r/ctype_ucs.result
View file @
969f4918
...
...
@@ -4483,7 +4483,7 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`d` date DEFAULT NULL,
`bad`
varchar(10) CHARACTER SET ucs2
DEFAULT NULL
`bad`
date
DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1, t2;
SET NAMES latin1;
...
...
mysql-test/r/ctype_utf8.result
View file @
969f4918
...
...
@@ -5351,7 +5351,7 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`d` date DEFAULT NULL,
`bad`
varchar(10) CHARACTER SET utf8
DEFAULT NULL
`bad`
date
DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1, t2;
SET NAMES latin1;
...
...
mysql-test/r/null.result
View file @
969f4918
...
...
@@ -241,7 +241,7 @@ t1 CREATE TABLE `t1` (
`c11` varchar(6) CHARACTER SET latin2 DEFAULT NULL,
`c12` varchar(6) CHARACTER SET latin2 DEFAULT NULL,
`c13` varchar(6) CHARACTER SET latin2 DEFAULT NULL,
`c14`
char(0) CHARACTER SET latin2
DEFAULT NULL,
`c14`
binary(0)
DEFAULT NULL,
`c15` char(0) CHARACTER SET latin2 DEFAULT NULL,
`c16` varchar(6) CHARACTER SET latin2 DEFAULT NULL,
`c17` varchar(6) CHARACTER SET latin2 DEFAULT NULL,
...
...
@@ -382,3 +382,961 @@ CREATE TABLE t2 (d DATE) ENGINE=MyISAM;
SELECT * FROM t1,t2 WHERE 1 IS NOT NULL AND t1.b IS NULL;
a b c d
DROP TABLE t1,t2;
#
# Start of 10.1 tests
#
#
# MDEV-7146 NULLIF returns unexpected result with a YEAR field
#
CREATE TABLE t1 (a YEAR(2));
Warnings:
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
INSERT INTO t1 VALUES (0);
SELECT a,NULLIF(a,2000),NULLIF(2000,a) FROM t1;
a NULLIF(a,2000) NULLIF(2000,a)
00 NULL NULL
SELECT a,NULLIF(a,2001),NULLIF(2001,a) FROM t1;
a NULLIF(a,2001) NULLIF(2001,a)
00 0 2001
DROP TABLE t1;
#
# MDEV-7005 NULLIF does not work as documented
#
CREATE TABLE t1 (a TIME);
CREATE TABLE t2 AS SELECT a,NULLIF(a,a), CASE WHEN a=a THEN NULL ELSE a END FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` time DEFAULT NULL,
`NULLIF(a,a)` time DEFAULT NULL,
`CASE WHEN a=a THEN NULL ELSE a END` time DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1,t2;
SELECT NULLIF(_latin1'a' COLLATE latin1_general_ci, _latin1'a' COLLATE latin1_bin);
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'nullif'
CREATE TABLE t1 AS SELECT
NULLIF(1,1),
NULLIF(1,1.0),
NULLIF(1,1e0),
NULLIF(1,'2001-01-01'),
NULLIF(1,TIME'00:00:00');
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '2001-01-01'
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`NULLIF(1,1)` int(1) DEFAULT NULL,
`NULLIF(1,1.0)` int(1) DEFAULT NULL,
`NULLIF(1,1e0)` int(1) DEFAULT NULL,
`NULLIF(1,'2001-01-01')` int(1) DEFAULT NULL,
`NULLIF(1,TIME'00:00:00')` int(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 AS SELECT
NULLIF(1.0,1),
NULLIF(1.0,1.0),
NULLIF(1.0,1e0),
NULLIF(1.0,'2001-01-01'),
NULLIF(1.0,TIME'00:00:00');
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '2001-01-01'
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`NULLIF(1.0,1)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0,1.0)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0,1e0)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0,'2001-01-01')` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0,TIME'00:00:00')` decimal(2,1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 AS SELECT
NULLIF(1e0,1),
NULLIF(1e0,1.0),
NULLIF(1e0,1e0),
NULLIF(1e0,'2001-01-01'),
NULLIF(1e0,TIME'00:00:00');
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '2001-01-01'
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`NULLIF(1e0,1)` double DEFAULT NULL,
`NULLIF(1e0,1.0)` double DEFAULT NULL,
`NULLIF(1e0,1e0)` double DEFAULT NULL,
`NULLIF(1e0,'2001-01-01')` double DEFAULT NULL,
`NULLIF(1e0,TIME'00:00:00')` double DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 AS SELECT
NULLIF('1',1),
NULLIF('1',1.0),
NULLIF('1',1e0),
NULLIF('1','2001-01-01'),
NULLIF('1',TIME'00:00:00');
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`NULLIF('1',1)` varchar(1) DEFAULT NULL,
`NULLIF('1',1.0)` varchar(1) DEFAULT NULL,
`NULLIF('1',1e0)` varchar(1) DEFAULT NULL,
`NULLIF('1','2001-01-01')` varchar(1) DEFAULT NULL,
`NULLIF('1',TIME'00:00:00')` varchar(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 AS SELECT
NULLIF(TIMESTAMP'2001-01-01 00:00:00',1),
NULLIF(TIMESTAMP'2001-01-01 00:00:00',1.0),
NULLIF(TIMESTAMP'2001-01-01 00:00:00',1e0),
NULLIF(TIMESTAMP'2001-01-01 00:00:00','2001-01-01'),
NULLIF(TIMESTAMP'2001-01-01 00:00:00',TIME'00:00:00');
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`NULLIF(TIMESTAMP'2001-01-01 00:00:00',1)` datetime DEFAULT NULL,
`NULLIF(TIMESTAMP'2001-01-01 00:00:00',1.0)` datetime DEFAULT NULL,
`NULLIF(TIMESTAMP'2001-01-01 00:00:00',1e0)` datetime DEFAULT NULL,
`NULLIF(TIMESTAMP'2001-01-01 00:00:00','2001-01-01')` datetime DEFAULT NULL,
`NULLIF(TIMESTAMP'2001-01-01 00:00:00',TIME'00:00:00')` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 AS SELECT
NULLIF(DATE'2001-01-01',1),
NULLIF(DATE'2001-01-01',1.0),
NULLIF(DATE'2001-01-01',1e0),
NULLIF(DATE'2001-01-01','2001-01-01'),
NULLIF(DATE'2001-01-01',TIME'00:00:00');
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`NULLIF(DATE'2001-01-01',1)` date DEFAULT NULL,
`NULLIF(DATE'2001-01-01',1.0)` date DEFAULT NULL,
`NULLIF(DATE'2001-01-01',1e0)` date DEFAULT NULL,
`NULLIF(DATE'2001-01-01','2001-01-01')` date DEFAULT NULL,
`NULLIF(DATE'2001-01-01',TIME'00:00:00')` date DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 AS SELECT
NULLIF(TIME'00:00:01',1),
NULLIF(TIME'00:00:01',1.0),
NULLIF(TIME'00:00:01',1e0),
NULLIF(TIME'00:00:01','00:00:00'),
NULLIF(TIME'00:00:01',DATE'2001-01-01');
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`NULLIF(TIME'00:00:01',1)` time DEFAULT NULL,
`NULLIF(TIME'00:00:01',1.0)` time DEFAULT NULL,
`NULLIF(TIME'00:00:01',1e0)` time DEFAULT NULL,
`NULLIF(TIME'00:00:01','00:00:00')` time DEFAULT NULL,
`NULLIF(TIME'00:00:01',DATE'2001-01-01')` time DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1
(
c_tinyint TINYINT,
c_smallint SMALLINT,
c_int INT,
c_bigint BIGINT,
c_float FLOAT,
c_double DOUBLE,
c_decimal103 DECIMAL(10,3),
c_varchar10 VARCHAR(10),
c_text TEXT,
c_blob BLOB,
c_enum ENUM('one','two','tree'),
c_datetime3 DATETIME(3),
c_timestamp3 TIMESTAMP(3),
c_date DATE,
c_time TIME
);
#
# Checking that the return type depends only on args[0], even when compared to a super type
#
CREATE TABLE t2 AS SELECT
NULLIF(c_tinyint, 1),
NULLIF(c_tinyint, c_smallint),
NULLIF(c_tinyint, c_tinyint),
NULLIF(c_tinyint, c_int),
NULLIF(c_tinyint, c_bigint),
NULLIF(c_tinyint, c_float),
NULLIF(c_tinyint, c_double),
NULLIF(c_tinyint, c_decimal103),
NULLIF(c_tinyint, c_varchar10),
NULLIF(c_tinyint, c_text),
NULLIF(c_tinyint, c_blob),
NULLIF(c_tinyint, c_enum),
NULLIF(c_tinyint, c_datetime3),
NULLIF(c_tinyint, c_timestamp3),
NULLIF(c_tinyint, c_date),
NULLIF(c_tinyint, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_tinyint, 1)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_smallint)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_tinyint)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_int)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_bigint)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_float)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_double)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_decimal103)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_varchar10)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_text)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_blob)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_enum)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_datetime3)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_timestamp3)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_date)` int(4) DEFAULT NULL,
`NULLIF(c_tinyint, c_time)` int(4) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(c_smallint, 1),
NULLIF(c_smallint, c_smallint),
NULLIF(c_smallint, c_tinyint),
NULLIF(c_smallint, c_int),
NULLIF(c_smallint, c_bigint),
NULLIF(c_smallint, c_float),
NULLIF(c_smallint, c_double),
NULLIF(c_smallint, c_decimal103),
NULLIF(c_smallint, c_varchar10),
NULLIF(c_smallint, c_text),
NULLIF(c_smallint, c_blob),
NULLIF(c_smallint, c_enum),
NULLIF(c_smallint, c_datetime3),
NULLIF(c_smallint, c_timestamp3),
NULLIF(c_smallint, c_date),
NULLIF(c_smallint, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_smallint, 1)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_smallint)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_tinyint)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_int)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_bigint)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_float)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_double)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_decimal103)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_varchar10)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_text)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_blob)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_enum)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_datetime3)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_timestamp3)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_date)` int(6) DEFAULT NULL,
`NULLIF(c_smallint, c_time)` int(6) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(c_int, 1),
NULLIF(c_int, c_smallint),
NULLIF(c_int, c_tinyint),
NULLIF(c_int, c_int),
NULLIF(c_int, c_bigint),
NULLIF(c_int, c_float),
NULLIF(c_int, c_double),
NULLIF(c_int, c_decimal103),
NULLIF(c_int, c_varchar10),
NULLIF(c_int, c_text),
NULLIF(c_int, c_blob),
NULLIF(c_int, c_enum),
NULLIF(c_int, c_datetime3),
NULLIF(c_int, c_timestamp3),
NULLIF(c_int, c_date),
NULLIF(c_int, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_int, 1)` int(11) DEFAULT NULL,
`NULLIF(c_int, c_smallint)` int(11) DEFAULT NULL,
`NULLIF(c_int, c_tinyint)` int(11) DEFAULT NULL,
`NULLIF(c_int, c_int)` int(11) DEFAULT NULL,
`NULLIF(c_int, c_bigint)` int(11) DEFAULT NULL,
`NULLIF(c_int, c_float)` int(11) DEFAULT NULL,
`NULLIF(c_int, c_double)` int(11) DEFAULT NULL,
`NULLIF(c_int, c_decimal103)` int(11) DEFAULT NULL,
`NULLIF(c_int, c_varchar10)` int(11) DEFAULT NULL,
`NULLIF(c_int, c_text)` int(11) DEFAULT NULL,
`NULLIF(c_int, c_blob)` int(11) DEFAULT NULL,
`NULLIF(c_int, c_enum)` int(11) DEFAULT NULL,
`NULLIF(c_int, c_datetime3)` int(11) DEFAULT NULL,
`NULLIF(c_int, c_timestamp3)` int(11) DEFAULT NULL,
`NULLIF(c_int, c_date)` int(11) DEFAULT NULL,
`NULLIF(c_int, c_time)` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(c_bigint, 1),
NULLIF(c_bigint, c_smallint),
NULLIF(c_bigint, c_tinyint),
NULLIF(c_bigint, c_int),
NULLIF(c_bigint, c_bigint),
NULLIF(c_bigint, c_float),
NULLIF(c_bigint, c_double),
NULLIF(c_bigint, c_decimal103),
NULLIF(c_bigint, c_varchar10),
NULLIF(c_bigint, c_text),
NULLIF(c_bigint, c_blob),
NULLIF(c_bigint, c_enum),
NULLIF(c_bigint, c_datetime3),
NULLIF(c_bigint, c_timestamp3),
NULLIF(c_bigint, c_date),
NULLIF(c_bigint, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_bigint, 1)` bigint(20) DEFAULT NULL,
`NULLIF(c_bigint, c_smallint)` bigint(20) DEFAULT NULL,
`NULLIF(c_bigint, c_tinyint)` bigint(20) DEFAULT NULL,
`NULLIF(c_bigint, c_int)` bigint(20) DEFAULT NULL,
`NULLIF(c_bigint, c_bigint)` bigint(20) DEFAULT NULL,
`NULLIF(c_bigint, c_float)` bigint(20) DEFAULT NULL,
`NULLIF(c_bigint, c_double)` bigint(20) DEFAULT NULL,
`NULLIF(c_bigint, c_decimal103)` bigint(20) DEFAULT NULL,
`NULLIF(c_bigint, c_varchar10)` bigint(20) DEFAULT NULL,
`NULLIF(c_bigint, c_text)` bigint(20) DEFAULT NULL,
`NULLIF(c_bigint, c_blob)` bigint(20) DEFAULT NULL,
`NULLIF(c_bigint, c_enum)` bigint(20) DEFAULT NULL,
`NULLIF(c_bigint, c_datetime3)` bigint(20) DEFAULT NULL,
`NULLIF(c_bigint, c_timestamp3)` bigint(20) DEFAULT NULL,
`NULLIF(c_bigint, c_date)` bigint(20) DEFAULT NULL,
`NULLIF(c_bigint, c_time)` bigint(20) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(c_float, 1),
NULLIF(c_float, c_smallint),
NULLIF(c_float, c_tinyint),
NULLIF(c_float, c_int),
NULLIF(c_float, c_bigint),
NULLIF(c_float, c_float),
NULLIF(c_float, c_double),
NULLIF(c_float, c_decimal103),
NULLIF(c_float, c_varchar10),
NULLIF(c_float, c_text),
NULLIF(c_float, c_blob),
NULLIF(c_float, c_enum),
NULLIF(c_float, c_datetime3),
NULLIF(c_float, c_timestamp3),
NULLIF(c_float, c_date),
NULLIF(c_float, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_float, 1)` double DEFAULT NULL,
`NULLIF(c_float, c_smallint)` double DEFAULT NULL,
`NULLIF(c_float, c_tinyint)` double DEFAULT NULL,
`NULLIF(c_float, c_int)` double DEFAULT NULL,
`NULLIF(c_float, c_bigint)` double DEFAULT NULL,
`NULLIF(c_float, c_float)` double DEFAULT NULL,
`NULLIF(c_float, c_double)` double DEFAULT NULL,
`NULLIF(c_float, c_decimal103)` double DEFAULT NULL,
`NULLIF(c_float, c_varchar10)` double DEFAULT NULL,
`NULLIF(c_float, c_text)` double DEFAULT NULL,
`NULLIF(c_float, c_blob)` double DEFAULT NULL,
`NULLIF(c_float, c_enum)` double DEFAULT NULL,
`NULLIF(c_float, c_datetime3)` double DEFAULT NULL,
`NULLIF(c_float, c_timestamp3)` double DEFAULT NULL,
`NULLIF(c_float, c_date)` double DEFAULT NULL,
`NULLIF(c_float, c_time)` double DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(c_double, 1),
NULLIF(c_double, c_smallint),
NULLIF(c_double, c_tinyint),
NULLIF(c_double, c_int),
NULLIF(c_double, c_bigint),
NULLIF(c_double, c_float),
NULLIF(c_double, c_double),
NULLIF(c_double, c_decimal103),
NULLIF(c_double, c_varchar10),
NULLIF(c_double, c_text),
NULLIF(c_double, c_blob),
NULLIF(c_double, c_enum),
NULLIF(c_double, c_datetime3),
NULLIF(c_double, c_timestamp3),
NULLIF(c_double, c_date),
NULLIF(c_double, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_double, 1)` double DEFAULT NULL,
`NULLIF(c_double, c_smallint)` double DEFAULT NULL,
`NULLIF(c_double, c_tinyint)` double DEFAULT NULL,
`NULLIF(c_double, c_int)` double DEFAULT NULL,
`NULLIF(c_double, c_bigint)` double DEFAULT NULL,
`NULLIF(c_double, c_float)` double DEFAULT NULL,
`NULLIF(c_double, c_double)` double DEFAULT NULL,
`NULLIF(c_double, c_decimal103)` double DEFAULT NULL,
`NULLIF(c_double, c_varchar10)` double DEFAULT NULL,
`NULLIF(c_double, c_text)` double DEFAULT NULL,
`NULLIF(c_double, c_blob)` double DEFAULT NULL,
`NULLIF(c_double, c_enum)` double DEFAULT NULL,
`NULLIF(c_double, c_datetime3)` double DEFAULT NULL,
`NULLIF(c_double, c_timestamp3)` double DEFAULT NULL,
`NULLIF(c_double, c_date)` double DEFAULT NULL,
`NULLIF(c_double, c_time)` double DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(c_decimal103, 1),
NULLIF(c_decimal103, c_smallint),
NULLIF(c_decimal103, c_tinyint),
NULLIF(c_decimal103, c_int),
NULLIF(c_decimal103, c_bigint),
NULLIF(c_decimal103, c_float),
NULLIF(c_decimal103, c_double),
NULLIF(c_decimal103, c_decimal103),
NULLIF(c_decimal103, c_varchar10),
NULLIF(c_decimal103, c_text),
NULLIF(c_decimal103, c_blob),
NULLIF(c_decimal103, c_enum),
NULLIF(c_decimal103, c_datetime3),
NULLIF(c_decimal103, c_timestamp3),
NULLIF(c_decimal103, c_date),
NULLIF(c_decimal103, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_decimal103, 1)` decimal(10,3) DEFAULT NULL,
`NULLIF(c_decimal103, c_smallint)` decimal(10,3) DEFAULT NULL,
`NULLIF(c_decimal103, c_tinyint)` decimal(10,3) DEFAULT NULL,
`NULLIF(c_decimal103, c_int)` decimal(10,3) DEFAULT NULL,
`NULLIF(c_decimal103, c_bigint)` decimal(10,3) DEFAULT NULL,
`NULLIF(c_decimal103, c_float)` decimal(10,3) DEFAULT NULL,
`NULLIF(c_decimal103, c_double)` decimal(10,3) DEFAULT NULL,
`NULLIF(c_decimal103, c_decimal103)` decimal(10,3) DEFAULT NULL,
`NULLIF(c_decimal103, c_varchar10)` decimal(10,3) DEFAULT NULL,
`NULLIF(c_decimal103, c_text)` decimal(10,3) DEFAULT NULL,
`NULLIF(c_decimal103, c_blob)` decimal(10,3) DEFAULT NULL,
`NULLIF(c_decimal103, c_enum)` decimal(10,3) DEFAULT NULL,
`NULLIF(c_decimal103, c_datetime3)` decimal(10,3) DEFAULT NULL,
`NULLIF(c_decimal103, c_timestamp3)` decimal(10,3) DEFAULT NULL,
`NULLIF(c_decimal103, c_date)` decimal(10,3) DEFAULT NULL,
`NULLIF(c_decimal103, c_time)` decimal(10,3) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(c_varchar10, 1),
NULLIF(c_varchar10, c_smallint),
NULLIF(c_varchar10, c_tinyint),
NULLIF(c_varchar10, c_int),
NULLIF(c_varchar10, c_bigint),
NULLIF(c_varchar10, c_float),
NULLIF(c_varchar10, c_double),
NULLIF(c_varchar10, c_decimal103),
NULLIF(c_varchar10, c_varchar10),
NULLIF(c_varchar10, c_text),
NULLIF(c_varchar10, c_blob),
NULLIF(c_varchar10, c_enum),
NULLIF(c_varchar10, c_datetime3),
NULLIF(c_varchar10, c_timestamp3),
NULLIF(c_varchar10, c_date),
NULLIF(c_varchar10, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_varchar10, 1)` varchar(10) DEFAULT NULL,
`NULLIF(c_varchar10, c_smallint)` varchar(10) DEFAULT NULL,
`NULLIF(c_varchar10, c_tinyint)` varchar(10) DEFAULT NULL,
`NULLIF(c_varchar10, c_int)` varchar(10) DEFAULT NULL,
`NULLIF(c_varchar10, c_bigint)` varchar(10) DEFAULT NULL,
`NULLIF(c_varchar10, c_float)` varchar(10) DEFAULT NULL,
`NULLIF(c_varchar10, c_double)` varchar(10) DEFAULT NULL,
`NULLIF(c_varchar10, c_decimal103)` varchar(10) DEFAULT NULL,
`NULLIF(c_varchar10, c_varchar10)` varchar(10) DEFAULT NULL,
`NULLIF(c_varchar10, c_text)` varchar(10) DEFAULT NULL,
`NULLIF(c_varchar10, c_blob)` varchar(10) DEFAULT NULL,
`NULLIF(c_varchar10, c_enum)` varchar(10) DEFAULT NULL,
`NULLIF(c_varchar10, c_datetime3)` varchar(10) DEFAULT NULL,
`NULLIF(c_varchar10, c_timestamp3)` varchar(10) DEFAULT NULL,
`NULLIF(c_varchar10, c_date)` varchar(10) DEFAULT NULL,
`NULLIF(c_varchar10, c_time)` varchar(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(c_text, 1),
NULLIF(c_text, c_smallint),
NULLIF(c_text, c_tinyint),
NULLIF(c_text, c_int),
NULLIF(c_text, c_bigint),
NULLIF(c_text, c_float),
NULLIF(c_text, c_double),
NULLIF(c_text, c_decimal103),
NULLIF(c_text, c_varchar10),
NULLIF(c_text, c_text),
NULLIF(c_text, c_blob),
NULLIF(c_text, c_enum),
NULLIF(c_text, c_datetime3),
NULLIF(c_text, c_timestamp3),
NULLIF(c_text, c_date),
NULLIF(c_text, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_text, 1)` longtext,
`NULLIF(c_text, c_smallint)` longtext,
`NULLIF(c_text, c_tinyint)` longtext,
`NULLIF(c_text, c_int)` longtext,
`NULLIF(c_text, c_bigint)` longtext,
`NULLIF(c_text, c_float)` longtext,
`NULLIF(c_text, c_double)` longtext,
`NULLIF(c_text, c_decimal103)` longtext,
`NULLIF(c_text, c_varchar10)` longtext,
`NULLIF(c_text, c_text)` longtext,
`NULLIF(c_text, c_blob)` longtext,
`NULLIF(c_text, c_enum)` longtext,
`NULLIF(c_text, c_datetime3)` longtext,
`NULLIF(c_text, c_timestamp3)` longtext,
`NULLIF(c_text, c_date)` longtext,
`NULLIF(c_text, c_time)` longtext
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(c_blob, 1),
NULLIF(c_blob, c_smallint),
NULLIF(c_blob, c_tinyint),
NULLIF(c_blob, c_int),
NULLIF(c_blob, c_bigint),
NULLIF(c_blob, c_float),
NULLIF(c_blob, c_double),
NULLIF(c_blob, c_decimal103),
NULLIF(c_blob, c_varchar10),
NULLIF(c_blob, c_text),
NULLIF(c_blob, c_blob),
NULLIF(c_blob, c_enum),
NULLIF(c_blob, c_datetime3),
NULLIF(c_blob, c_timestamp3),
NULLIF(c_blob, c_date),
NULLIF(c_blob, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_blob, 1)` longblob,
`NULLIF(c_blob, c_smallint)` longblob,
`NULLIF(c_blob, c_tinyint)` longblob,
`NULLIF(c_blob, c_int)` longblob,
`NULLIF(c_blob, c_bigint)` longblob,
`NULLIF(c_blob, c_float)` longblob,
`NULLIF(c_blob, c_double)` longblob,
`NULLIF(c_blob, c_decimal103)` longblob,
`NULLIF(c_blob, c_varchar10)` longblob,
`NULLIF(c_blob, c_text)` longblob,
`NULLIF(c_blob, c_blob)` longblob,
`NULLIF(c_blob, c_enum)` longblob,
`NULLIF(c_blob, c_datetime3)` longblob,
`NULLIF(c_blob, c_timestamp3)` longblob,
`NULLIF(c_blob, c_date)` longblob,
`NULLIF(c_blob, c_time)` longblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(c_enum, 1),
NULLIF(c_enum, c_smallint),
NULLIF(c_enum, c_tinyint),
NULLIF(c_enum, c_int),
NULLIF(c_enum, c_bigint),
NULLIF(c_enum, c_float),
NULLIF(c_enum, c_double),
NULLIF(c_enum, c_decimal103),
NULLIF(c_enum, c_varchar10),
NULLIF(c_enum, c_text),
NULLIF(c_enum, c_blob),
NULLIF(c_enum, c_enum),
NULLIF(c_enum, c_datetime3),
NULLIF(c_enum, c_timestamp3),
NULLIF(c_enum, c_date),
NULLIF(c_enum, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_enum, 1)` varchar(4) DEFAULT NULL,
`NULLIF(c_enum, c_smallint)` varchar(4) DEFAULT NULL,
`NULLIF(c_enum, c_tinyint)` varchar(4) DEFAULT NULL,
`NULLIF(c_enum, c_int)` varchar(4) DEFAULT NULL,
`NULLIF(c_enum, c_bigint)` varchar(4) DEFAULT NULL,
`NULLIF(c_enum, c_float)` varchar(4) DEFAULT NULL,
`NULLIF(c_enum, c_double)` varchar(4) DEFAULT NULL,
`NULLIF(c_enum, c_decimal103)` varchar(4) DEFAULT NULL,
`NULLIF(c_enum, c_varchar10)` varchar(4) DEFAULT NULL,
`NULLIF(c_enum, c_text)` varchar(4) DEFAULT NULL,
`NULLIF(c_enum, c_blob)` varchar(4) DEFAULT NULL,
`NULLIF(c_enum, c_enum)` varchar(4) DEFAULT NULL,
`NULLIF(c_enum, c_datetime3)` varchar(4) DEFAULT NULL,
`NULLIF(c_enum, c_timestamp3)` varchar(4) DEFAULT NULL,
`NULLIF(c_enum, c_date)` varchar(4) DEFAULT NULL,
`NULLIF(c_enum, c_time)` varchar(4) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(c_datetime3, 1),
NULLIF(c_datetime3, c_smallint),
NULLIF(c_datetime3, c_tinyint),
NULLIF(c_datetime3, c_int),
NULLIF(c_datetime3, c_bigint),
NULLIF(c_datetime3, c_float),
NULLIF(c_datetime3, c_double),
NULLIF(c_datetime3, c_decimal103),
NULLIF(c_datetime3, c_varchar10),
NULLIF(c_datetime3, c_text),
NULLIF(c_datetime3, c_blob),
NULLIF(c_datetime3, c_enum),
NULLIF(c_datetime3, c_datetime3),
NULLIF(c_datetime3, c_timestamp3),
NULLIF(c_datetime3, c_date),
NULLIF(c_datetime3, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_datetime3, 1)` datetime(3) DEFAULT NULL,
`NULLIF(c_datetime3, c_smallint)` datetime(3) DEFAULT NULL,
`NULLIF(c_datetime3, c_tinyint)` datetime(3) DEFAULT NULL,
`NULLIF(c_datetime3, c_int)` datetime(3) DEFAULT NULL,
`NULLIF(c_datetime3, c_bigint)` datetime(3) DEFAULT NULL,
`NULLIF(c_datetime3, c_float)` datetime(3) DEFAULT NULL,
`NULLIF(c_datetime3, c_double)` datetime(3) DEFAULT NULL,
`NULLIF(c_datetime3, c_decimal103)` datetime(3) DEFAULT NULL,
`NULLIF(c_datetime3, c_varchar10)` datetime(3) DEFAULT NULL,
`NULLIF(c_datetime3, c_text)` datetime(3) DEFAULT NULL,
`NULLIF(c_datetime3, c_blob)` datetime(3) DEFAULT NULL,
`NULLIF(c_datetime3, c_enum)` datetime(3) DEFAULT NULL,
`NULLIF(c_datetime3, c_datetime3)` datetime(3) DEFAULT NULL,
`NULLIF(c_datetime3, c_timestamp3)` datetime(3) DEFAULT NULL,
`NULLIF(c_datetime3, c_date)` datetime(3) DEFAULT NULL,
`NULLIF(c_datetime3, c_time)` datetime(3) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(c_timestamp3, 1),
NULLIF(c_timestamp3, c_smallint),
NULLIF(c_timestamp3, c_tinyint),
NULLIF(c_timestamp3, c_int),
NULLIF(c_timestamp3, c_bigint),
NULLIF(c_timestamp3, c_float),
NULLIF(c_timestamp3, c_double),
NULLIF(c_timestamp3, c_decimal103),
NULLIF(c_timestamp3, c_varchar10),
NULLIF(c_timestamp3, c_text),
NULLIF(c_timestamp3, c_blob),
NULLIF(c_timestamp3, c_enum),
NULLIF(c_timestamp3, c_datetime3),
NULLIF(c_timestamp3, c_timestamp3),
NULLIF(c_timestamp3, c_date),
NULLIF(c_timestamp3, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_timestamp3, 1)` timestamp(3) NULL DEFAULT NULL,
`NULLIF(c_timestamp3, c_smallint)` timestamp(3) NULL DEFAULT NULL,
`NULLIF(c_timestamp3, c_tinyint)` timestamp(3) NULL DEFAULT NULL,
`NULLIF(c_timestamp3, c_int)` timestamp(3) NULL DEFAULT NULL,
`NULLIF(c_timestamp3, c_bigint)` timestamp(3) NULL DEFAULT NULL,
`NULLIF(c_timestamp3, c_float)` timestamp(3) NULL DEFAULT NULL,
`NULLIF(c_timestamp3, c_double)` timestamp(3) NULL DEFAULT NULL,
`NULLIF(c_timestamp3, c_decimal103)` timestamp(3) NULL DEFAULT NULL,
`NULLIF(c_timestamp3, c_varchar10)` timestamp(3) NULL DEFAULT NULL,
`NULLIF(c_timestamp3, c_text)` timestamp(3) NULL DEFAULT NULL,
`NULLIF(c_timestamp3, c_blob)` timestamp(3) NULL DEFAULT NULL,
`NULLIF(c_timestamp3, c_enum)` timestamp(3) NULL DEFAULT NULL,
`NULLIF(c_timestamp3, c_datetime3)` timestamp(3) NULL DEFAULT NULL,
`NULLIF(c_timestamp3, c_timestamp3)` timestamp(3) NULL DEFAULT NULL,
`NULLIF(c_timestamp3, c_date)` timestamp(3) NULL DEFAULT NULL,
`NULLIF(c_timestamp3, c_time)` timestamp(3) NULL DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(c_date, 1),
NULLIF(c_date, c_smallint),
NULLIF(c_date, c_tinyint),
NULLIF(c_date, c_int),
NULLIF(c_date, c_bigint),
NULLIF(c_date, c_float),
NULLIF(c_date, c_double),
NULLIF(c_date, c_decimal103),
NULLIF(c_date, c_varchar10),
NULLIF(c_date, c_text),
NULLIF(c_date, c_blob),
NULLIF(c_date, c_enum),
NULLIF(c_date, c_datetime3),
NULLIF(c_date, c_timestamp3),
NULLIF(c_date, c_date),
NULLIF(c_date, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_date, 1)` date DEFAULT NULL,
`NULLIF(c_date, c_smallint)` date DEFAULT NULL,
`NULLIF(c_date, c_tinyint)` date DEFAULT NULL,
`NULLIF(c_date, c_int)` date DEFAULT NULL,
`NULLIF(c_date, c_bigint)` date DEFAULT NULL,
`NULLIF(c_date, c_float)` date DEFAULT NULL,
`NULLIF(c_date, c_double)` date DEFAULT NULL,
`NULLIF(c_date, c_decimal103)` date DEFAULT NULL,
`NULLIF(c_date, c_varchar10)` date DEFAULT NULL,
`NULLIF(c_date, c_text)` date DEFAULT NULL,
`NULLIF(c_date, c_blob)` date DEFAULT NULL,
`NULLIF(c_date, c_enum)` date DEFAULT NULL,
`NULLIF(c_date, c_datetime3)` date DEFAULT NULL,
`NULLIF(c_date, c_timestamp3)` date DEFAULT NULL,
`NULLIF(c_date, c_date)` date DEFAULT NULL,
`NULLIF(c_date, c_time)` date DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(c_time, 1),
NULLIF(c_time, c_smallint),
NULLIF(c_time, c_tinyint),
NULLIF(c_time, c_int),
NULLIF(c_time, c_bigint),
NULLIF(c_time, c_float),
NULLIF(c_time, c_double),
NULLIF(c_time, c_decimal103),
NULLIF(c_time, c_varchar10),
NULLIF(c_time, c_text),
NULLIF(c_time, c_blob),
NULLIF(c_time, c_enum),
NULLIF(c_time, c_datetime3),
NULLIF(c_time, c_timestamp3),
NULLIF(c_time, c_date),
NULLIF(c_time, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(c_time, 1)` time DEFAULT NULL,
`NULLIF(c_time, c_smallint)` time DEFAULT NULL,
`NULLIF(c_time, c_tinyint)` time DEFAULT NULL,
`NULLIF(c_time, c_int)` time DEFAULT NULL,
`NULLIF(c_time, c_bigint)` time DEFAULT NULL,
`NULLIF(c_time, c_float)` time DEFAULT NULL,
`NULLIF(c_time, c_double)` time DEFAULT NULL,
`NULLIF(c_time, c_decimal103)` time DEFAULT NULL,
`NULLIF(c_time, c_varchar10)` time DEFAULT NULL,
`NULLIF(c_time, c_text)` time DEFAULT NULL,
`NULLIF(c_time, c_blob)` time DEFAULT NULL,
`NULLIF(c_time, c_enum)` time DEFAULT NULL,
`NULLIF(c_time, c_datetime3)` time DEFAULT NULL,
`NULLIF(c_time, c_timestamp3)` time DEFAULT NULL,
`NULLIF(c_time, c_date)` time DEFAULT NULL,
`NULLIF(c_time, c_time)` time DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
#
# Checking that the return type depends only on args[0], even if compared to a field
#
CREATE TABLE t2 AS SELECT
NULLIF(1, 1),
NULLIF(1, c_smallint),
NULLIF(1, c_tinyint),
NULLIF(1, c_int),
NULLIF(1, c_bigint),
NULLIF(1, c_float),
NULLIF(1, c_double),
NULLIF(1, c_decimal103),
NULLIF(1, c_varchar10),
NULLIF(1, c_text),
NULLIF(1, c_blob),
NULLIF(1, c_enum),
NULLIF(1, c_datetime3),
NULLIF(1, c_timestamp3),
NULLIF(1, c_date),
NULLIF(1, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(1, 1)` int(1) DEFAULT NULL,
`NULLIF(1, c_smallint)` int(1) DEFAULT NULL,
`NULLIF(1, c_tinyint)` int(1) DEFAULT NULL,
`NULLIF(1, c_int)` int(1) DEFAULT NULL,
`NULLIF(1, c_bigint)` int(1) DEFAULT NULL,
`NULLIF(1, c_float)` int(1) DEFAULT NULL,
`NULLIF(1, c_double)` int(1) DEFAULT NULL,
`NULLIF(1, c_decimal103)` int(1) DEFAULT NULL,
`NULLIF(1, c_varchar10)` int(1) DEFAULT NULL,
`NULLIF(1, c_text)` int(1) DEFAULT NULL,
`NULLIF(1, c_blob)` int(1) DEFAULT NULL,
`NULLIF(1, c_enum)` int(1) DEFAULT NULL,
`NULLIF(1, c_datetime3)` int(1) DEFAULT NULL,
`NULLIF(1, c_timestamp3)` int(1) DEFAULT NULL,
`NULLIF(1, c_date)` int(1) DEFAULT NULL,
`NULLIF(1, c_time)` int(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(1.0, 1),
NULLIF(1.0, c_smallint),
NULLIF(1.0, c_tinyint),
NULLIF(1.0, c_int),
NULLIF(1.0, c_bigint),
NULLIF(1.0, c_float),
NULLIF(1.0, c_double),
NULLIF(1.0, c_decimal103),
NULLIF(1.0, c_varchar10),
NULLIF(1.0, c_text),
NULLIF(1.0, c_blob),
NULLIF(1.0, c_enum),
NULLIF(1.0, c_datetime3),
NULLIF(1.0, c_timestamp3),
NULLIF(1.0, c_date),
NULLIF(1.0, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(1.0, 1)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0, c_smallint)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0, c_tinyint)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0, c_int)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0, c_bigint)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0, c_float)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0, c_double)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0, c_decimal103)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0, c_varchar10)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0, c_text)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0, c_blob)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0, c_enum)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0, c_datetime3)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0, c_timestamp3)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0, c_date)` decimal(2,1) DEFAULT NULL,
`NULLIF(1.0, c_time)` decimal(2,1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(1e0, 1),
NULLIF(1e0, c_smallint),
NULLIF(1e0, c_tinyint),
NULLIF(1e0, c_int),
NULLIF(1e0, c_bigint),
NULLIF(1e0, c_float),
NULLIF(1e0, c_double),
NULLIF(1e0, c_decimal103),
NULLIF(1e0, c_varchar10),
NULLIF(1e0, c_text),
NULLIF(1e0, c_blob),
NULLIF(1e0, c_enum),
NULLIF(1e0, c_datetime3),
NULLIF(1e0, c_timestamp3),
NULLIF(1e0, c_date),
NULLIF(1e0, c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(1e0, 1)` double DEFAULT NULL,
`NULLIF(1e0, c_smallint)` double DEFAULT NULL,
`NULLIF(1e0, c_tinyint)` double DEFAULT NULL,
`NULLIF(1e0, c_int)` double DEFAULT NULL,
`NULLIF(1e0, c_bigint)` double DEFAULT NULL,
`NULLIF(1e0, c_float)` double DEFAULT NULL,
`NULLIF(1e0, c_double)` double DEFAULT NULL,
`NULLIF(1e0, c_decimal103)` double DEFAULT NULL,
`NULLIF(1e0, c_varchar10)` double DEFAULT NULL,
`NULLIF(1e0, c_text)` double DEFAULT NULL,
`NULLIF(1e0, c_blob)` double DEFAULT NULL,
`NULLIF(1e0, c_enum)` double DEFAULT NULL,
`NULLIF(1e0, c_datetime3)` double DEFAULT NULL,
`NULLIF(1e0, c_timestamp3)` double DEFAULT NULL,
`NULLIF(1e0, c_date)` double DEFAULT NULL,
`NULLIF(1e0, c_time)` double DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF('1', 1),
NULLIF('1', c_smallint),
NULLIF('1', c_tinyint),
NULLIF('1', c_int),
NULLIF('1', c_bigint),
NULLIF('1', c_float),
NULLIF('1', c_double),
NULLIF('1', c_decimal103),
NULLIF('1', c_varchar10),
NULLIF('1', c_text),
NULLIF('1', c_blob),
NULLIF('1', c_enum),
NULLIF('1', c_datetime3),
NULLIF('1', c_timestamp3),
NULLIF('1', c_date),
NULLIF('1', c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF('1', 1)` varchar(1) DEFAULT NULL,
`NULLIF('1', c_smallint)` varchar(1) DEFAULT NULL,
`NULLIF('1', c_tinyint)` varchar(1) DEFAULT NULL,
`NULLIF('1', c_int)` varchar(1) DEFAULT NULL,
`NULLIF('1', c_bigint)` varchar(1) DEFAULT NULL,
`NULLIF('1', c_float)` varchar(1) DEFAULT NULL,
`NULLIF('1', c_double)` varchar(1) DEFAULT NULL,
`NULLIF('1', c_decimal103)` varchar(1) DEFAULT NULL,
`NULLIF('1', c_varchar10)` varchar(1) DEFAULT NULL,
`NULLIF('1', c_text)` varchar(1) DEFAULT NULL,
`NULLIF('1', c_blob)` varchar(1) DEFAULT NULL,
`NULLIF('1', c_enum)` varchar(1) DEFAULT NULL,
`NULLIF('1', c_datetime3)` varchar(1) DEFAULT NULL,
`NULLIF('1', c_timestamp3)` varchar(1) DEFAULT NULL,
`NULLIF('1', c_date)` varchar(1) DEFAULT NULL,
`NULLIF('1', c_time)` varchar(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
NULLIF(TIME'10:10:10', 1),
NULLIF(TIME'10:10:10', c_smallint),
NULLIF(TIME'10:10:10', c_tinyint),
NULLIF(TIME'10:10:10', c_int),
NULLIF(TIME'10:10:10', c_bigint),
NULLIF(TIME'10:10:10', c_float),
NULLIF(TIME'10:10:10', c_double),
NULLIF(TIME'10:10:10', c_decimal103),
NULLIF(TIME'10:10:10', c_varchar10),
NULLIF(TIME'10:10:10', c_text),
NULLIF(TIME'10:10:10', c_blob),
NULLIF(TIME'10:10:10', c_enum),
NULLIF(TIME'10:10:10', c_datetime3),
NULLIF(TIME'10:10:10', c_timestamp3),
NULLIF(TIME'10:10:10', c_date),
NULLIF(TIME'10:10:10', c_time)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`NULLIF(TIME'10:10:10', 1)` time DEFAULT NULL,
`NULLIF(TIME'10:10:10', c_smallint)` time DEFAULT NULL,
`NULLIF(TIME'10:10:10', c_tinyint)` time DEFAULT NULL,
`NULLIF(TIME'10:10:10', c_int)` time DEFAULT NULL,
`NULLIF(TIME'10:10:10', c_bigint)` time DEFAULT NULL,
`NULLIF(TIME'10:10:10', c_float)` time DEFAULT NULL,
`NULLIF(TIME'10:10:10', c_double)` time DEFAULT NULL,
`NULLIF(TIME'10:10:10', c_decimal103)` time DEFAULT NULL,
`NULLIF(TIME'10:10:10', c_varchar10)` time DEFAULT NULL,
`NULLIF(TIME'10:10:10', c_text)` time DEFAULT NULL,
`NULLIF(TIME'10:10:10', c_blob)` time DEFAULT NULL,
`NULLIF(TIME'10:10:10', c_enum)` time DEFAULT NULL,
`NULLIF(TIME'10:10:10', c_datetime3)` time DEFAULT NULL,
`NULLIF(TIME'10:10:10', c_timestamp3)` time DEFAULT NULL,
`NULLIF(TIME'10:10:10', c_date)` time DEFAULT NULL,
`NULLIF(TIME'10:10:10', c_time)` time DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
DROP TABLE t1;
#
# End of 10.1 tests
#
mysql-test/t/null.test
View file @
969f4918
...
...
@@ -295,3 +295,548 @@ CREATE TABLE t2 (d DATE) ENGINE=MyISAM;
SELECT
*
FROM
t1
,
t2
WHERE
1
IS
NOT
NULL
AND
t1
.
b
IS
NULL
;
DROP
TABLE
t1
,
t2
;
--
echo
#
--
echo
# Start of 10.1 tests
--
echo
#
--
echo
#
--
echo
# MDEV-7146 NULLIF returns unexpected result with a YEAR field
--
echo
#
CREATE
TABLE
t1
(
a
YEAR
(
2
));
INSERT
INTO
t1
VALUES
(
0
);
SELECT
a
,
NULLIF
(
a
,
2000
),
NULLIF
(
2000
,
a
)
FROM
t1
;
SELECT
a
,
NULLIF
(
a
,
2001
),
NULLIF
(
2001
,
a
)
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# MDEV-7005 NULLIF does not work as documented
--
echo
#
CREATE
TABLE
t1
(
a
TIME
);
CREATE
TABLE
t2
AS
SELECT
a
,
NULLIF
(
a
,
a
),
CASE
WHEN
a
=
a
THEN
NULL
ELSE
a
END
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t1
,
t2
;
--
error
ER_CANT_AGGREGATE_2COLLATIONS
SELECT
NULLIF
(
_latin1
'a'
COLLATE
latin1_general_ci
,
_latin1
'a'
COLLATE
latin1_bin
);
CREATE
TABLE
t1
AS
SELECT
NULLIF
(
1
,
1
),
NULLIF
(
1
,
1.0
),
NULLIF
(
1
,
1
e0
),
NULLIF
(
1
,
'2001-01-01'
),
NULLIF
(
1
,
TIME
'00:00:00'
);
SHOW
CREATE
TABLE
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
AS
SELECT
NULLIF
(
1.0
,
1
),
NULLIF
(
1.0
,
1.0
),
NULLIF
(
1.0
,
1
e0
),
NULLIF
(
1.0
,
'2001-01-01'
),
NULLIF
(
1.0
,
TIME
'00:00:00'
);
SHOW
CREATE
TABLE
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
AS
SELECT
NULLIF
(
1
e0
,
1
),
NULLIF
(
1
e0
,
1.0
),
NULLIF
(
1
e0
,
1
e0
),
NULLIF
(
1
e0
,
'2001-01-01'
),
NULLIF
(
1
e0
,
TIME
'00:00:00'
);
SHOW
CREATE
TABLE
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
AS
SELECT
NULLIF
(
'1'
,
1
),
NULLIF
(
'1'
,
1.0
),
NULLIF
(
'1'
,
1
e0
),
NULLIF
(
'1'
,
'2001-01-01'
),
NULLIF
(
'1'
,
TIME
'00:00:00'
);
SHOW
CREATE
TABLE
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
AS
SELECT
NULLIF
(
TIMESTAMP
'2001-01-01 00:00:00'
,
1
),
NULLIF
(
TIMESTAMP
'2001-01-01 00:00:00'
,
1.0
),
NULLIF
(
TIMESTAMP
'2001-01-01 00:00:00'
,
1
e0
),
NULLIF
(
TIMESTAMP
'2001-01-01 00:00:00'
,
'2001-01-01'
),
NULLIF
(
TIMESTAMP
'2001-01-01 00:00:00'
,
TIME
'00:00:00'
);
SHOW
CREATE
TABLE
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
AS
SELECT
NULLIF
(
DATE
'2001-01-01'
,
1
),
NULLIF
(
DATE
'2001-01-01'
,
1.0
),
NULLIF
(
DATE
'2001-01-01'
,
1
e0
),
NULLIF
(
DATE
'2001-01-01'
,
'2001-01-01'
),
NULLIF
(
DATE
'2001-01-01'
,
TIME
'00:00:00'
);
SHOW
CREATE
TABLE
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
AS
SELECT
NULLIF
(
TIME
'00:00:01'
,
1
),
NULLIF
(
TIME
'00:00:01'
,
1.0
),
NULLIF
(
TIME
'00:00:01'
,
1
e0
),
NULLIF
(
TIME
'00:00:01'
,
'00:00:00'
),
NULLIF
(
TIME
'00:00:01'
,
DATE
'2001-01-01'
);
SHOW
CREATE
TABLE
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
c_tinyint
TINYINT
,
c_smallint
SMALLINT
,
c_int
INT
,
c_bigint
BIGINT
,
c_float
FLOAT
,
c_double
DOUBLE
,
c_decimal103
DECIMAL
(
10
,
3
),
c_varchar10
VARCHAR
(
10
),
c_text
TEXT
,
c_blob
BLOB
,
c_enum
ENUM
(
'one'
,
'two'
,
'tree'
),
c_datetime3
DATETIME
(
3
),
c_timestamp3
TIMESTAMP
(
3
),
c_date
DATE
,
c_time
TIME
);
--
echo
#
--
echo
# Checking that the return type depends only on args[0], even when compared to a super type
--
echo
#
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
c_tinyint
,
1
),
NULLIF
(
c_tinyint
,
c_smallint
),
NULLIF
(
c_tinyint
,
c_tinyint
),
NULLIF
(
c_tinyint
,
c_int
),
NULLIF
(
c_tinyint
,
c_bigint
),
NULLIF
(
c_tinyint
,
c_float
),
NULLIF
(
c_tinyint
,
c_double
),
NULLIF
(
c_tinyint
,
c_decimal103
),
NULLIF
(
c_tinyint
,
c_varchar10
),
NULLIF
(
c_tinyint
,
c_text
),
NULLIF
(
c_tinyint
,
c_blob
),
NULLIF
(
c_tinyint
,
c_enum
),
NULLIF
(
c_tinyint
,
c_datetime3
),
NULLIF
(
c_tinyint
,
c_timestamp3
),
NULLIF
(
c_tinyint
,
c_date
),
NULLIF
(
c_tinyint
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
c_smallint
,
1
),
NULLIF
(
c_smallint
,
c_smallint
),
NULLIF
(
c_smallint
,
c_tinyint
),
NULLIF
(
c_smallint
,
c_int
),
NULLIF
(
c_smallint
,
c_bigint
),
NULLIF
(
c_smallint
,
c_float
),
NULLIF
(
c_smallint
,
c_double
),
NULLIF
(
c_smallint
,
c_decimal103
),
NULLIF
(
c_smallint
,
c_varchar10
),
NULLIF
(
c_smallint
,
c_text
),
NULLIF
(
c_smallint
,
c_blob
),
NULLIF
(
c_smallint
,
c_enum
),
NULLIF
(
c_smallint
,
c_datetime3
),
NULLIF
(
c_smallint
,
c_timestamp3
),
NULLIF
(
c_smallint
,
c_date
),
NULLIF
(
c_smallint
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
c_int
,
1
),
NULLIF
(
c_int
,
c_smallint
),
NULLIF
(
c_int
,
c_tinyint
),
NULLIF
(
c_int
,
c_int
),
NULLIF
(
c_int
,
c_bigint
),
NULLIF
(
c_int
,
c_float
),
NULLIF
(
c_int
,
c_double
),
NULLIF
(
c_int
,
c_decimal103
),
NULLIF
(
c_int
,
c_varchar10
),
NULLIF
(
c_int
,
c_text
),
NULLIF
(
c_int
,
c_blob
),
NULLIF
(
c_int
,
c_enum
),
NULLIF
(
c_int
,
c_datetime3
),
NULLIF
(
c_int
,
c_timestamp3
),
NULLIF
(
c_int
,
c_date
),
NULLIF
(
c_int
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
c_bigint
,
1
),
NULLIF
(
c_bigint
,
c_smallint
),
NULLIF
(
c_bigint
,
c_tinyint
),
NULLIF
(
c_bigint
,
c_int
),
NULLIF
(
c_bigint
,
c_bigint
),
NULLIF
(
c_bigint
,
c_float
),
NULLIF
(
c_bigint
,
c_double
),
NULLIF
(
c_bigint
,
c_decimal103
),
NULLIF
(
c_bigint
,
c_varchar10
),
NULLIF
(
c_bigint
,
c_text
),
NULLIF
(
c_bigint
,
c_blob
),
NULLIF
(
c_bigint
,
c_enum
),
NULLIF
(
c_bigint
,
c_datetime3
),
NULLIF
(
c_bigint
,
c_timestamp3
),
NULLIF
(
c_bigint
,
c_date
),
NULLIF
(
c_bigint
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
# QQ: this should probably create a FLOAT column instead of a DOUBLE column
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
c_float
,
1
),
NULLIF
(
c_float
,
c_smallint
),
NULLIF
(
c_float
,
c_tinyint
),
NULLIF
(
c_float
,
c_int
),
NULLIF
(
c_float
,
c_bigint
),
NULLIF
(
c_float
,
c_float
),
NULLIF
(
c_float
,
c_double
),
NULLIF
(
c_float
,
c_decimal103
),
NULLIF
(
c_float
,
c_varchar10
),
NULLIF
(
c_float
,
c_text
),
NULLIF
(
c_float
,
c_blob
),
NULLIF
(
c_float
,
c_enum
),
NULLIF
(
c_float
,
c_datetime3
),
NULLIF
(
c_float
,
c_timestamp3
),
NULLIF
(
c_float
,
c_date
),
NULLIF
(
c_float
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
c_double
,
1
),
NULLIF
(
c_double
,
c_smallint
),
NULLIF
(
c_double
,
c_tinyint
),
NULLIF
(
c_double
,
c_int
),
NULLIF
(
c_double
,
c_bigint
),
NULLIF
(
c_double
,
c_float
),
NULLIF
(
c_double
,
c_double
),
NULLIF
(
c_double
,
c_decimal103
),
NULLIF
(
c_double
,
c_varchar10
),
NULLIF
(
c_double
,
c_text
),
NULLIF
(
c_double
,
c_blob
),
NULLIF
(
c_double
,
c_enum
),
NULLIF
(
c_double
,
c_datetime3
),
NULLIF
(
c_double
,
c_timestamp3
),
NULLIF
(
c_double
,
c_date
),
NULLIF
(
c_double
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
c_decimal103
,
1
),
NULLIF
(
c_decimal103
,
c_smallint
),
NULLIF
(
c_decimal103
,
c_tinyint
),
NULLIF
(
c_decimal103
,
c_int
),
NULLIF
(
c_decimal103
,
c_bigint
),
NULLIF
(
c_decimal103
,
c_float
),
NULLIF
(
c_decimal103
,
c_double
),
NULLIF
(
c_decimal103
,
c_decimal103
),
NULLIF
(
c_decimal103
,
c_varchar10
),
NULLIF
(
c_decimal103
,
c_text
),
NULLIF
(
c_decimal103
,
c_blob
),
NULLIF
(
c_decimal103
,
c_enum
),
NULLIF
(
c_decimal103
,
c_datetime3
),
NULLIF
(
c_decimal103
,
c_timestamp3
),
NULLIF
(
c_decimal103
,
c_date
),
NULLIF
(
c_decimal103
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
c_varchar10
,
1
),
NULLIF
(
c_varchar10
,
c_smallint
),
NULLIF
(
c_varchar10
,
c_tinyint
),
NULLIF
(
c_varchar10
,
c_int
),
NULLIF
(
c_varchar10
,
c_bigint
),
NULLIF
(
c_varchar10
,
c_float
),
NULLIF
(
c_varchar10
,
c_double
),
NULLIF
(
c_varchar10
,
c_decimal103
),
NULLIF
(
c_varchar10
,
c_varchar10
),
NULLIF
(
c_varchar10
,
c_text
),
NULLIF
(
c_varchar10
,
c_blob
),
NULLIF
(
c_varchar10
,
c_enum
),
NULLIF
(
c_varchar10
,
c_datetime3
),
NULLIF
(
c_varchar10
,
c_timestamp3
),
NULLIF
(
c_varchar10
,
c_date
),
NULLIF
(
c_varchar10
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
c_text
,
1
),
NULLIF
(
c_text
,
c_smallint
),
NULLIF
(
c_text
,
c_tinyint
),
NULLIF
(
c_text
,
c_int
),
NULLIF
(
c_text
,
c_bigint
),
NULLIF
(
c_text
,
c_float
),
NULLIF
(
c_text
,
c_double
),
NULLIF
(
c_text
,
c_decimal103
),
NULLIF
(
c_text
,
c_varchar10
),
NULLIF
(
c_text
,
c_text
),
NULLIF
(
c_text
,
c_blob
),
NULLIF
(
c_text
,
c_enum
),
NULLIF
(
c_text
,
c_datetime3
),
NULLIF
(
c_text
,
c_timestamp3
),
NULLIF
(
c_text
,
c_date
),
NULLIF
(
c_text
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
# QQ: this should probably create BLOB instead of LONGBLOB
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
c_blob
,
1
),
NULLIF
(
c_blob
,
c_smallint
),
NULLIF
(
c_blob
,
c_tinyint
),
NULLIF
(
c_blob
,
c_int
),
NULLIF
(
c_blob
,
c_bigint
),
NULLIF
(
c_blob
,
c_float
),
NULLIF
(
c_blob
,
c_double
),
NULLIF
(
c_blob
,
c_decimal103
),
NULLIF
(
c_blob
,
c_varchar10
),
NULLIF
(
c_blob
,
c_text
),
NULLIF
(
c_blob
,
c_blob
),
NULLIF
(
c_blob
,
c_enum
),
NULLIF
(
c_blob
,
c_datetime3
),
NULLIF
(
c_blob
,
c_timestamp3
),
NULLIF
(
c_blob
,
c_date
),
NULLIF
(
c_blob
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
# QQ: this should probably create a ENUM column instead of VARCHAR(4)
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
c_enum
,
1
),
NULLIF
(
c_enum
,
c_smallint
),
NULLIF
(
c_enum
,
c_tinyint
),
NULLIF
(
c_enum
,
c_int
),
NULLIF
(
c_enum
,
c_bigint
),
NULLIF
(
c_enum
,
c_float
),
NULLIF
(
c_enum
,
c_double
),
NULLIF
(
c_enum
,
c_decimal103
),
NULLIF
(
c_enum
,
c_varchar10
),
NULLIF
(
c_enum
,
c_text
),
NULLIF
(
c_enum
,
c_blob
),
NULLIF
(
c_enum
,
c_enum
),
NULLIF
(
c_enum
,
c_datetime3
),
NULLIF
(
c_enum
,
c_timestamp3
),
NULLIF
(
c_enum
,
c_date
),
NULLIF
(
c_enum
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
c_datetime3
,
1
),
NULLIF
(
c_datetime3
,
c_smallint
),
NULLIF
(
c_datetime3
,
c_tinyint
),
NULLIF
(
c_datetime3
,
c_int
),
NULLIF
(
c_datetime3
,
c_bigint
),
NULLIF
(
c_datetime3
,
c_float
),
NULLIF
(
c_datetime3
,
c_double
),
NULLIF
(
c_datetime3
,
c_decimal103
),
NULLIF
(
c_datetime3
,
c_varchar10
),
NULLIF
(
c_datetime3
,
c_text
),
NULLIF
(
c_datetime3
,
c_blob
),
NULLIF
(
c_datetime3
,
c_enum
),
NULLIF
(
c_datetime3
,
c_datetime3
),
NULLIF
(
c_datetime3
,
c_timestamp3
),
NULLIF
(
c_datetime3
,
c_date
),
NULLIF
(
c_datetime3
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
c_timestamp3
,
1
),
NULLIF
(
c_timestamp3
,
c_smallint
),
NULLIF
(
c_timestamp3
,
c_tinyint
),
NULLIF
(
c_timestamp3
,
c_int
),
NULLIF
(
c_timestamp3
,
c_bigint
),
NULLIF
(
c_timestamp3
,
c_float
),
NULLIF
(
c_timestamp3
,
c_double
),
NULLIF
(
c_timestamp3
,
c_decimal103
),
NULLIF
(
c_timestamp3
,
c_varchar10
),
NULLIF
(
c_timestamp3
,
c_text
),
NULLIF
(
c_timestamp3
,
c_blob
),
NULLIF
(
c_timestamp3
,
c_enum
),
NULLIF
(
c_timestamp3
,
c_datetime3
),
NULLIF
(
c_timestamp3
,
c_timestamp3
),
NULLIF
(
c_timestamp3
,
c_date
),
NULLIF
(
c_timestamp3
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
c_date
,
1
),
NULLIF
(
c_date
,
c_smallint
),
NULLIF
(
c_date
,
c_tinyint
),
NULLIF
(
c_date
,
c_int
),
NULLIF
(
c_date
,
c_bigint
),
NULLIF
(
c_date
,
c_float
),
NULLIF
(
c_date
,
c_double
),
NULLIF
(
c_date
,
c_decimal103
),
NULLIF
(
c_date
,
c_varchar10
),
NULLIF
(
c_date
,
c_text
),
NULLIF
(
c_date
,
c_blob
),
NULLIF
(
c_date
,
c_enum
),
NULLIF
(
c_date
,
c_datetime3
),
NULLIF
(
c_date
,
c_timestamp3
),
NULLIF
(
c_date
,
c_date
),
NULLIF
(
c_date
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
c_time
,
1
),
NULLIF
(
c_time
,
c_smallint
),
NULLIF
(
c_time
,
c_tinyint
),
NULLIF
(
c_time
,
c_int
),
NULLIF
(
c_time
,
c_bigint
),
NULLIF
(
c_time
,
c_float
),
NULLIF
(
c_time
,
c_double
),
NULLIF
(
c_time
,
c_decimal103
),
NULLIF
(
c_time
,
c_varchar10
),
NULLIF
(
c_time
,
c_text
),
NULLIF
(
c_time
,
c_blob
),
NULLIF
(
c_time
,
c_enum
),
NULLIF
(
c_time
,
c_datetime3
),
NULLIF
(
c_time
,
c_timestamp3
),
NULLIF
(
c_time
,
c_date
),
NULLIF
(
c_time
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
--
echo
#
--
echo
# Checking that the return type depends only on args[0], even if compared to a field
--
echo
#
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
1
,
1
),
NULLIF
(
1
,
c_smallint
),
NULLIF
(
1
,
c_tinyint
),
NULLIF
(
1
,
c_int
),
NULLIF
(
1
,
c_bigint
),
NULLIF
(
1
,
c_float
),
NULLIF
(
1
,
c_double
),
NULLIF
(
1
,
c_decimal103
),
NULLIF
(
1
,
c_varchar10
),
NULLIF
(
1
,
c_text
),
NULLIF
(
1
,
c_blob
),
NULLIF
(
1
,
c_enum
),
NULLIF
(
1
,
c_datetime3
),
NULLIF
(
1
,
c_timestamp3
),
NULLIF
(
1
,
c_date
),
NULLIF
(
1
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
1.0
,
1
),
NULLIF
(
1.0
,
c_smallint
),
NULLIF
(
1.0
,
c_tinyint
),
NULLIF
(
1.0
,
c_int
),
NULLIF
(
1.0
,
c_bigint
),
NULLIF
(
1.0
,
c_float
),
NULLIF
(
1.0
,
c_double
),
NULLIF
(
1.0
,
c_decimal103
),
NULLIF
(
1.0
,
c_varchar10
),
NULLIF
(
1.0
,
c_text
),
NULLIF
(
1.0
,
c_blob
),
NULLIF
(
1.0
,
c_enum
),
NULLIF
(
1.0
,
c_datetime3
),
NULLIF
(
1.0
,
c_timestamp3
),
NULLIF
(
1.0
,
c_date
),
NULLIF
(
1.0
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
1
e0
,
1
),
NULLIF
(
1
e0
,
c_smallint
),
NULLIF
(
1
e0
,
c_tinyint
),
NULLIF
(
1
e0
,
c_int
),
NULLIF
(
1
e0
,
c_bigint
),
NULLIF
(
1
e0
,
c_float
),
NULLIF
(
1
e0
,
c_double
),
NULLIF
(
1
e0
,
c_decimal103
),
NULLIF
(
1
e0
,
c_varchar10
),
NULLIF
(
1
e0
,
c_text
),
NULLIF
(
1
e0
,
c_blob
),
NULLIF
(
1
e0
,
c_enum
),
NULLIF
(
1
e0
,
c_datetime3
),
NULLIF
(
1
e0
,
c_timestamp3
),
NULLIF
(
1
e0
,
c_date
),
NULLIF
(
1
e0
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
'1'
,
1
),
NULLIF
(
'1'
,
c_smallint
),
NULLIF
(
'1'
,
c_tinyint
),
NULLIF
(
'1'
,
c_int
),
NULLIF
(
'1'
,
c_bigint
),
NULLIF
(
'1'
,
c_float
),
NULLIF
(
'1'
,
c_double
),
NULLIF
(
'1'
,
c_decimal103
),
NULLIF
(
'1'
,
c_varchar10
),
NULLIF
(
'1'
,
c_text
),
NULLIF
(
'1'
,
c_blob
),
NULLIF
(
'1'
,
c_enum
),
NULLIF
(
'1'
,
c_datetime3
),
NULLIF
(
'1'
,
c_timestamp3
),
NULLIF
(
'1'
,
c_date
),
NULLIF
(
'1'
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
CREATE
TABLE
t2
AS
SELECT
NULLIF
(
TIME
'10:10:10'
,
1
),
NULLIF
(
TIME
'10:10:10'
,
c_smallint
),
NULLIF
(
TIME
'10:10:10'
,
c_tinyint
),
NULLIF
(
TIME
'10:10:10'
,
c_int
),
NULLIF
(
TIME
'10:10:10'
,
c_bigint
),
NULLIF
(
TIME
'10:10:10'
,
c_float
),
NULLIF
(
TIME
'10:10:10'
,
c_double
),
NULLIF
(
TIME
'10:10:10'
,
c_decimal103
),
NULLIF
(
TIME
'10:10:10'
,
c_varchar10
),
NULLIF
(
TIME
'10:10:10'
,
c_text
),
NULLIF
(
TIME
'10:10:10'
,
c_blob
),
NULLIF
(
TIME
'10:10:10'
,
c_enum
),
NULLIF
(
TIME
'10:10:10'
,
c_datetime3
),
NULLIF
(
TIME
'10:10:10'
,
c_timestamp3
),
NULLIF
(
TIME
'10:10:10'
,
c_date
),
NULLIF
(
TIME
'10:10:10'
,
c_time
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# End of 10.1 tests
--
echo
#
sql/item_cmpfunc.cc
View file @
969f4918
...
...
@@ -525,6 +525,32 @@ static bool convert_const_to_int(THD *thd, Item_field *field_item,
}
/*
Make a special case of compare with fields to get nicer comparisons
of bigint numbers with constant string.
This directly contradicts the manual (number and a string should
be compared as doubles), but seems to provide more
"intuitive" behavior in some cases (but less intuitive in others).
*/
void
Item_func
::
convert_const_compared_to_int_field
(
THD
*
thd
)
{
DBUG_ASSERT
(
arg_count
==
2
);
if
(
!
thd
->
lex
->
is_ps_or_view_context_analysis
())
{
int
field
;
if
(
args
[
field
=
0
]
->
real_item
()
->
type
()
==
FIELD_ITEM
||
args
[
field
=
1
]
->
real_item
()
->
type
()
==
FIELD_ITEM
)
{
Item_field
*
field_item
=
(
Item_field
*
)
(
args
[
field
]
->
real_item
());
if
((
field_item
->
field_type
()
==
MYSQL_TYPE_LONGLONG
||
field_item
->
field_type
()
==
MYSQL_TYPE_YEAR
)
&&
convert_const_to_int
(
thd
,
field_item
,
&
args
[
!
field
]))
args
[
0
]
->
cmp_context
=
args
[
1
]
->
cmp_context
=
INT_RESULT
;
}
}
}
void
Item_bool_func2
::
fix_length_and_dec
()
{
max_length
=
1
;
// Function returns 0 or 1
...
...
@@ -557,29 +583,9 @@ void Item_bool_func2::fix_length_and_dec()
args
[
0
]
->
cmp_context
=
args
[
1
]
->
cmp_context
=
item_cmp_type
(
args
[
0
]
->
result_type
(),
args
[
1
]
->
result_type
());
/*
Make a special case of compare with fields to get nicer comparisons
of bigint numbers with constant string.
This directly contradicts the manual (number and a string should
be compared as doubles), but seems to provide more
"intuitive" behavior in some cases (but less intuitive in others).
But disable conversion in case of LIKE function.
*/
THD
*
thd
=
current_thd
;
if
(
functype
()
!=
LIKE_FUNC
&&
!
thd
->
lex
->
is_ps_or_view_context_analysis
())
{
int
field
;
if
(
args
[
field
=
0
]
->
real_item
()
->
type
()
==
FIELD_ITEM
||
args
[
field
=
1
]
->
real_item
()
->
type
()
==
FIELD_ITEM
)
{
Item_field
*
field_item
=
(
Item_field
*
)
(
args
[
field
]
->
real_item
());
if
((
field_item
->
field_type
()
==
MYSQL_TYPE_LONGLONG
||
field_item
->
field_type
()
==
MYSQL_TYPE_YEAR
)
&&
convert_const_to_int
(
thd
,
field_item
,
&
args
[
!
field
]))
args
[
0
]
->
cmp_context
=
args
[
1
]
->
cmp_context
=
INT_RESULT
;
}
}
// Convert constants when compared to int/year field, unless this is LIKE
if
(
functype
()
!=
LIKE_FUNC
)
convert_const_compared_to_int_field
(
current_thd
);
set_cmp_func
();
}
...
...
@@ -2723,18 +2729,21 @@ bool Item_func_if::date_op(MYSQL_TIME *ltime, uint fuzzydate)
void
Item_func_nullif
::
fix_length_and_dec
()
{
Item_bool_func2
::
fix_length_and_dec
();
if
(
!
args
[
0
])
// Only false if EOM
return
;
cached_result_type
=
args
[
0
]
->
result_type
();
cached_field_type
=
args
[
0
]
->
field_type
();
collation
.
set
(
args
[
0
]
->
collation
);
decimals
=
args
[
0
]
->
decimals
;
unsigned_flag
=
args
[
0
]
->
unsigned_flag
;
fix_char_length
(
args
[
0
]
->
max_char_length
());
convert_const_compared_to_int_field
(
current_thd
);
args
[
0
]
->
cmp_context
=
args
[
1
]
->
cmp_context
=
item_cmp_type
(
args
[
0
]
->
result_type
(),
args
[
1
]
->
result_type
());
cmp
.
set_cmp_func
(
this
,
tmp_arg
,
tmp_arg
+
1
,
args
[
0
]
->
cmp_context
);
maybe_null
=
1
;
if
(
args
[
0
])
// Only false if EOM
{
decimals
=
args
[
0
]
->
decimals
;
unsigned_flag
=
args
[
0
]
->
unsigned_flag
;
cached_result_type
=
args
[
0
]
->
result_type
();
if
(
cached_result_type
==
STRING_RESULT
&&
agg_arg_charsets_for_comparison
(
collation
,
args
,
arg_count
))
return
;
fix_char_length
(
args
[
0
]
->
max_char_length
());
}
}
...
...
@@ -2749,7 +2758,7 @@ Item_func_nullif::fix_length_and_dec()
*/
double
Item_func_nullif
::
val_real
()
Item_func_nullif
::
real_op
()
{
DBUG_ASSERT
(
fixed
==
1
);
double
value
;
...
...
@@ -2758,13 +2767,13 @@ Item_func_nullif::val_real()
null_value
=
1
;
return
0.0
;
}
value
=
args
[
0
]
->
val_real
();
null_value
=
args
[
0
]
->
null_value
;
value
=
m_args0_copy
->
val_real
();
null_value
=
m_args0_copy
->
null_value
;
return
value
;
}
longlong
Item_func_nullif
::
val_int
()
Item_func_nullif
::
int_op
()
{
DBUG_ASSERT
(
fixed
==
1
);
longlong
value
;
...
...
@@ -2773,13 +2782,13 @@ Item_func_nullif::val_int()
null_value
=
1
;
return
0
;
}
value
=
args
[
0
]
->
val_int
();
null_value
=
args
[
0
]
->
null_value
;
value
=
m_args0_copy
->
val_int
();
null_value
=
m_args0_copy
->
null_value
;
return
value
;
}
String
*
Item_func_nullif
::
val_str
(
String
*
str
)
Item_func_nullif
::
str_op
(
String
*
str
)
{
DBUG_ASSERT
(
fixed
==
1
);
String
*
res
;
...
...
@@ -2788,14 +2797,14 @@ Item_func_nullif::val_str(String *str)
null_value
=
1
;
return
0
;
}
res
=
args
[
0
]
->
val_str
(
str
);
null_value
=
args
[
0
]
->
null_value
;
res
=
m_args0_copy
->
val_str
(
str
);
null_value
=
m_args0_copy
->
null_value
;
return
res
;
}
my_decimal
*
Item_func_nullif
::
val_decimal
(
my_decimal
*
decimal_value
)
Item_func_nullif
::
decimal_op
(
my_decimal
*
decimal_value
)
{
DBUG_ASSERT
(
fixed
==
1
);
my_decimal
*
res
;
...
...
@@ -2804,16 +2813,26 @@ Item_func_nullif::val_decimal(my_decimal * decimal_value)
null_value
=
1
;
return
0
;
}
res
=
args
[
0
]
->
val_decimal
(
decimal_value
);
null_value
=
args
[
0
]
->
null_value
;
res
=
m_args0_copy
->
val_decimal
(
decimal_value
);
null_value
=
m_args0_copy
->
null_value
;
return
res
;
}
bool
Item_func_nullif
::
date_op
(
MYSQL_TIME
*
ltime
,
uint
fuzzydate
)
{
DBUG_ASSERT
(
fixed
==
1
);
if
(
!
cmp
.
compare
())
return
(
null_value
=
true
);
return
(
null_value
=
m_args0_copy
->
get_date
(
ltime
,
fuzzydate
));
}
bool
Item_func_nullif
::
is_null
()
{
return
(
null_value
=
(
!
cmp
.
compare
()
?
1
:
args
[
0
]
->
null_value
));
return
(
null_value
=
(
!
cmp
.
compare
()
?
1
:
m_args0_copy
->
null_value
));
}
...
...
sql/item_cmpfunc.h
View file @
969f4918
...
...
@@ -822,20 +822,30 @@ class Item_func_if :public Item_func_case_abbreviation2
};
class
Item_func_nullif
:
public
Item_
bool_func2
class
Item_func_nullif
:
public
Item_
func_hybrid_field_type
{
enum
Item_result
cached_result_type
;
Arg_comparator
cmp
;
/*
Remember the first argument in case it will be substituted by either of:
- convert_const_compared_to_int_field()
- agg_item_set_converter() in set_cmp_func()
- cache_converted_constant() in set_cmp_func()
The original item will be stored in m_arg0_copy, to return result.
The substituted item will be stored in args[0], for comparison purposes.
*/
Item
*
m_args0_copy
;
public:
Item_func_nullif
(
Item
*
a
,
Item
*
b
)
:
Item_bool_func2
(
a
,
b
),
cached_result_type
(
INT_RESULT
)
:
Item_func_hybrid_field_type
(
a
,
b
),
m_args0_copy
(
a
)
{}
double
val_real
(
);
longlong
val_int
();
String
*
val_str
(
String
*
str
);
my_decimal
*
val_decimal
(
my_decimal
*
);
enum
Item_result
result_type
()
const
{
return
cached_result_type
;
}
bool
date_op
(
MYSQL_TIME
*
ltime
,
uint
fuzzydate
);
double
real_op
();
longlong
int_op
(
);
String
*
str_op
(
String
*
str
);
my_decimal
*
decimal_op
(
my_decimal
*
);
void
fix_length_and_dec
();
uint
decimal_precision
()
const
{
return
args
[
0
]
->
decimal_precision
();
}
uint
decimal_precision
()
const
{
return
m_args0_copy
->
decimal_precision
();
}
const
char
*
func_name
()
const
{
return
"nullif"
;
}
virtual
inline
void
print
(
String
*
str
,
enum_query_type
query_type
)
...
...
sql/item_func.h
View file @
969f4918
...
...
@@ -396,6 +396,7 @@ class Item_func :public Item_result_field
info
.
bool_function
=
&
Item
::
restore_to_before_no_rows_in_result
;
walk
(
&
Item
::
call_bool_func_processor
,
FALSE
,
(
uchar
*
)
&
info
);
}
void
convert_const_compared_to_int_field
(
THD
*
thd
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment