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

Wrong metadata for integer additive and multiplicative operators

Details

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

    Description

      I start mysql --column-type-info test and execute this script:

      SELECT 1+1, 1*1;
      

      It reports the following metadata:

      Field   1:  `1+1`
      Type:       LONGLONG
      Length:     3
       
      Field   2:  `1*1`
      Type:       LONGLONG
      Length:     3
      

      However, if I do:

      CREATE OR REPLACE TABLE t1 AS SELECT 1+1,1*1;
      DESCRIBE t1;
      

      It creates INT(3):

      +-------+--------+------+-----+---------+-------+
      | Field | Type   | Null | Key | Default | Extra |
      +-------+--------+------+-----+---------+-------+
      | 1+1   | int(3) | NO   |     | 0       |       |
      | 1*1   | int(3) | NO   |     | 0       |       |
      +-------+--------+------+-----+---------+-------+
      

      Metadata should be fixed to match the real column type created on CREATE..SELECT.

      The same problem is repeatable for all Item_func_numhybrid descendants:

            Item_func_numhybrid 
              Item_func_num1    
                Item_func_neg   
                Item_func_abs   
                Item_func_int_val
                  Item_func_ceiling
                  Item_func_floor  
              Item_num_op
                Item_func_additive_op
                  Item_func_plus
                  Item_func_minus
                Item_func_mul
                Item_func_div
                Item_func_mod
              Item_func_round
              Item_func_seconds_hybrid
                Item_func_unix_timestamp
                Item_func_time_to_sec 
      

      Attachments

        Activity

          bar Alexander Barkov created issue -
          bar Alexander Barkov made changes -
          Field Original Value New Value
          Description I start {{mysql --column-type-info test}} and
          {code:sql}
          SELECT 1+1, 1*1;
          {code}
          {noformat}
          It reports the following metadata:
          {noformat}
          Field 1: `1+1`
          Type: LONGLONG
          Length: 3

          Field 2: `1*1`
          Type: LONGLONG
          Length: 3
          {noformat}

          However, if I do:
          {code:sql}
          CREATE OR REPLACE TABLE t1 AS SELECT 1+1,1*1;
          DESCRIBE t1;
          {code}
          It creates {{INT(3)}}:
          {noformat}
          +-------+--------+------+-----+---------+-------+
          | Field | Type | Null | Key | Default | Extra |
          +-------+--------+------+-----+---------+-------+
          | 1+1 | int(3) | NO | | 0 | |
          | 1*1 | int(3) | NO | | 0 | |
          +-------+--------+------+-----+---------+-------+
          {noformat}

          Metadata should be fixed to match the real column type created on {{CREATE..SELECT}}.
          I start {{mysql --column-type-info test}} and execute this script:
          {code:sql}
          SELECT 1+1, 1*1;
          {code}
          {noformat}
          It reports the following metadata:
          {noformat}
          Field 1: `1+1`
          Type: LONGLONG
          Length: 3

          Field 2: `1*1`
          Type: LONGLONG
          Length: 3
          {noformat}

          However, if I do:
          {code:sql}
          CREATE OR REPLACE TABLE t1 AS SELECT 1+1,1*1;
          DESCRIBE t1;
          {code}
          It creates {{INT(3)}}:
          {noformat}
          +-------+--------+------+-----+---------+-------+
          | Field | Type | Null | Key | Default | Extra |
          +-------+--------+------+-----+---------+-------+
          | 1+1 | int(3) | NO | | 0 | |
          | 1*1 | int(3) | NO | | 0 | |
          +-------+--------+------+-----+---------+-------+
          {noformat}

          Metadata should be fixed to match the real column type created on {{CREATE..SELECT}}.
          bar Alexander Barkov made changes -
          Description I start {{mysql --column-type-info test}} and execute this script:
          {code:sql}
          SELECT 1+1, 1*1;
          {code}
          {noformat}
          It reports the following metadata:
          {noformat}
          Field 1: `1+1`
          Type: LONGLONG
          Length: 3

          Field 2: `1*1`
          Type: LONGLONG
          Length: 3
          {noformat}

          However, if I do:
          {code:sql}
          CREATE OR REPLACE TABLE t1 AS SELECT 1+1,1*1;
          DESCRIBE t1;
          {code}
          It creates {{INT(3)}}:
          {noformat}
          +-------+--------+------+-----+---------+-------+
          | Field | Type | Null | Key | Default | Extra |
          +-------+--------+------+-----+---------+-------+
          | 1+1 | int(3) | NO | | 0 | |
          | 1*1 | int(3) | NO | | 0 | |
          +-------+--------+------+-----+---------+-------+
          {noformat}

          Metadata should be fixed to match the real column type created on {{CREATE..SELECT}}.
          I start {{mysql --column-type-info test}} and execute this script:
          {code:sql}
          SELECT 1+1, 1*1;
          {code}
          It reports the following metadata:
          {noformat}
          Field 1: `1+1`
          Type: LONGLONG
          Length: 3

          Field 2: `1*1`
          Type: LONGLONG
          Length: 3
          {noformat}

          However, if I do:
          {code:sql}
          CREATE OR REPLACE TABLE t1 AS SELECT 1+1,1*1;
          DESCRIBE t1;
          {code}
          It creates {{INT(3)}}:
          {noformat}
          +-------+--------+------+-----+---------+-------+
          | Field | Type | Null | Key | Default | Extra |
          +-------+--------+------+-----+---------+-------+
          | 1+1 | int(3) | NO | | 0 | |
          | 1*1 | int(3) | NO | | 0 | |
          +-------+--------+------+-----+---------+-------+
          {noformat}

          Metadata should be fixed to match the real column type created on {{CREATE..SELECT}}.
          bar Alexander Barkov made changes -
          Description I start {{mysql --column-type-info test}} and execute this script:
          {code:sql}
          SELECT 1+1, 1*1;
          {code}
          It reports the following metadata:
          {noformat}
          Field 1: `1+1`
          Type: LONGLONG
          Length: 3

          Field 2: `1*1`
          Type: LONGLONG
          Length: 3
          {noformat}

          However, if I do:
          {code:sql}
          CREATE OR REPLACE TABLE t1 AS SELECT 1+1,1*1;
          DESCRIBE t1;
          {code}
          It creates {{INT(3)}}:
          {noformat}
          +-------+--------+------+-----+---------+-------+
          | Field | Type | Null | Key | Default | Extra |
          +-------+--------+------+-----+---------+-------+
          | 1+1 | int(3) | NO | | 0 | |
          | 1*1 | int(3) | NO | | 0 | |
          +-------+--------+------+-----+---------+-------+
          {noformat}

          Metadata should be fixed to match the real column type created on {{CREATE..SELECT}}.
          I start {{mysql --column-type-info test}} and execute this script:
          {code:sql}
          SELECT 1+1, 1*1;
          {code}
          It reports the following metadata:
          {noformat}
          Field 1: `1+1`
          Type: LONGLONG
          Length: 3

          Field 2: `1*1`
          Type: LONGLONG
          Length: 3
          {noformat}

          However, if I do:
          {code:sql}
          CREATE OR REPLACE TABLE t1 AS SELECT 1+1,1*1;
          DESCRIBE t1;
          {code}
          It creates {{INT(3)}}:
          {noformat}
          +-------+--------+------+-----+---------+-------+
          | Field | Type | Null | Key | Default | Extra |
          +-------+--------+------+-----+---------+-------+
          | 1+1 | int(3) | NO | | 0 | |
          | 1*1 | int(3) | NO | | 0 | |
          +-------+--------+------+-----+---------+-------+
          {noformat}

          Metadata should be fixed to match the real column type created on {{CREATE..SELECT}}.

          The same problem is repeatable for all {{Item_func_numhybrid}} descendants:
          {noformat}
                Item_func_numhybrid
                  Item_func_num1
                    Item_func_neg
                    Item_func_abs
                    Item_func_int_val
                      Item_func_ceiling
                      Item_func_floor
                  Item_num_op
                    Item_func_additive_op
                      Item_func_plus
                      Item_func_minus
                    Item_func_mul
                    Item_func_div
                    Item_func_mod
                  Item_func_round
                  Item_func_seconds_hybrid
                    Item_func_unix_timestamp
                    Item_func_time_to_sec
          {noformat}
          bar Alexander Barkov made changes -
          Labels datatype

          Pushed into bb-10.2-ext

          bar Alexander Barkov added a comment - Pushed into bb-10.2-ext
          bar Alexander Barkov made changes -
          issue.field.resolutiondate 2017-05-23 08:51:30.0 2017-05-23 08:51:30.873
          bar Alexander Barkov made changes -
          Fix Version/s 10.3.1 [ 22532 ]
          Fix Version/s 10.3 [ 22126 ]
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 80883 ] MariaDB v4 [ 152198 ]

          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.