[MDEV-11458] Inconsistency when mixing NULL and ENUM in UNION vs hybrid functions Created: 2016-12-02  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 5.5, 10.1, 10.2, 10.3
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: None

Epic Link: Data type cleanups

 Description   

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a ENUM('a'));
SHOW CREATE TABLE t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t2 AS SELECT COALESCE(a,NULL) FROM t1;
SHOW CREATE TABLE t2;

+-------+---------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                            |
+-------+---------------------------------------------------------------------------------------------------------+
| t2    | CREATE TABLE `t2` (
  `COALESCE(a,NULL)` varchar(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+---------------------------------------------------------------------------------------------------------+

DROP TABLE IF EXISTS t2;
CREATE TABLE t2 AS SELECT a FROM t1 UNION SELECT NULL;
SHOW CREATE TABLE t2;

+-------+-----------------------------------------------------------------------------------------+
| Table | Create Table                                                                            |
+-------+-----------------------------------------------------------------------------------------+
| t2    | CREATE TABLE `t2` (
  `a` enum('a') DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+-----------------------------------------------------------------------------------------+

Notice, it creates a ENUM column with UNION and a VARCHAR column with COALESCE.
It would be nice to have the same data type in both cases.


Generated at Thu Feb 08 07:50:07 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.