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

NULLIF does not preserve data type

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 5.5.36, 10.0.9
    • 5.5(EOL)
    • None
    • None

    Description

      This script:

      DROP TABLE IF EXISTS t1,t2;
      CREATE TABLE t1 (a DATE, b DATE);
      CREATE TABLE t2 AS SELECT COALESCE(a,b), NULLIF(a,b) FROM t1; 
      SHOW COLUMNS FROM t2;

      creates these columns:

      +---------------+-------------+------+-----+---------+-------+
      | Field         | Type        | Null | Key | Default | Extra |
      +---------------+-------------+------+-----+---------+-------+
      | COALESCE(a,b) | date        | YES  |     | NULL    |       |
      | NULLIF(a,b)   | varchar(10) | YES  |     | NULL    |       |
      +---------------+-------------+------+-----+---------+-------+

      NULLIF erroneously created a VARCHAR column.

      Notice, on the contrary, COALESCE correctly created a DATE column.

      Attachments

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.