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

UNION creates excessive integer column types for integer literals

Details

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

    Description

      CREATE OR REPLACE TABLE t1 AS SELECT 1;
      SHOW CREATE TABLE t1;
      

      +-------+----------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                 |
      +-------+----------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `1` int(1) NOT NULL DEFAULT '0'
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+----------------------------------------------------------------------------------------------+
      

      CREATE OR REPLACE TABLE t1 AS SELECT 1 UNION SELECT 1;
      SHOW CREATE TABLE t1;
      

      +-------+--------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                     |
      +-------+--------------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `1` bigint(20) NOT NULL DEFAULT '0'
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+--------------------------------------------------------------------------------------------------+
      

      Notice:

      • The first CREATE statement made a column of the int(1) type.
      • The second CREATE statement with UNION made a column the bigint(20) type. Looks excessive. An int column would be enough.

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            Description {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1;
            SHOW CREATE TABLE t1;
            CREATE OR REPLACE TABLE t1 AS SELECT 1 UNION SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            Notice:
            - The first {{CREATE}} statement made a column of the {{int(1)}} type.
            - The second {{CREATE}} statement with {{UNION}} made a column the {{bigint(11)}} type. Looks excessive. An {{int}} column would be enough.
            {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            +-------+----------------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `1` int(1) NOT NULL DEFAULT '0'
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------------+
            {noformat}
            {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1 UNION SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            {noformat}

            Notice:
            - The first {{CREATE}} statement made a column of the {{int(1)}} type.
            - The second {{CREATE}} statement with {{UNION}} made a column the {{bigint(11)}} type. Looks excessive. An {{int}} column would be enough.
            bar Alexander Barkov made changes -
            Description {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            +-------+----------------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `1` int(1) NOT NULL DEFAULT '0'
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------------+
            {noformat}
            {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1 UNION SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            {noformat}

            Notice:
            - The first {{CREATE}} statement made a column of the {{int(1)}} type.
            - The second {{CREATE}} statement with {{UNION}} made a column the {{bigint(11)}} type. Looks excessive. An {{int}} column would be enough.
            {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            +-------+----------------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `1` int(1) NOT NULL DEFAULT '0'
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------------+
            {noformat}
            {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1 UNION SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            +-------+--------------------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+--------------------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `1` bigint(20) NOT NULL DEFAULT '0'
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+--------------------------------------------------------------------------------------------------+
            {noformat}

            Notice:
            - The first {{CREATE}} statement made a column of the {{int(1)}} type.
            - The second {{CREATE}} statement with {{UNION}} made a column the {{bigint(11)}} type. Looks excessive. An {{int}} column would be enough.

            Non-union query returns a correct result:
            {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            +-------+----------------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `1` int(1) NOT NULL DEFAULT '0'
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------------+
            {noformat}
            bar Alexander Barkov made changes -
            Description {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            +-------+----------------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `1` int(1) NOT NULL DEFAULT '0'
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------------+
            {noformat}
            {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1 UNION SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            +-------+--------------------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+--------------------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `1` bigint(20) NOT NULL DEFAULT '0'
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+--------------------------------------------------------------------------------------------------+
            {noformat}

            Notice:
            - The first {{CREATE}} statement made a column of the {{int(1)}} type.
            - The second {{CREATE}} statement with {{UNION}} made a column the {{bigint(11)}} type. Looks excessive. An {{int}} column would be enough.

            Non-union query returns a correct result:
            {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            +-------+----------------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `1` int(1) NOT NULL DEFAULT '0'
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------------+
            {noformat}
            {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            +-------+----------------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `1` int(1) NOT NULL DEFAULT '0'
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------------+
            {noformat}
            {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1 UNION SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            +-------+--------------------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+--------------------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `1` bigint(20) NOT NULL DEFAULT '0'
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+--------------------------------------------------------------------------------------------------+
            {noformat}

            Notice:
            - The first {{CREATE}} statement made a column of the {{int(1)}} type.
            - The second {{CREATE}} statement with {{UNION}} made a column the {{bigint(11)}} type. Looks excessive. An {{int}} column would be enough.
            bar Alexander Barkov made changes -
            Description {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            +-------+----------------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `1` int(1) NOT NULL DEFAULT '0'
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------------+
            {noformat}
            {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1 UNION SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            +-------+--------------------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+--------------------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `1` bigint(20) NOT NULL DEFAULT '0'
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+--------------------------------------------------------------------------------------------------+
            {noformat}

            Notice:
            - The first {{CREATE}} statement made a column of the {{int(1)}} type.
            - The second {{CREATE}} statement with {{UNION}} made a column the {{bigint(11)}} type. Looks excessive. An {{int}} column would be enough.
            {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            +-------+----------------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `1` int(1) NOT NULL DEFAULT '0'
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------------+
            {noformat}
            {code:sql}
            CREATE OR REPLACE TABLE t1 AS SELECT 1 UNION SELECT 1;
            SHOW CREATE TABLE t1;
            {code}
            {noformat}
            +-------+--------------------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+--------------------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `1` bigint(20) NOT NULL DEFAULT '0'
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
            +-------+--------------------------------------------------------------------------------------------------+
            {noformat}

            Notice:
            - The first {{CREATE}} statement made a column of the {{int(1)}} type.
            - The second {{CREATE}} statement with {{UNION}} made a column the {{bigint(20)}} type. Looks excessive. An {{int}} column would be enough.
            bar Alexander Barkov made changes -
            Status Open [ 1 ] In Progress [ 3 ]

            Pushed to bb-10.2-ext

            bar Alexander Barkov added a comment - Pushed to bb-10.2-ext
            bar Alexander Barkov made changes -
            issue.field.resolutiondate 2017-04-28 12:28:40.0 2017-04-28 12:28:40.097
            bar Alexander Barkov made changes -
            Fix Version/s 10.3.1 [ 22532 ]
            Fix Version/s 10.3 [ 22126 ]
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Closed [ 6 ]
            bgrainger Bradley Grainger made changes -
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 80518 ] MariaDB v4 [ 152037 ]

            People

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