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

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 5.5, 10.1, 10.2, 10.3
    • 10.4
    • Data types
    • 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

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

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.