Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-11458

Inconsistency when mixing NULL and ENUM in UNION vs hybrid functions

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 5.5, 10.1, 10.2, 10.3
    • Fix Version/s: 10.3, 10.4
    • Component/s: Data types
    • Labels:
      None

      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.

        Attachments

          Activity

            People

            Assignee:
            bar Alexander Barkov
            Reporter:
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: