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

COALESCE(12345678900) makes a column of a wrong type and truncates the data

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.1(EOL), 10.2(EOL)
    • 10.3.1
    • OTHER
    • None

    Description

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 AS SELECT 12345678900 AS c1, COALESCE(12345678900) AS c2;
      SELECT * FROM t1;
      SHOW CREATE TABLE t1;
      

      +-------------+------------+
      | c1          | c2         |
      +-------------+------------+
      | 12345678900 | 2147483647 |
      +-------------+------------+
      

      +-------+----------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                   |
      +-------+----------------------------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `c1` bigint(11) NOT NULL,
        `c2` int(11) NOT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+---------------------------------------------------------------------------------------------------------------
      

      The expected result to create a BIGINT column for both expressions, and return 12345678900 for both columns.

      Attachments

        Issue Links

          Activity

            The same problem is repeatable with smaller numbers:

            CREATE OR REPLACE TABLE t1 AS SELECT 2147483648 AS c1, COALESCE(2147483648) AS c2;
            SHOW CREATE TABLE t1;
            SELECT * FROM t1;
            

            +-------+----------------------------------------------------------------------------------------------------------------+
            | Table | Create Table                                                                                                   |
            +-------+----------------------------------------------------------------------------------------------------------------+
            | t1    | CREATE TABLE `t1` (
              `c1` bigint(10) NOT NULL,
              `c2` int(10) NOT NULL
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------------------------------+
            

            +------------+------------+
            | c1         | c2         |
            +------------+------------+
            | 2147483648 | 2147483647 |
            +------------+------------+
            

            Notice, the data type and the value for c2 is wrong.

            bar Alexander Barkov added a comment - The same problem is repeatable with smaller numbers: CREATE OR REPLACE TABLE t1 AS SELECT 2147483648 AS c1, COALESCE (2147483648) AS c2; SHOW CREATE TABLE t1; SELECT * FROM t1; +-------+----------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+----------------------------------------------------------------------------------------------------------------+ | t1 | CREATE TABLE `t1` ( `c1` bigint(10) NOT NULL, `c2` int(10) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | +-------+----------------------------------------------------------------------------------------------------------------+ +------------+------------+ | c1 | c2 | +------------+------------+ | 2147483648 | 2147483647 | +------------+------------+ Notice, the data type and the value for c2 is wrong.

            Previous fixes in Type_handler
            (see the patch for MDEV-12875, MDEV-12886, MDEV-12916)
            fixed this problem as well. Adding only the test from the report.

            Pushed into bb-10.2-ext.

            bar Alexander Barkov added a comment - Previous fixes in Type_handler (see the patch for MDEV-12875 , MDEV-12886 , MDEV-12916 ) fixed this problem as well. Adding only the test from the report. Pushed into bb-10.2-ext.

            People

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