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

Crash with CASE WHEN TRUE THEN COALESCE(CAST(NULL AS UNSIGNED)) ELSE 4 END

    XMLWordPrintable

Details

    • 5.5.49

    Description

      This script crashes the server:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 SELECT CASE WHEN TRUE THEN COALESCE(CAST(NULL AS UNSIGNED)) ELSE 4 END AS a;
      

      The problem is not repeatable in MySQL-5.7.11.

      It seems it's trying to create a DECIMAL(0,0) column. If I change the script slightly:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 SELECT CASE WHEN TRUE THEN COALESCE(CAST(NULL AS UNSIGNED)) ELSE 40 END AS a;
      SHOW CREATE TABLE t1;
      

      it does not crash, but the result is incorrect:

      +-------+--------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                               |
      +-------+--------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `a` decimal(1,0) DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+--------------------------------------------------------------------------------------------+
      

      The field data type DECIMAL(1,0) is too small. It should probably be DECIMAL(2,0).

      MySQL-5.7.11 creates a DECIMAL(2,0) column.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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