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

UNION and COALESCE produce different field types for DECIMAL+INT

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.0, 10.1, 10.2
    • Fix Version/s: 10.3.1
    • Component/s: OTHER
    • Labels:

      Description

      CREATE OR REPLACE TABLE t1 AS SELECT COALESCE(10.1,CAST(10 AS UNSIGNED)) AS a;
      SHOW CREATE TABLE t1;

      returns

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

      Now if I join the same arguments in UNION:

      CREATE OR REPLACE TABLE t1 AS SELECT 10.1 AS a UNION SELECT CAST(10 AS UNSIGNED);
      SHOW CREATE TABLE t1;

      it returns:

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

      DECIMAL(18,1) for these arguments looks too huge.
      UNION should create DECIMAL(3,1), like COALESCE does.

        Attachments

          Issue Links

            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:
                  Resolved: