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

Wrong metadata or data type for string user variables

    XMLWordPrintable

Details

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

    Description

      DROP TABLE IF EXISTS t1;
      SET @a='test';
      SELECT @a;
      

      Field   1:  `@a`
      Catalog:    `def`
      Database:   ``
      Table:      ``
      Org_table:  ``
      Type:       MEDIUM_BLOB
      Collation:  utf8_general_ci (33)
      Length:     50331645
      Max_length: 4
      Decimals:   31
      Flags:      
      

      +------+
      | @a   |
      +------+
      | test |
      +------+
      

      Notice, MEDIUM_BLOB is displayed as the data type.

      Now I create a table:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 AS SELECT @a;
      SHOW CREATE TABLE t1; 
      

      +-------+-----------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                  |
      +-------+-----------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `@a` longtext CHARACTER SET utf8
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+-----------------------------------------------------------------------------------------------+
      

      Notice, a LONGTEXT column was created.

      There is a mismatch:

      • Either LONG_BLOB should be reported in the metadata
      • Or a MEDIUMBLOB column should be created
      • Or perhaps a smaller data type could be used, e.g. BLOB or TINYBLOB, with the corresponding data type displayed in metadata.

      Update:
      The data type should be LONGBLOB/LONGTEXT, because user variables can be modified on the fly. So the metadata should by synchronized with the data type and report LONG_BLOB.

      The same problem is repeatable with Item_func_set_user_var:

      CREATE OR REPLACE TABLE t1 AS SELECT @a:=1;
      DESCRIBE t1;
      

      +-------+--------+------+-----+---------+-------+
      | Field | Type   | Null | Key | Default | Extra |
      +-------+--------+------+-----+---------+-------+
      | @a:=1 | int(1) | NO   |     | 0       |       |
      +-------+--------+------+-----+---------+-------+
      

      But if I start mysql --column-type-info test and do:

      SELECT @a:=1;
      

      Field   1:  `@a:=1`
      Type:       LONGLONG
      Length:     3
      Max_length: 1
      

      Notice, result set metadata is wrong. It should report LONG rather than LONGLONG.

      Attachments

        Issue Links

          Activity

            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.