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

MEDIUMINT returns a wrong length on conversion to string

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3
    • Fix Version/s: 10.4
    • Component/s: Data types
    • Labels:
      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

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: