summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2015-09-30 12:37:34 +0400
committerAlexander Barkov <bar@mariadb.org>2015-09-30 12:37:34 +0400
commitcc9cfecab78bde9376e4406bf24506e92fdaaeac (patch)
tree1ca3c873ef881d5e25be4aa390253f7eeb17c4ec /mysql-test
parent09b87d6293b4b41321ba98366d5d7ade9ad681d3 (diff)
downloadmariadb-git-cc9cfecab78bde9376e4406bf24506e92fdaaeac.tar.gz
MDEV-8865 Wrong field type or metadata for COALESCE(signed_int_column, unsigned_int_column)
Item_func_hybrid_field_type did not return correct field_type(), cmp_type() and result_type() in some cases, because cached_result_type and cached_field_type were set in independent pieces of the code and did not properly match to each other. Fix: - Removing Item_func_hybrid_result_type - Deriving Item_func_hybrid_field_type directly from Item_func - Introducing a new class Type_handler which guarantees that field_type(), cmp_type() and result_type() are always properly synchronized and using the new class in Item_func_hybrid_field_type.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/include/func_hybrid_type.inc81
-rw-r--r--mysql-test/r/func_hybrid_type.result1396
-rw-r--r--mysql-test/t/func_hybrid_type.test63
3 files changed, 1540 insertions, 0 deletions
diff --git a/mysql-test/include/func_hybrid_type.inc b/mysql-test/include/func_hybrid_type.inc
new file mode 100644
index 00000000000..854c7ebd34e
--- /dev/null
+++ b/mysql-test/include/func_hybrid_type.inc
@@ -0,0 +1,81 @@
+# "mtr --ps" returns different values in "Max length"
+--disable_ps_protocol
+--enable_metadata
+--vertical_results
+SELECT
+ a AS ___________a,
+ CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+ CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+ COALESCE(a) AS coalesce___a,
+ COALESCE(a, a) AS coalesce_a_a,
+ IF(a IS NULL, a, a) AS if_______a_a,
+ IFNULL(a, a) AS ifnull___a_a,
+ LEAST(a, a) AS least____a_a,
+ GREATEST(a, a) AS greatest_a_a,
+ b AS ___________b,
+ CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+ CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+ COALESCE(b) AS coalesce___b,
+ COALESCE(b, b) AS coalesce_b_b,
+ IF(a IS NULL, b, b) AS if_______b_b,
+ IFNULL(b, b) AS ifnull___b_b,
+ LEAST(b, b) AS least____b_b,
+ GREATEST(b, b) AS greatest_b_b
+FROM t1;
+SELECT
+ CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+ CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+ COALESCE(a, b) AS coalesce_a_b,
+ COALESCE(b, a) AS coalesce_b_a,
+ IF(a IS NULL, a, b) AS if_______a_b,
+ IF(a IS NULL, b, a) AS if_______b_a,
+ IFNULL(a, b) AS ifnull___a_b,
+ IFNULL(b, a) AS ifnull___b_a,
+ LEAST(a, b) AS least____a_b,
+ LEAST(b, a) AS least____b_a,
+ GREATEST(a, b) AS greatest_a_b,
+ GREATEST(b, a) AS greatest_b_a
+FROM t1;
+--horizontal_results
+--disable_metadata
+--enable_ps_protocol
+CREATE TABLE t2 AS
+SELECT
+ a AS ___________a,
+ CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+ CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+ COALESCE(a) AS coalesce___a,
+ COALESCE(a, a) AS coalesce_a_a,
+ IF(a IS NULL, a, a) AS if_______a_a,
+ IFNULL(a, a) AS ifnull___a_a,
+ LEAST(a, a) AS least____a_a,
+ GREATEST(a, a) AS greatest_a_a,
+ b AS ___________b,
+ CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+ CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+ COALESCE(b) AS coalesce___b,
+ COALESCE(b, b) AS coalesce_b_b,
+ IF(a IS NULL, b, b) AS if_______b_b,
+ IFNULL(b, b) AS ifnull___b_b,
+ LEAST(b, b) AS least____b_b,
+ GREATEST(b, b) AS greatest_b_b
+FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+CREATE TABLE t2 AS
+SELECT
+ CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+ CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+ COALESCE(a, b) AS coalesce_a_b,
+ COALESCE(b, a) AS coalesce_b_a,
+ IF(a IS NULL, a, b) AS if_______a_b,
+ IF(a IS NULL, b, a) AS if_______b_a,
+ IFNULL(a, b) AS ifnull___a_b,
+ IFNULL(b, a) AS ifnull___b_a,
+ LEAST(a, b) AS least____a_b,
+ LEAST(b, a) AS least____b_a,
+ GREATEST(a, b) AS greatest_a_b,
+ GREATEST(b, a) AS greatest_b_a
+FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
diff --git a/mysql-test/r/func_hybrid_type.result b/mysql-test/r/func_hybrid_type.result
new file mode 100644
index 00000000000..0d2ac5aab7b
--- /dev/null
+++ b/mysql-test/r/func_hybrid_type.result
@@ -0,0 +1,1396 @@
+#
+# Start of 10.1 tests
+#
+#
+# MDEV-8865 Wrong field type or metadata for COALESCE(signed_int_column, unsigned_int_column)
+#
+#
+CREATE TABLE t1 (a INT, b INT UNSIGNED);
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (-1,1);
+INSERT INTO t1 VALUES (-2147483648,4294967295);
+SELECT
+a AS ___________a,
+CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+COALESCE(a) AS coalesce___a,
+COALESCE(a, a) AS coalesce_a_a,
+IF(a IS NULL, a, a) AS if_______a_a,
+IFNULL(a, a) AS ifnull___a_a,
+LEAST(a, a) AS least____a_a,
+GREATEST(a, a) AS greatest_a_a,
+b AS ___________b,
+CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+COALESCE(b) AS coalesce___b,
+COALESCE(b, b) AS coalesce_b_b,
+IF(a IS NULL, b, b) AS if_______b_b,
+IFNULL(b, b) AS ifnull___b_b,
+LEAST(b, b) AS least____b_b,
+GREATEST(b, b) AS greatest_b_b
+FROM t1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t1 t1 a ___________a 3 11 11 Y 32768 0 63
+def case_______a 3 11 11 Y 32896 0 63
+def case_____a_a 3 11 11 Y 32896 0 63
+def coalesce___a 3 11 11 Y 32896 0 63
+def coalesce_a_a 3 11 11 Y 32896 0 63
+def if_______a_a 3 11 11 Y 32896 0 63
+def ifnull___a_a 3 11 11 Y 32896 0 63
+def least____a_a 3 11 11 Y 32896 0 63
+def greatest_a_a 3 11 11 Y 32896 0 63
+def test t1 t1 b ___________b 3 10 10 Y 32800 0 63
+def case_______b 3 10 10 Y 32928 0 63
+def case_____b_b 3 10 10 Y 32928 0 63
+def coalesce___b 3 10 10 Y 32928 0 63
+def coalesce_b_b 3 10 10 Y 32928 0 63
+def if_______b_b 3 10 10 Y 32928 0 63
+def ifnull___b_b 3 10 10 Y 32928 0 63
+def least____b_b 3 10 10 Y 32928 0 63
+def greatest_b_b 3 10 10 Y 32928 0 63
+___________a 1
+case_______a 1
+case_____a_a 1
+coalesce___a 1
+coalesce_a_a 1
+if_______a_a 1
+ifnull___a_a 1
+least____a_a 1
+greatest_a_a 1
+___________b 1
+case_______b 1
+case_____b_b 1
+coalesce___b 1
+coalesce_b_b 1
+if_______b_b 1
+ifnull___b_b 1
+least____b_b 1
+greatest_b_b 1
+___________a -1
+case_______a -1
+case_____a_a -1
+coalesce___a -1
+coalesce_a_a -1
+if_______a_a -1
+ifnull___a_a -1
+least____a_a -1
+greatest_a_a -1
+___________b 1
+case_______b 1
+case_____b_b 1
+coalesce___b 1
+coalesce_b_b 1
+if_______b_b 1
+ifnull___b_b 1
+least____b_b 1
+greatest_b_b 1
+___________a -2147483648
+case_______a -2147483648
+case_____a_a -2147483648
+coalesce___a -2147483648
+coalesce_a_a -2147483648
+if_______a_a -2147483648
+ifnull___a_a -2147483648
+least____a_a -2147483648
+greatest_a_a -2147483648
+___________b 4294967295
+case_______b 4294967295
+case_____b_b 4294967295
+coalesce___b 4294967295
+coalesce_b_b 4294967295
+if_______b_b 4294967295
+ifnull___b_b 4294967295
+least____b_b 4294967295
+greatest_b_b 4294967295
+SELECT
+CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+COALESCE(a, b) AS coalesce_a_b,
+COALESCE(b, a) AS coalesce_b_a,
+IF(a IS NULL, a, b) AS if_______a_b,
+IF(a IS NULL, b, a) AS if_______b_a,
+IFNULL(a, b) AS ifnull___a_b,
+IFNULL(b, a) AS ifnull___b_a,
+LEAST(a, b) AS least____a_b,
+LEAST(b, a) AS least____b_a,
+GREATEST(a, b) AS greatest_a_b,
+GREATEST(b, a) AS greatest_b_a
+FROM t1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def case_____a_b 246 11 11 Y 32896 0 63
+def case_____b_a 246 11 10 Y 32896 0 63
+def coalesce_a_b 246 11 11 Y 32896 0 63
+def coalesce_b_a 246 11 10 Y 32896 0 63
+def if_______a_b 246 11 10 Y 32896 0 63
+def if_______b_a 246 11 11 Y 32896 0 63
+def ifnull___a_b 246 11 11 Y 32896 0 63
+def ifnull___b_a 246 11 10 Y 32896 0 63
+def least____a_b 246 11 11 Y 32896 0 63
+def least____b_a 246 11 11 Y 32896 0 63
+def greatest_a_b 246 11 10 Y 32896 0 63
+def greatest_b_a 246 11 10 Y 32896 0 63
+case_____a_b 1
+case_____b_a 1
+coalesce_a_b 1
+coalesce_b_a 1
+if_______a_b 1
+if_______b_a 1
+ifnull___a_b 1
+ifnull___b_a 1
+least____a_b 1
+least____b_a 1
+greatest_a_b 1
+greatest_b_a 1
+case_____a_b -1
+case_____b_a 1
+coalesce_a_b -1
+coalesce_b_a 1
+if_______a_b 1
+if_______b_a -1
+ifnull___a_b -1
+ifnull___b_a 1
+least____a_b -1
+least____b_a -1
+greatest_a_b 1
+greatest_b_a 1
+case_____a_b -2147483648
+case_____b_a 4294967295
+coalesce_a_b -2147483648
+coalesce_b_a 4294967295
+if_______a_b 4294967295
+if_______b_a -2147483648
+ifnull___a_b -2147483648
+ifnull___b_a 4294967295
+least____a_b -2147483648
+least____b_a -2147483648
+greatest_a_b 4294967295
+greatest_b_a 4294967295
+CREATE TABLE t2 AS
+SELECT
+a AS ___________a,
+CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+COALESCE(a) AS coalesce___a,
+COALESCE(a, a) AS coalesce_a_a,
+IF(a IS NULL, a, a) AS if_______a_a,
+IFNULL(a, a) AS ifnull___a_a,
+LEAST(a, a) AS least____a_a,
+GREATEST(a, a) AS greatest_a_a,
+b AS ___________b,
+CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+COALESCE(b) AS coalesce___b,
+COALESCE(b, b) AS coalesce_b_b,
+IF(a IS NULL, b, b) AS if_______b_b,
+IFNULL(b, b) AS ifnull___b_b,
+LEAST(b, b) AS least____b_b,
+GREATEST(b, b) AS greatest_b_b
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `___________a` int(11) DEFAULT NULL,
+ `case_______a` int(11) DEFAULT NULL,
+ `case_____a_a` int(11) DEFAULT NULL,
+ `coalesce___a` int(11) DEFAULT NULL,
+ `coalesce_a_a` int(11) DEFAULT NULL,
+ `if_______a_a` int(11) DEFAULT NULL,
+ `ifnull___a_a` int(11) DEFAULT NULL,
+ `least____a_a` int(11) DEFAULT NULL,
+ `greatest_a_a` int(11) DEFAULT NULL,
+ `___________b` int(10) unsigned DEFAULT NULL,
+ `case_______b` int(10) unsigned DEFAULT NULL,
+ `case_____b_b` int(10) unsigned DEFAULT NULL,
+ `coalesce___b` int(10) unsigned DEFAULT NULL,
+ `coalesce_b_b` int(10) unsigned DEFAULT NULL,
+ `if_______b_b` int(10) unsigned DEFAULT NULL,
+ `ifnull___b_b` int(10) unsigned DEFAULT NULL,
+ `least____b_b` int(10) unsigned DEFAULT NULL,
+ `greatest_b_b` int(10) unsigned DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+CREATE TABLE t2 AS
+SELECT
+CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+COALESCE(a, b) AS coalesce_a_b,
+COALESCE(b, a) AS coalesce_b_a,
+IF(a IS NULL, a, b) AS if_______a_b,
+IF(a IS NULL, b, a) AS if_______b_a,
+IFNULL(a, b) AS ifnull___a_b,
+IFNULL(b, a) AS ifnull___b_a,
+LEAST(a, b) AS least____a_b,
+LEAST(b, a) AS least____b_a,
+GREATEST(a, b) AS greatest_a_b,
+GREATEST(b, a) AS greatest_b_a
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `case_____a_b` decimal(10,0) DEFAULT NULL,
+ `case_____b_a` decimal(10,0) DEFAULT NULL,
+ `coalesce_a_b` decimal(10,0) DEFAULT NULL,
+ `coalesce_b_a` decimal(10,0) DEFAULT NULL,
+ `if_______a_b` decimal(10,0) DEFAULT NULL,
+ `if_______b_a` decimal(10,0) DEFAULT NULL,
+ `ifnull___a_b` decimal(10,0) DEFAULT NULL,
+ `ifnull___b_a` decimal(10,0) DEFAULT NULL,
+ `least____a_b` decimal(10,0) DEFAULT NULL,
+ `least____b_a` decimal(10,0) DEFAULT NULL,
+ `greatest_a_b` decimal(10,0) DEFAULT NULL,
+ `greatest_b_a` decimal(10,0) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+#
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (-2147483648,2147483647);
+SELECT
+a AS ___________a,
+CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+COALESCE(a) AS coalesce___a,
+COALESCE(a, a) AS coalesce_a_a,
+IF(a IS NULL, a, a) AS if_______a_a,
+IFNULL(a, a) AS ifnull___a_a,
+LEAST(a, a) AS least____a_a,
+GREATEST(a, a) AS greatest_a_a,
+b AS ___________b,
+CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+COALESCE(b) AS coalesce___b,
+COALESCE(b, b) AS coalesce_b_b,
+IF(a IS NULL, b, b) AS if_______b_b,
+IFNULL(b, b) AS ifnull___b_b,
+LEAST(b, b) AS least____b_b,
+GREATEST(b, b) AS greatest_b_b
+FROM t1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t1 t1 a ___________a 3 11 11 Y 32768 0 63
+def case_______a 3 11 11 Y 32896 0 63
+def case_____a_a 3 11 11 Y 32896 0 63
+def coalesce___a 3 11 11 Y 32896 0 63
+def coalesce_a_a 3 11 11 Y 32896 0 63
+def if_______a_a 3 11 11 Y 32896 0 63
+def ifnull___a_a 3 11 11 Y 32896 0 63
+def least____a_a 3 11 11 Y 32896 0 63
+def greatest_a_a 3 11 11 Y 32896 0 63
+def test t1 t1 b ___________b 3 11 10 Y 32768 0 63
+def case_______b 3 11 10 Y 32896 0 63
+def case_____b_b 3 11 10 Y 32896 0 63
+def coalesce___b 3 11 10 Y 32896 0 63
+def coalesce_b_b 3 11 10 Y 32896 0 63
+def if_______b_b 3 11 10 Y 32896 0 63
+def ifnull___b_b 3 11 10 Y 32896 0 63
+def least____b_b 3 11 10 Y 32896 0 63
+def greatest_b_b 3 11 10 Y 32896 0 63
+___________a 1
+case_______a 1
+case_____a_a 1
+coalesce___a 1
+coalesce_a_a 1
+if_______a_a 1
+ifnull___a_a 1
+least____a_a 1
+greatest_a_a 1
+___________b 1
+case_______b 1
+case_____b_b 1
+coalesce___b 1
+coalesce_b_b 1
+if_______b_b 1
+ifnull___b_b 1
+least____b_b 1
+greatest_b_b 1
+___________a -2147483648
+case_______a -2147483648
+case_____a_a -2147483648
+coalesce___a -2147483648
+coalesce_a_a -2147483648
+if_______a_a -2147483648
+ifnull___a_a -2147483648
+least____a_a -2147483648
+greatest_a_a -2147483648
+___________b 2147483647
+case_______b 2147483647
+case_____b_b 2147483647
+coalesce___b 2147483647
+coalesce_b_b 2147483647
+if_______b_b 2147483647
+ifnull___b_b 2147483647
+least____b_b 2147483647
+greatest_b_b 2147483647
+SELECT
+CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+COALESCE(a, b) AS coalesce_a_b,
+COALESCE(b, a) AS coalesce_b_a,
+IF(a IS NULL, a, b) AS if_______a_b,
+IF(a IS NULL, b, a) AS if_______b_a,
+IFNULL(a, b) AS ifnull___a_b,
+IFNULL(b, a) AS ifnull___b_a,
+LEAST(a, b) AS least____a_b,
+LEAST(b, a) AS least____b_a,
+GREATEST(a, b) AS greatest_a_b,
+GREATEST(b, a) AS greatest_b_a
+FROM t1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def case_____a_b 3 11 11 Y 32896 0 63
+def case_____b_a 3 11 10 Y 32896 0 63
+def coalesce_a_b 3 11 11 Y 32896 0 63
+def coalesce_b_a 3 11 10 Y 32896 0 63
+def if_______a_b 3 11 10 Y 32896 0 63
+def if_______b_a 3 11 11 Y 32896 0 63
+def ifnull___a_b 3 11 11 Y 32896 0 63
+def ifnull___b_a 3 11 10 Y 32896 0 63
+def least____a_b 3 11 11 Y 32896 0 63
+def least____b_a 3 11 11 Y 32896 0 63
+def greatest_a_b 3 11 10 Y 32896 0 63
+def greatest_b_a 3 11 10 Y 32896 0 63
+case_____a_b 1
+case_____b_a 1
+coalesce_a_b 1
+coalesce_b_a 1
+if_______a_b 1
+if_______b_a 1
+ifnull___a_b 1
+ifnull___b_a 1
+least____a_b 1
+least____b_a 1
+greatest_a_b 1
+greatest_b_a 1
+case_____a_b -2147483648
+case_____b_a 2147483647
+coalesce_a_b -2147483648
+coalesce_b_a 2147483647
+if_______a_b 2147483647
+if_______b_a -2147483648
+ifnull___a_b -2147483648
+ifnull___b_a 2147483647
+least____a_b -2147483648
+least____b_a -2147483648
+greatest_a_b 2147483647
+greatest_b_a 2147483647
+CREATE TABLE t2 AS
+SELECT
+a AS ___________a,
+CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+COALESCE(a) AS coalesce___a,
+COALESCE(a, a) AS coalesce_a_a,
+IF(a IS NULL, a, a) AS if_______a_a,
+IFNULL(a, a) AS ifnull___a_a,
+LEAST(a, a) AS least____a_a,
+GREATEST(a, a) AS greatest_a_a,
+b AS ___________b,
+CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+COALESCE(b) AS coalesce___b,
+COALESCE(b, b) AS coalesce_b_b,
+IF(a IS NULL, b, b) AS if_______b_b,
+IFNULL(b, b) AS ifnull___b_b,
+LEAST(b, b) AS least____b_b,
+GREATEST(b, b) AS greatest_b_b
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `___________a` int(11) DEFAULT NULL,
+ `case_______a` int(11) DEFAULT NULL,
+ `case_____a_a` int(11) DEFAULT NULL,
+ `coalesce___a` int(11) DEFAULT NULL,
+ `coalesce_a_a` int(11) DEFAULT NULL,
+ `if_______a_a` int(11) DEFAULT NULL,
+ `ifnull___a_a` int(11) DEFAULT NULL,
+ `least____a_a` int(11) DEFAULT NULL,
+ `greatest_a_a` int(11) DEFAULT NULL,
+ `___________b` int(11) DEFAULT NULL,
+ `case_______b` int(11) DEFAULT NULL,
+ `case_____b_b` int(11) DEFAULT NULL,
+ `coalesce___b` int(11) DEFAULT NULL,
+ `coalesce_b_b` int(11) DEFAULT NULL,
+ `if_______b_b` int(11) DEFAULT NULL,
+ `ifnull___b_b` int(11) DEFAULT NULL,
+ `least____b_b` int(11) DEFAULT NULL,
+ `greatest_b_b` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+CREATE TABLE t2 AS
+SELECT
+CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+COALESCE(a, b) AS coalesce_a_b,
+COALESCE(b, a) AS coalesce_b_a,
+IF(a IS NULL, a, b) AS if_______a_b,
+IF(a IS NULL, b, a) AS if_______b_a,
+IFNULL(a, b) AS ifnull___a_b,
+IFNULL(b, a) AS ifnull___b_a,
+LEAST(a, b) AS least____a_b,
+LEAST(b, a) AS least____b_a,
+GREATEST(a, b) AS greatest_a_b,
+GREATEST(b, a) AS greatest_b_a
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `case_____a_b` int(11) DEFAULT NULL,
+ `case_____b_a` int(11) DEFAULT NULL,
+ `coalesce_a_b` int(11) DEFAULT NULL,
+ `coalesce_b_a` int(11) DEFAULT NULL,
+ `if_______a_b` int(11) DEFAULT NULL,
+ `if_______b_a` int(11) DEFAULT NULL,
+ `ifnull___a_b` int(11) DEFAULT NULL,
+ `ifnull___b_a` int(11) DEFAULT NULL,
+ `least____a_b` int(11) DEFAULT NULL,
+ `least____b_a` int(11) DEFAULT NULL,
+ `greatest_a_b` int(11) DEFAULT NULL,
+ `greatest_b_a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+#
+CREATE TABLE t1 (a BIGINT, b BIGINT UNSIGNED);
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (-9223372036854775808,0xFFFFFFFFFFFFFFFF);
+SELECT
+a AS ___________a,
+CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+COALESCE(a) AS coalesce___a,
+COALESCE(a, a) AS coalesce_a_a,
+IF(a IS NULL, a, a) AS if_______a_a,
+IFNULL(a, a) AS ifnull___a_a,
+LEAST(a, a) AS least____a_a,
+GREATEST(a, a) AS greatest_a_a,
+b AS ___________b,
+CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+COALESCE(b) AS coalesce___b,
+COALESCE(b, b) AS coalesce_b_b,
+IF(a IS NULL, b, b) AS if_______b_b,
+IFNULL(b, b) AS ifnull___b_b,
+LEAST(b, b) AS least____b_b,
+GREATEST(b, b) AS greatest_b_b
+FROM t1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t1 t1 a ___________a 8 20 20 Y 32768 0 63
+def case_______a 8 20 20 Y 32896 0 63
+def case_____a_a 8 20 20 Y 32896 0 63
+def coalesce___a 8 20 20 Y 32896 0 63
+def coalesce_a_a 8 20 20 Y 32896 0 63
+def if_______a_a 8 20 20 Y 32896 0 63
+def ifnull___a_a 8 20 20 Y 32896 0 63
+def least____a_a 8 20 20 Y 32896 0 63
+def greatest_a_a 8 20 20 Y 32896 0 63
+def test t1 t1 b ___________b 8 20 20 Y 32800 0 63
+def case_______b 8 20 20 Y 32928 0 63
+def case_____b_b 8 20 20 Y 32928 0 63
+def coalesce___b 8 20 20 Y 32928 0 63
+def coalesce_b_b 8 20 20 Y 32928 0 63
+def if_______b_b 8 20 20 Y 32928 0 63
+def ifnull___b_b 8 20 20 Y 32928 0 63
+def least____b_b 8 20 20 Y 32928 0 63
+def greatest_b_b 8 20 20 Y 32928 0 63
+___________a 1
+case_______a 1
+case_____a_a 1
+coalesce___a 1
+coalesce_a_a 1
+if_______a_a 1
+ifnull___a_a 1
+least____a_a 1
+greatest_a_a 1
+___________b 1
+case_______b 1
+case_____b_b 1
+coalesce___b 1
+coalesce_b_b 1
+if_______b_b 1
+ifnull___b_b 1
+least____b_b 1
+greatest_b_b 1
+___________a -9223372036854775808
+case_______a -9223372036854775808
+case_____a_a -9223372036854775808
+coalesce___a -9223372036854775808
+coalesce_a_a -9223372036854775808
+if_______a_a -9223372036854775808
+ifnull___a_a -9223372036854775808
+least____a_a -9223372036854775808
+greatest_a_a -9223372036854775808
+___________b 18446744073709551615
+case_______b 18446744073709551615
+case_____b_b 18446744073709551615
+coalesce___b 18446744073709551615
+coalesce_b_b 18446744073709551615
+if_______b_b 18446744073709551615
+ifnull___b_b 18446744073709551615
+least____b_b 18446744073709551615
+greatest_b_b 18446744073709551615
+SELECT
+CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+COALESCE(a, b) AS coalesce_a_b,
+COALESCE(b, a) AS coalesce_b_a,
+IF(a IS NULL, a, b) AS if_______a_b,
+IF(a IS NULL, b, a) AS if_______b_a,
+IFNULL(a, b) AS ifnull___a_b,
+IFNULL(b, a) AS ifnull___b_a,
+LEAST(a, b) AS least____a_b,
+LEAST(b, a) AS least____b_a,
+GREATEST(a, b) AS greatest_a_b,
+GREATEST(b, a) AS greatest_b_a
+FROM t1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def case_____a_b 246 21 20 Y 32896 0 63
+def case_____b_a 246 21 20 Y 32896 0 63
+def coalesce_a_b 246 21 20 Y 32896 0 63
+def coalesce_b_a 246 21 20 Y 32896 0 63
+def if_______a_b 246 21 20 Y 32896 0 63
+def if_______b_a 246 21 20 Y 32896 0 63
+def ifnull___a_b 246 21 20 Y 32896 0 63
+def ifnull___b_a 246 21 20 Y 32896 0 63
+def least____a_b 246 21 20 Y 32896 0 63
+def least____b_a 246 21 20 Y 32896 0 63
+def greatest_a_b 246 21 20 Y 32896 0 63
+def greatest_b_a 246 21 20 Y 32896 0 63
+case_____a_b 1
+case_____b_a 1
+coalesce_a_b 1
+coalesce_b_a 1
+if_______a_b 1
+if_______b_a 1
+ifnull___a_b 1
+ifnull___b_a 1
+least____a_b 1
+least____b_a 1
+greatest_a_b 1
+greatest_b_a 1
+case_____a_b -9223372036854775808
+case_____b_a 18446744073709551615
+coalesce_a_b -9223372036854775808
+coalesce_b_a 18446744073709551615
+if_______a_b 18446744073709551615
+if_______b_a -9223372036854775808
+ifnull___a_b -9223372036854775808
+ifnull___b_a 18446744073709551615
+least____a_b -9223372036854775808
+least____b_a -9223372036854775808
+greatest_a_b 18446744073709551615
+greatest_b_a 18446744073709551615
+CREATE TABLE t2 AS
+SELECT
+a AS ___________a,
+CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+COALESCE(a) AS coalesce___a,
+COALESCE(a, a) AS coalesce_a_a,
+IF(a IS NULL, a, a) AS if_______a_a,
+IFNULL(a, a) AS ifnull___a_a,
+LEAST(a, a) AS least____a_a,
+GREATEST(a, a) AS greatest_a_a,
+b AS ___________b,
+CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+COALESCE(b) AS coalesce___b,
+COALESCE(b, b) AS coalesce_b_b,
+IF(a IS NULL, b, b) AS if_______b_b,
+IFNULL(b, b) AS ifnull___b_b,
+LEAST(b, b) AS least____b_b,
+GREATEST(b, b) AS greatest_b_b
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `___________a` bigint(20) DEFAULT NULL,
+ `case_______a` bigint(20) DEFAULT NULL,
+ `case_____a_a` bigint(20) DEFAULT NULL,
+ `coalesce___a` bigint(20) DEFAULT NULL,
+ `coalesce_a_a` bigint(20) DEFAULT NULL,
+ `if_______a_a` bigint(20) DEFAULT NULL,
+ `ifnull___a_a` bigint(20) DEFAULT NULL,
+ `least____a_a` bigint(20) DEFAULT NULL,
+ `greatest_a_a` bigint(20) DEFAULT NULL,
+ `___________b` bigint(20) unsigned DEFAULT NULL,
+ `case_______b` bigint(20) unsigned DEFAULT NULL,
+ `case_____b_b` bigint(20) unsigned DEFAULT NULL,
+ `coalesce___b` bigint(20) unsigned DEFAULT NULL,
+ `coalesce_b_b` bigint(20) unsigned DEFAULT NULL,
+ `if_______b_b` bigint(20) unsigned DEFAULT NULL,
+ `ifnull___b_b` bigint(20) unsigned DEFAULT NULL,
+ `least____b_b` bigint(20) unsigned DEFAULT NULL,
+ `greatest_b_b` bigint(20) unsigned DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+CREATE TABLE t2 AS
+SELECT
+CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+COALESCE(a, b) AS coalesce_a_b,
+COALESCE(b, a) AS coalesce_b_a,
+IF(a IS NULL, a, b) AS if_______a_b,
+IF(a IS NULL, b, a) AS if_______b_a,
+IFNULL(a, b) AS ifnull___a_b,
+IFNULL(b, a) AS ifnull___b_a,
+LEAST(a, b) AS least____a_b,
+LEAST(b, a) AS least____b_a,
+GREATEST(a, b) AS greatest_a_b,
+GREATEST(b, a) AS greatest_b_a
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `case_____a_b` decimal(20,0) DEFAULT NULL,
+ `case_____b_a` decimal(20,0) DEFAULT NULL,
+ `coalesce_a_b` decimal(20,0) DEFAULT NULL,
+ `coalesce_b_a` decimal(20,0) DEFAULT NULL,
+ `if_______a_b` decimal(20,0) DEFAULT NULL,
+ `if_______b_a` decimal(20,0) DEFAULT NULL,
+ `ifnull___a_b` decimal(20,0) DEFAULT NULL,
+ `ifnull___b_a` decimal(20,0) DEFAULT NULL,
+ `least____a_b` decimal(20,0) DEFAULT NULL,
+ `least____b_a` decimal(20,0) DEFAULT NULL,
+ `greatest_a_b` decimal(20,0) DEFAULT NULL,
+ `greatest_b_a` decimal(20,0) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+#
+CREATE TABLE t1 (a BIGINT, b BIGINT);
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (-9223372036854775808,9223372036854775807);
+SELECT
+a AS ___________a,
+CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+COALESCE(a) AS coalesce___a,
+COALESCE(a, a) AS coalesce_a_a,
+IF(a IS NULL, a, a) AS if_______a_a,
+IFNULL(a, a) AS ifnull___a_a,
+LEAST(a, a) AS least____a_a,
+GREATEST(a, a) AS greatest_a_a,
+b AS ___________b,
+CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+COALESCE(b) AS coalesce___b,
+COALESCE(b, b) AS coalesce_b_b,
+IF(a IS NULL, b, b) AS if_______b_b,
+IFNULL(b, b) AS ifnull___b_b,
+LEAST(b, b) AS least____b_b,
+GREATEST(b, b) AS greatest_b_b
+FROM t1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t1 t1 a ___________a 8 20 20 Y 32768 0 63
+def case_______a 8 20 20 Y 32896 0 63
+def case_____a_a 8 20 20 Y 32896 0 63
+def coalesce___a 8 20 20 Y 32896 0 63
+def coalesce_a_a 8 20 20 Y 32896 0 63
+def if_______a_a 8 20 20 Y 32896 0 63
+def ifnull___a_a 8 20 20 Y 32896 0 63
+def least____a_a 8 20 20 Y 32896 0 63
+def greatest_a_a 8 20 20 Y 32896 0 63
+def test t1 t1 b ___________b 8 20 19 Y 32768 0 63
+def case_______b 8 20 19 Y 32896 0 63
+def case_____b_b 8 20 19 Y 32896 0 63
+def coalesce___b 8 20 19 Y 32896 0 63
+def coalesce_b_b 8 20 19 Y 32896 0 63
+def if_______b_b 8 20 19 Y 32896 0 63
+def ifnull___b_b 8 20 19 Y 32896 0 63
+def least____b_b 8 20 19 Y 32896 0 63
+def greatest_b_b 8 20 19 Y 32896 0 63
+___________a 1
+case_______a 1
+case_____a_a 1
+coalesce___a 1
+coalesce_a_a 1
+if_______a_a 1
+ifnull___a_a 1
+least____a_a 1
+greatest_a_a 1
+___________b 1
+case_______b 1
+case_____b_b 1
+coalesce___b 1
+coalesce_b_b 1
+if_______b_b 1
+ifnull___b_b 1
+least____b_b 1
+greatest_b_b 1
+___________a -9223372036854775808
+case_______a -9223372036854775808
+case_____a_a -9223372036854775808
+coalesce___a -9223372036854775808
+coalesce_a_a -9223372036854775808
+if_______a_a -9223372036854775808
+ifnull___a_a -9223372036854775808
+least____a_a -9223372036854775808
+greatest_a_a -9223372036854775808
+___________b 9223372036854775807
+case_______b 9223372036854775807
+case_____b_b 9223372036854775807
+coalesce___b 9223372036854775807
+coalesce_b_b 9223372036854775807
+if_______b_b 9223372036854775807
+ifnull___b_b 9223372036854775807
+least____b_b 9223372036854775807
+greatest_b_b 9223372036854775807
+SELECT
+CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+COALESCE(a, b) AS coalesce_a_b,
+COALESCE(b, a) AS coalesce_b_a,
+IF(a IS NULL, a, b) AS if_______a_b,
+IF(a IS NULL, b, a) AS if_______b_a,
+IFNULL(a, b) AS ifnull___a_b,
+IFNULL(b, a) AS ifnull___b_a,
+LEAST(a, b) AS least____a_b,
+LEAST(b, a) AS least____b_a,
+GREATEST(a, b) AS greatest_a_b,
+GREATEST(b, a) AS greatest_b_a
+FROM t1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def case_____a_b 8 20 20 Y 32896 0 63
+def case_____b_a 8 20 19 Y 32896 0 63
+def coalesce_a_b 8 20 20 Y 32896 0 63
+def coalesce_b_a 8 20 19 Y 32896 0 63
+def if_______a_b 8 20 19 Y 32896 0 63
+def if_______b_a 8 20 20 Y 32896 0 63
+def ifnull___a_b 8 20 20 Y 32896 0 63
+def ifnull___b_a 8 20 19 Y 32896 0 63
+def least____a_b 8 20 20 Y 32896 0 63
+def least____b_a 8 20 20 Y 32896 0 63
+def greatest_a_b 8 20 19 Y 32896 0 63
+def greatest_b_a 8 20 19 Y 32896 0 63
+case_____a_b 1
+case_____b_a 1
+coalesce_a_b 1
+coalesce_b_a 1
+if_______a_b 1
+if_______b_a 1
+ifnull___a_b 1
+ifnull___b_a 1
+least____a_b 1
+least____b_a 1
+greatest_a_b 1
+greatest_b_a 1
+case_____a_b -9223372036854775808
+case_____b_a 9223372036854775807
+coalesce_a_b -9223372036854775808
+coalesce_b_a 9223372036854775807
+if_______a_b 9223372036854775807
+if_______b_a -9223372036854775808
+ifnull___a_b -9223372036854775808
+ifnull___b_a 9223372036854775807
+least____a_b -9223372036854775808
+least____b_a -9223372036854775808
+greatest_a_b 9223372036854775807
+greatest_b_a 9223372036854775807
+CREATE TABLE t2 AS
+SELECT
+a AS ___________a,
+CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+COALESCE(a) AS coalesce___a,
+COALESCE(a, a) AS coalesce_a_a,
+IF(a IS NULL, a, a) AS if_______a_a,
+IFNULL(a, a) AS ifnull___a_a,
+LEAST(a, a) AS least____a_a,
+GREATEST(a, a) AS greatest_a_a,
+b AS ___________b,
+CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+COALESCE(b) AS coalesce___b,
+COALESCE(b, b) AS coalesce_b_b,
+IF(a IS NULL, b, b) AS if_______b_b,
+IFNULL(b, b) AS ifnull___b_b,
+LEAST(b, b) AS least____b_b,
+GREATEST(b, b) AS greatest_b_b
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `___________a` bigint(20) DEFAULT NULL,
+ `case_______a` bigint(20) DEFAULT NULL,
+ `case_____a_a` bigint(20) DEFAULT NULL,
+ `coalesce___a` bigint(20) DEFAULT NULL,
+ `coalesce_a_a` bigint(20) DEFAULT NULL,
+ `if_______a_a` bigint(20) DEFAULT NULL,
+ `ifnull___a_a` bigint(20) DEFAULT NULL,
+ `least____a_a` bigint(20) DEFAULT NULL,
+ `greatest_a_a` bigint(20) DEFAULT NULL,
+ `___________b` bigint(20) DEFAULT NULL,
+ `case_______b` bigint(20) DEFAULT NULL,
+ `case_____b_b` bigint(20) DEFAULT NULL,
+ `coalesce___b` bigint(20) DEFAULT NULL,
+ `coalesce_b_b` bigint(20) DEFAULT NULL,
+ `if_______b_b` bigint(20) DEFAULT NULL,
+ `ifnull___b_b` bigint(20) DEFAULT NULL,
+ `least____b_b` bigint(20) DEFAULT NULL,
+ `greatest_b_b` bigint(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+CREATE TABLE t2 AS
+SELECT
+CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+COALESCE(a, b) AS coalesce_a_b,
+COALESCE(b, a) AS coalesce_b_a,
+IF(a IS NULL, a, b) AS if_______a_b,
+IF(a IS NULL, b, a) AS if_______b_a,
+IFNULL(a, b) AS ifnull___a_b,
+IFNULL(b, a) AS ifnull___b_a,
+LEAST(a, b) AS least____a_b,
+LEAST(b, a) AS least____b_a,
+GREATEST(a, b) AS greatest_a_b,
+GREATEST(b, a) AS greatest_b_a
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `case_____a_b` bigint(20) DEFAULT NULL,
+ `case_____b_a` bigint(20) DEFAULT NULL,
+ `coalesce_a_b` bigint(20) DEFAULT NULL,
+ `coalesce_b_a` bigint(20) DEFAULT NULL,
+ `if_______a_b` bigint(20) DEFAULT NULL,
+ `if_______b_a` bigint(20) DEFAULT NULL,
+ `ifnull___a_b` bigint(20) DEFAULT NULL,
+ `ifnull___b_a` bigint(20) DEFAULT NULL,
+ `least____a_b` bigint(20) DEFAULT NULL,
+ `least____b_a` bigint(20) DEFAULT NULL,
+ `greatest_a_b` bigint(20) DEFAULT NULL,
+ `greatest_b_a` bigint(20) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+#
+CREATE TABLE t1 (a INT, b BIT(8));
+INSERT INTO t1 VALUES (-2147483648,0x32);
+SELECT
+a AS ___________a,
+CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+COALESCE(a) AS coalesce___a,
+COALESCE(a, a) AS coalesce_a_a,
+IF(a IS NULL, a, a) AS if_______a_a,
+IFNULL(a, a) AS ifnull___a_a,
+LEAST(a, a) AS least____a_a,
+GREATEST(a, a) AS greatest_a_a,
+b AS ___________b,
+CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+COALESCE(b) AS coalesce___b,
+COALESCE(b, b) AS coalesce_b_b,
+IF(a IS NULL, b, b) AS if_______b_b,
+IFNULL(b, b) AS ifnull___b_b,
+LEAST(b, b) AS least____b_b,
+GREATEST(b, b) AS greatest_b_b
+FROM t1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t1 t1 a ___________a 3 11 11 Y 32768 0 63
+def case_______a 3 11 11 Y 32896 0 63
+def case_____a_a 3 11 11 Y 32896 0 63
+def coalesce___a 3 11 11 Y 32896 0 63
+def coalesce_a_a 3 11 11 Y 32896 0 63
+def if_______a_a 3 11 11 Y 32896 0 63
+def ifnull___a_a 3 11 11 Y 32896 0 63
+def least____a_a 3 11 11 Y 32896 0 63
+def greatest_a_a 3 11 11 Y 32896 0 63
+def test t1 t1 b ___________b 16 8 1 Y 32 0 63
+def case_______b 16 8 2 Y 160 0 63
+def case_____b_b 16 8 2 Y 160 0 63
+def coalesce___b 16 8 2 Y 160 0 63
+def coalesce_b_b 16 8 2 Y 160 0 63
+def if_______b_b 16 8 2 Y 160 0 63
+def ifnull___b_b 16 8 2 Y 160 0 63
+def least____b_b 16 8 2 Y 160 0 63
+def greatest_b_b 16 8 2 Y 160 0 63
+___________a -2147483648
+case_______a -2147483648
+case_____a_a -2147483648
+coalesce___a -2147483648
+coalesce_a_a -2147483648
+if_______a_a -2147483648
+ifnull___a_a -2147483648
+least____a_a -2147483648
+greatest_a_a -2147483648
+___________b 2
+case_______b 50
+case_____b_b 50
+coalesce___b 50
+coalesce_b_b 50
+if_______b_b 50
+ifnull___b_b 50
+least____b_b 50
+greatest_b_b 50
+SELECT
+CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+COALESCE(a, b) AS coalesce_a_b,
+COALESCE(b, a) AS coalesce_b_a,
+IF(a IS NULL, a, b) AS if_______a_b,
+IF(a IS NULL, b, a) AS if_______b_a,
+IFNULL(a, b) AS ifnull___a_b,
+IFNULL(b, a) AS ifnull___b_a,
+LEAST(a, b) AS least____a_b,
+LEAST(b, a) AS least____b_a,
+GREATEST(a, b) AS greatest_a_b,
+GREATEST(b, a) AS greatest_b_a
+FROM t1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def case_____a_b 246 11 11 Y 32896 0 63
+def case_____b_a 246 11 2 Y 32896 0 63
+def coalesce_a_b 246 11 11 Y 32896 0 63
+def coalesce_b_a 246 11 2 Y 32896 0 63
+def if_______a_b 246 11 2 Y 32896 0 63
+def if_______b_a 246 11 11 Y 32896 0 63
+def ifnull___a_b 246 11 11 Y 32896 0 63
+def ifnull___b_a 246 11 2 Y 32896 0 63
+def least____a_b 246 11 11 Y 32896 0 63
+def least____b_a 246 11 11 Y 32896 0 63
+def greatest_a_b 246 11 2 Y 32896 0 63
+def greatest_b_a 246 11 2 Y 32896 0 63
+case_____a_b -2147483648
+case_____b_a 50
+coalesce_a_b -2147483648
+coalesce_b_a 50
+if_______a_b 50
+if_______b_a -2147483648
+ifnull___a_b -2147483648
+ifnull___b_a 50
+least____a_b -2147483648
+least____b_a -2147483648
+greatest_a_b 50
+greatest_b_a 50
+CREATE TABLE t2 AS
+SELECT
+a AS ___________a,
+CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+COALESCE(a) AS coalesce___a,
+COALESCE(a, a) AS coalesce_a_a,
+IF(a IS NULL, a, a) AS if_______a_a,
+IFNULL(a, a) AS ifnull___a_a,
+LEAST(a, a) AS least____a_a,
+GREATEST(a, a) AS greatest_a_a,
+b AS ___________b,
+CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+COALESCE(b) AS coalesce___b,
+COALESCE(b, b) AS coalesce_b_b,
+IF(a IS NULL, b, b) AS if_______b_b,
+IFNULL(b, b) AS ifnull___b_b,
+LEAST(b, b) AS least____b_b,
+GREATEST(b, b) AS greatest_b_b
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `___________a` int(11) DEFAULT NULL,
+ `case_______a` int(11) DEFAULT NULL,
+ `case_____a_a` int(11) DEFAULT NULL,
+ `coalesce___a` int(11) DEFAULT NULL,
+ `coalesce_a_a` int(11) DEFAULT NULL,
+ `if_______a_a` int(11) DEFAULT NULL,
+ `ifnull___a_a` int(11) DEFAULT NULL,
+ `least____a_a` int(11) DEFAULT NULL,
+ `greatest_a_a` int(11) DEFAULT NULL,
+ `___________b` bit(8) DEFAULT NULL,
+ `case_______b` int(8) unsigned DEFAULT NULL,
+ `case_____b_b` int(8) unsigned DEFAULT NULL,
+ `coalesce___b` int(8) unsigned DEFAULT NULL,
+ `coalesce_b_b` int(8) unsigned DEFAULT NULL,
+ `if_______b_b` int(8) unsigned DEFAULT NULL,
+ `ifnull___b_b` bit(8) DEFAULT NULL,
+ `least____b_b` int(8) unsigned DEFAULT NULL,
+ `greatest_b_b` int(8) unsigned DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+CREATE TABLE t2 AS
+SELECT
+CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+COALESCE(a, b) AS coalesce_a_b,
+COALESCE(b, a) AS coalesce_b_a,
+IF(a IS NULL, a, b) AS if_______a_b,
+IF(a IS NULL, b, a) AS if_______b_a,
+IFNULL(a, b) AS ifnull___a_b,
+IFNULL(b, a) AS ifnull___b_a,
+LEAST(a, b) AS least____a_b,
+LEAST(b, a) AS least____b_a,
+GREATEST(a, b) AS greatest_a_b,
+GREATEST(b, a) AS greatest_b_a
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `case_____a_b` decimal(10,0) DEFAULT NULL,
+ `case_____b_a` decimal(10,0) DEFAULT NULL,
+ `coalesce_a_b` decimal(10,0) DEFAULT NULL,
+ `coalesce_b_a` decimal(10,0) DEFAULT NULL,
+ `if_______a_b` decimal(10,0) DEFAULT NULL,
+ `if_______b_a` decimal(10,0) DEFAULT NULL,
+ `ifnull___a_b` decimal(10,0) DEFAULT NULL,
+ `ifnull___b_a` decimal(10,0) DEFAULT NULL,
+ `least____a_b` decimal(10,0) DEFAULT NULL,
+ `least____b_a` decimal(10,0) DEFAULT NULL,
+ `greatest_a_b` decimal(10,0) DEFAULT NULL,
+ `greatest_b_a` decimal(10,0) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+#
+CREATE TABLE t1 (a INT UNSIGNED, b BIT(8));
+INSERT INTO t1 VALUES (4294967295,0x32);
+SELECT
+a AS ___________a,
+CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+COALESCE(a) AS coalesce___a,
+COALESCE(a, a) AS coalesce_a_a,
+IF(a IS NULL, a, a) AS if_______a_a,
+IFNULL(a, a) AS ifnull___a_a,
+LEAST(a, a) AS least____a_a,
+GREATEST(a, a) AS greatest_a_a,
+b AS ___________b,
+CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+COALESCE(b) AS coalesce___b,
+COALESCE(b, b) AS coalesce_b_b,
+IF(a IS NULL, b, b) AS if_______b_b,
+IFNULL(b, b) AS ifnull___b_b,
+LEAST(b, b) AS least____b_b,
+GREATEST(b, b) AS greatest_b_b
+FROM t1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t1 t1 a ___________a 3 10 10 Y 32800 0 63
+def case_______a 3 10 10 Y 32928 0 63
+def case_____a_a 3 10 10 Y 32928 0 63
+def coalesce___a 3 10 10 Y 32928 0 63
+def coalesce_a_a 3 10 10 Y 32928 0 63
+def if_______a_a 3 10 10 Y 32928 0 63
+def ifnull___a_a 3 10 10 Y 32928 0 63
+def least____a_a 3 10 10 Y 32928 0 63
+def greatest_a_a 3 10 10 Y 32928 0 63
+def test t1 t1 b ___________b 16 8 1 Y 32 0 63
+def case_______b 16 8 2 Y 160 0 63
+def case_____b_b 16 8 2 Y 160 0 63
+def coalesce___b 16 8 2 Y 160 0 63
+def coalesce_b_b 16 8 2 Y 160 0 63
+def if_______b_b 16 8 2 Y 160 0 63
+def ifnull___b_b 16 8 2 Y 160 0 63
+def least____b_b 16 8 2 Y 160 0 63
+def greatest_b_b 16 8 2 Y 160 0 63
+___________a 4294967295
+case_______a 4294967295
+case_____a_a 4294967295
+coalesce___a 4294967295
+coalesce_a_a 4294967295
+if_______a_a 4294967295
+ifnull___a_a 4294967295
+least____a_a 4294967295
+greatest_a_a 4294967295
+___________b 2
+case_______b 50
+case_____b_b 50
+coalesce___b 50
+coalesce_b_b 50
+if_______b_b 50
+ifnull___b_b 50
+least____b_b 50
+greatest_b_b 50
+SELECT
+CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+COALESCE(a, b) AS coalesce_a_b,
+COALESCE(b, a) AS coalesce_b_a,
+IF(a IS NULL, a, b) AS if_______a_b,
+IF(a IS NULL, b, a) AS if_______b_a,
+IFNULL(a, b) AS ifnull___a_b,
+IFNULL(b, a) AS ifnull___b_a,
+LEAST(a, b) AS least____a_b,
+LEAST(b, a) AS least____b_a,
+GREATEST(a, b) AS greatest_a_b,
+GREATEST(b, a) AS greatest_b_a
+FROM t1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def case_____a_b 8 10 10 Y 32928 0 63
+def case_____b_a 8 10 2 Y 32928 0 63
+def coalesce_a_b 8 10 10 Y 32928 0 63
+def coalesce_b_a 8 10 2 Y 32928 0 63
+def if_______a_b 8 10 2 Y 32928 0 63
+def if_______b_a 8 10 10 Y 32928 0 63
+def ifnull___a_b 8 10 10 Y 32928 0 63
+def ifnull___b_a 8 10 2 Y 32928 0 63
+def least____a_b 253 10 2 Y 32 0 8
+def least____b_a 253 10 2 Y 32 0 8
+def greatest_a_b 253 10 10 Y 32 0 8
+def greatest_b_a 253 10 10 Y 32 0 8
+case_____a_b 4294967295
+case_____b_a 50
+coalesce_a_b 4294967295
+coalesce_b_a 50
+if_______a_b 50
+if_______b_a 4294967295
+ifnull___a_b 4294967295
+ifnull___b_a 50
+least____a_b 50
+least____b_a 50
+greatest_a_b 4294967295
+greatest_b_a 4294967295
+CREATE TABLE t2 AS
+SELECT
+a AS ___________a,
+CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+COALESCE(a) AS coalesce___a,
+COALESCE(a, a) AS coalesce_a_a,
+IF(a IS NULL, a, a) AS if_______a_a,
+IFNULL(a, a) AS ifnull___a_a,
+LEAST(a, a) AS least____a_a,
+GREATEST(a, a) AS greatest_a_a,
+b AS ___________b,
+CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+COALESCE(b) AS coalesce___b,
+COALESCE(b, b) AS coalesce_b_b,
+IF(a IS NULL, b, b) AS if_______b_b,
+IFNULL(b, b) AS ifnull___b_b,
+LEAST(b, b) AS least____b_b,
+GREATEST(b, b) AS greatest_b_b
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `___________a` int(10) unsigned DEFAULT NULL,
+ `case_______a` int(10) unsigned DEFAULT NULL,
+ `case_____a_a` int(10) unsigned DEFAULT NULL,
+ `coalesce___a` int(10) unsigned DEFAULT NULL,
+ `coalesce_a_a` int(10) unsigned DEFAULT NULL,
+ `if_______a_a` int(10) unsigned DEFAULT NULL,
+ `ifnull___a_a` int(10) unsigned DEFAULT NULL,
+ `least____a_a` int(10) unsigned DEFAULT NULL,
+ `greatest_a_a` int(10) unsigned DEFAULT NULL,
+ `___________b` bit(8) DEFAULT NULL,
+ `case_______b` int(8) unsigned DEFAULT NULL,
+ `case_____b_b` int(8) unsigned DEFAULT NULL,
+ `coalesce___b` int(8) unsigned DEFAULT NULL,
+ `coalesce_b_b` int(8) unsigned DEFAULT NULL,
+ `if_______b_b` int(8) unsigned DEFAULT NULL,
+ `ifnull___b_b` bit(8) DEFAULT NULL,
+ `least____b_b` int(8) unsigned DEFAULT NULL,
+ `greatest_b_b` int(8) unsigned DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+CREATE TABLE t2 AS
+SELECT
+CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+COALESCE(a, b) AS coalesce_a_b,
+COALESCE(b, a) AS coalesce_b_a,
+IF(a IS NULL, a, b) AS if_______a_b,
+IF(a IS NULL, b, a) AS if_______b_a,
+IFNULL(a, b) AS ifnull___a_b,
+IFNULL(b, a) AS ifnull___b_a,
+LEAST(a, b) AS least____a_b,
+LEAST(b, a) AS least____b_a,
+GREATEST(a, b) AS greatest_a_b,
+GREATEST(b, a) AS greatest_b_a
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `case_____a_b` int(10) unsigned DEFAULT NULL,
+ `case_____b_a` int(10) unsigned DEFAULT NULL,
+ `coalesce_a_b` int(10) unsigned DEFAULT NULL,
+ `coalesce_b_a` int(10) unsigned DEFAULT NULL,
+ `if_______a_b` int(10) unsigned DEFAULT NULL,
+ `if_______b_a` int(10) unsigned DEFAULT NULL,
+ `ifnull___a_b` bigint(10) unsigned DEFAULT NULL,
+ `ifnull___b_a` bigint(10) unsigned DEFAULT NULL,
+ `least____a_b` int(10) unsigned DEFAULT NULL,
+ `least____b_a` int(10) unsigned DEFAULT NULL,
+ `greatest_a_b` int(10) unsigned DEFAULT NULL,
+ `greatest_b_a` int(10) unsigned DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+#
+CREATE TABLE t1 (a BIT(7), b BIT(8));
+INSERT INTO t1 VALUES (0x32,0x32);
+SELECT
+a AS ___________a,
+CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+COALESCE(a) AS coalesce___a,
+COALESCE(a, a) AS coalesce_a_a,
+IF(a IS NULL, a, a) AS if_______a_a,
+IFNULL(a, a) AS ifnull___a_a,
+LEAST(a, a) AS least____a_a,
+GREATEST(a, a) AS greatest_a_a,
+b AS ___________b,
+CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+COALESCE(b) AS coalesce___b,
+COALESCE(b, b) AS coalesce_b_b,
+IF(a IS NULL, b, b) AS if_______b_b,
+IFNULL(b, b) AS ifnull___b_b,
+LEAST(b, b) AS least____b_b,
+GREATEST(b, b) AS greatest_b_b
+FROM t1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t1 t1 a ___________a 16 7 1 Y 32 0 63
+def case_______a 16 7 2 Y 160 0 63
+def case_____a_a 16 7 2 Y 160 0 63
+def coalesce___a 16 7 2 Y 160 0 63
+def coalesce_a_a 16 7 2 Y 160 0 63
+def if_______a_a 16 7 2 Y 160 0 63
+def ifnull___a_a 16 7 2 Y 160 0 63
+def least____a_a 16 7 2 Y 160 0 63
+def greatest_a_a 16 7 2 Y 160 0 63
+def test t1 t1 b ___________b 16 8 1 Y 32 0 63
+def case_______b 16 8 2 Y 160 0 63
+def case_____b_b 16 8 2 Y 160 0 63
+def coalesce___b 16 8 2 Y 160 0 63
+def coalesce_b_b 16 8 2 Y 160 0 63
+def if_______b_b 16 8 2 Y 160 0 63
+def ifnull___b_b 16 8 2 Y 160 0 63
+def least____b_b 16 8 2 Y 160 0 63
+def greatest_b_b 16 8 2 Y 160 0 63
+___________a 2
+case_______a 50
+case_____a_a 50
+coalesce___a 50
+coalesce_a_a 50
+if_______a_a 50
+ifnull___a_a 50
+least____a_a 50
+greatest_a_a 50
+___________b 2
+case_______b 50
+case_____b_b 50
+coalesce___b 50
+coalesce_b_b 50
+if_______b_b 50
+ifnull___b_b 50
+least____b_b 50
+greatest_b_b 50
+SELECT
+CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+COALESCE(a, b) AS coalesce_a_b,
+COALESCE(b, a) AS coalesce_b_a,
+IF(a IS NULL, a, b) AS if_______a_b,
+IF(a IS NULL, b, a) AS if_______b_a,
+IFNULL(a, b) AS ifnull___a_b,
+IFNULL(b, a) AS ifnull___b_a,
+LEAST(a, b) AS least____a_b,
+LEAST(b, a) AS least____b_a,
+GREATEST(a, b) AS greatest_a_b,
+GREATEST(b, a) AS greatest_b_a
+FROM t1;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def case_____a_b 16 8 2 Y 160 0 63
+def case_____b_a 16 8 2 Y 160 0 63
+def coalesce_a_b 16 8 2 Y 160 0 63
+def coalesce_b_a 16 8 2 Y 160 0 63
+def if_______a_b 16 8 2 Y 160 0 63
+def if_______b_a 16 8 2 Y 160 0 63
+def ifnull___a_b 16 8 2 Y 160 0 63
+def ifnull___b_a 16 8 2 Y 160 0 63
+def least____a_b 16 8 2 Y 160 0 63
+def least____b_a 16 8 2 Y 160 0 63
+def greatest_a_b 16 8 2 Y 160 0 63
+def greatest_b_a 16 8 2 Y 160 0 63
+case_____a_b 50
+case_____b_a 50
+coalesce_a_b 50
+coalesce_b_a 50
+if_______a_b 50
+if_______b_a 50
+ifnull___a_b 50
+ifnull___b_a 50
+least____a_b 50
+least____b_a 50
+greatest_a_b 50
+greatest_b_a 50
+CREATE TABLE t2 AS
+SELECT
+a AS ___________a,
+CASE WHEN a IS NOT NULL THEN a END AS case_______a,
+CASE WHEN a IS NOT NULL THEN a ELSE a END AS case_____a_a,
+COALESCE(a) AS coalesce___a,
+COALESCE(a, a) AS coalesce_a_a,
+IF(a IS NULL, a, a) AS if_______a_a,
+IFNULL(a, a) AS ifnull___a_a,
+LEAST(a, a) AS least____a_a,
+GREATEST(a, a) AS greatest_a_a,
+b AS ___________b,
+CASE WHEN a IS NOT NULL THEN b END AS case_______b,
+CASE WHEN a IS NOT NULL THEN b ELSE b END AS case_____b_b,
+COALESCE(b) AS coalesce___b,
+COALESCE(b, b) AS coalesce_b_b,
+IF(a IS NULL, b, b) AS if_______b_b,
+IFNULL(b, b) AS ifnull___b_b,
+LEAST(b, b) AS least____b_b,
+GREATEST(b, b) AS greatest_b_b
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `___________a` bit(7) DEFAULT NULL,
+ `case_______a` int(7) unsigned DEFAULT NULL,
+ `case_____a_a` int(7) unsigned DEFAULT NULL,
+ `coalesce___a` int(7) unsigned DEFAULT NULL,
+ `coalesce_a_a` int(7) unsigned DEFAULT NULL,
+ `if_______a_a` int(7) unsigned DEFAULT NULL,
+ `ifnull___a_a` bit(7) DEFAULT NULL,
+ `least____a_a` int(7) unsigned DEFAULT NULL,
+ `greatest_a_a` int(7) unsigned DEFAULT NULL,
+ `___________b` bit(8) DEFAULT NULL,
+ `case_______b` int(8) unsigned DEFAULT NULL,
+ `case_____b_b` int(8) unsigned DEFAULT NULL,
+ `coalesce___b` int(8) unsigned DEFAULT NULL,
+ `coalesce_b_b` int(8) unsigned DEFAULT NULL,
+ `if_______b_b` int(8) unsigned DEFAULT NULL,
+ `ifnull___b_b` bit(8) DEFAULT NULL,
+ `least____b_b` int(8) unsigned DEFAULT NULL,
+ `greatest_b_b` int(8) unsigned DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+CREATE TABLE t2 AS
+SELECT
+CASE WHEN a IS NOT NULL THEN a ELSE b END AS case_____a_b,
+CASE WHEN a IS NOT NULL THEN b ELSE a END AS case_____b_a,
+COALESCE(a, b) AS coalesce_a_b,
+COALESCE(b, a) AS coalesce_b_a,
+IF(a IS NULL, a, b) AS if_______a_b,
+IF(a IS NULL, b, a) AS if_______b_a,
+IFNULL(a, b) AS ifnull___a_b,
+IFNULL(b, a) AS ifnull___b_a,
+LEAST(a, b) AS least____a_b,
+LEAST(b, a) AS least____b_a,
+GREATEST(a, b) AS greatest_a_b,
+GREATEST(b, a) AS greatest_b_a
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `case_____a_b` int(8) unsigned DEFAULT NULL,
+ `case_____b_a` int(8) unsigned DEFAULT NULL,
+ `coalesce_a_b` int(8) unsigned DEFAULT NULL,
+ `coalesce_b_a` int(8) unsigned DEFAULT NULL,
+ `if_______a_b` int(8) unsigned DEFAULT NULL,
+ `if_______b_a` int(8) unsigned DEFAULT NULL,
+ `ifnull___a_b` bit(8) DEFAULT NULL,
+ `ifnull___b_a` bit(8) DEFAULT NULL,
+ `least____a_b` int(8) unsigned DEFAULT NULL,
+ `least____b_a` int(8) unsigned DEFAULT NULL,
+ `greatest_a_b` int(8) unsigned DEFAULT NULL,
+ `greatest_b_a` int(8) unsigned DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+#
+# End of 10.1 tests
+#
diff --git a/mysql-test/t/func_hybrid_type.test b/mysql-test/t/func_hybrid_type.test
new file mode 100644
index 00000000000..55bfead668c
--- /dev/null
+++ b/mysql-test/t/func_hybrid_type.test
@@ -0,0 +1,63 @@
+--echo #
+--echo # Start of 10.1 tests
+--echo #
+
+--echo #
+--echo # MDEV-8865 Wrong field type or metadata for COALESCE(signed_int_column, unsigned_int_column)
+--echo #
+
+--echo #
+CREATE TABLE t1 (a INT, b INT UNSIGNED);
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (-1,1);
+INSERT INTO t1 VALUES (-2147483648,4294967295);
+--source include/func_hybrid_type.inc
+DROP TABLE t1;
+
+--echo #
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (-2147483648,2147483647);
+--source include/func_hybrid_type.inc
+DROP TABLE t1;
+
+--echo #
+CREATE TABLE t1 (a BIGINT, b BIGINT UNSIGNED);
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (-9223372036854775808,0xFFFFFFFFFFFFFFFF);
+--source include/func_hybrid_type.inc
+DROP TABLE t1;
+
+--echo #
+CREATE TABLE t1 (a BIGINT, b BIGINT);
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (-9223372036854775808,9223372036854775807);
+--source include/func_hybrid_type.inc
+DROP TABLE t1;
+
+# Testing BIT(N) types.
+# Using safe BIT(N) type and value to make sure
+# that "file func_hybrid_type.test" tells "ASCII text".
+
+--echo #
+CREATE TABLE t1 (a INT, b BIT(8));
+INSERT INTO t1 VALUES (-2147483648,0x32);
+--source include/func_hybrid_type.inc
+DROP TABLE t1;
+
+--echo #
+CREATE TABLE t1 (a INT UNSIGNED, b BIT(8));
+INSERT INTO t1 VALUES (4294967295,0x32);
+--source include/func_hybrid_type.inc
+DROP TABLE t1;
+
+--echo #
+CREATE TABLE t1 (a BIT(7), b BIT(8));
+INSERT INTO t1 VALUES (0x32,0x32);
+--source include/func_hybrid_type.inc
+DROP TABLE t1;
+
+
+--echo #
+--echo # End of 10.1 tests
+--echo #