From c09f22bab535bccc1687a3b06e03dbaf4fc3ae46 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 7 Nov 2017 12:57:11 +0400 Subject: MDEV-8867 Wrong field type or metadata for COALESCE(bit_column, 1) This problem was earlier fixed by the patch for MDEV-8910. Adding tests only. --- mysql-test/r/type_bit.result | 24 ++++++++++++++++++++++++ mysql-test/t/type_bit.test | 19 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result index 639a97be27b..4136eb4dff7 100644 --- a/mysql-test/r/type_bit.result +++ b/mysql-test/r/type_bit.result @@ -806,3 +806,27 @@ SUM(a) NULL DROP TABLE t1; End of 5.1 tests +# +# Start of 10.1 tests +# +# +# MDEV-8867 Wrong field type or metadata for COALESCE(bit_column, 1) +# +CREATE TABLE t1 (val bit(1)); +INSERT INTO t1 VALUES (0); +CREATE TABLE t2 AS SELECT COALESCE(val, 1) AS c FROM t1; +SELECT * FROM t2; +c +0 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `c` decimal(1,0) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t2; +SELECT COALESCE(val, 1) FROM t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def COALESCE(val, 1) 246 2 1 Y 32896 0 63 +COALESCE(val, 1) +0 +DROP TABLE t1; diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index 2ca608e76ff..01a610999bd 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -439,3 +439,22 @@ SELECT SUM(a) FROM t1 GROUP BY c, b, a; DROP TABLE t1; --echo End of 5.1 tests + +--echo # +--echo # Start of 10.1 tests +--echo # + +--echo # +--echo # MDEV-8867 Wrong field type or metadata for COALESCE(bit_column, 1) +--echo # + +CREATE TABLE t1 (val bit(1)); +INSERT INTO t1 VALUES (0); +CREATE TABLE t2 AS SELECT COALESCE(val, 1) AS c FROM t1; +SELECT * FROM t2; +SHOW CREATE TABLE t2; +DROP TABLE t2; +--enable_metadata +SELECT COALESCE(val, 1) FROM t1; +--disable_metadata +DROP TABLE t1; -- cgit v1.2.1