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

MEDIUMINT returns a wrong length on conversion to string

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 5.5, 10.0, 10.1, 10.2, 10.3
    • 10.4
    • Data types
    • None

    Description

      I run a script which makes a few implicit conversions MEDIUMINT to string:

      CREATE OR REPLACE TABLE t1 (a MEDIUMINT, b MEDIUMINT UNSIGNED);
      CREATE OR REPLACE TABLE t2 AS SELECT
        CONCAT(a),
        CONCAT(b),
        COALESCE(a,''),
        COALESCE(b,'')
      FROM t1;
      DESC t2;
      

      +----------------+------------+------+-----+---------+-------+
      | Field          | Type       | Null | Key | Default | Extra |
      +----------------+------------+------+-----+---------+-------+
      | CONCAT(a)      | varchar(9) | YES  |     | NULL    |       |
      | CONCAT(b)      | varchar(8) | YES  |     | NULL    |       |
      | COALESCE(a,'') | varchar(9) | YES  |     | NULL    |       |
      | COALESCE(b,'') | varchar(8) | YES  |     | NULL    |       |
      +----------------+------------+------+-----+---------+-------+
      

      The data types of the t2 columns corresponding to signed columns in t1 is wrong: 9 is too excessive. All columns in t2 must have length of 8.

      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:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.