[MDEV-12599] UNION is not symmetric when mixing INT and CHAR Created: 2017-04-27  Updated: 2017-05-17  Resolved: 2017-05-17

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.1, 10.2, 10.3
Fix Version/s: 10.3.1

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: datatype

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed
Relates
relates to MDEV-12594 UNION between fixed length double col... Closed
relates to MDEV-12595 UNION converts INT to BIGINT Closed
relates to MDEV-12775 Reuse data type aggregation code for ... Closed

 Description   

CREATE OR REPLACE TABLE t1 AS SELECT 1, 'a' AS c1 UNION SELECT 'a', 1;
SHOW CREATE TABLE t1;

+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                  |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `1` varchar(1) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `c1` varchar(20) CHARACTER SET utf8 NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Notice:

  • INT+CHAR created a varchar(1) column
  • CHAR+INT created a varchar(20) column

Note, if I mix the same expression in hybrid functions, the results are symmetric:

CREATE OR REPLACE TABLE t1 AS SELECT COALESCE(1,'a'), COALESCE('a',1);
SHOW CREATE TABLE t1;

+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                            |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `COALESCE(1,'a')` varchar(1) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `COALESCE('a',1)` varchar(1) CHARACTER SET utf8 NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+



 Comments   
Comment by Alexander Barkov [ 2017-05-17 ]

This problem was fixed by the patch for MDEV-12775

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