Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL)
-
None
Description
I run this script:
DROP TABLE IF EXISTS t1,t2,t3; |
CREATE TABLE t1 (a CHAR(1), b CHAR(2)); |
CREATE TABLE t2 AS SELECT COALESCE(a,b) AS c FROM t1; |
CREATE TABLE t3 AS SELECT a FROM t1 UNION SELECT b FROM t1; |
DESC t2; |
DESC t3; |
It produces these two result sets:
+-------+------------+------+-----+---------+-------+
|
| Field | Type | Null | Key | Default | Extra |
|
+-------+------------+------+-----+---------+-------+
|
| c | varchar(2) | YES | | NULL | |
|
+-------+------------+------+-----+---------+-------+
|
+-------+---------+------+-----+---------+-------+
|
| Field | Type | Null | Key | Default | Extra |
|
+-------+---------+------+-----+---------+-------+
|
| a | char(2) | YES | | NULL | |
|
+-------+---------+------+-----+---------+-------+
|
Notice:
- CHAR + CHAR gives VARCHAR in COALESCE
- CHAR + CHAR gives CHAR in UNION
The latter looks more correct.
Hybrid functions should be fixed to preserve the data type.