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

Wrong UNSIGNED metadata flag returned for COALESCE(unsigned_field,timestamp_field)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5
    • Fix Version/s: 10.5.0
    • Component/s: Data types
    • Labels:
      None

      Description

      I run this command

      mysql --column-type-info test
      

      and execute the following script:

      CREATE OR REPLACE TABLE t1 (a INT UNSIGNED, b TIMESTAMP);
      SELECT COALESCE(a,b) FROM t1;
      

      Field   1:  `COALESCE(a,b)`
      Catalog:    `def`
      Database:   ``
      Table:      ``
      Org_table:  ``
      Type:       VAR_STRING
      Collation:  utf8_general_ci (33)
      Length:     57
      Max_length: 0
      Decimals:   39
      Flags:      UNSIGNED
      

      Note, in prints the UNSIGNED flag, although this flag is not applicable to VAR_STRING.

      Note, this script correctly creates a column of the VARCHAR data type without any UNSIGNED flags:

      CREATE OR REPLACE TABLE t1 (a INT UNSIGNED, b TIMESTAMP);
      CREATE OR REPLACE TABLE t2 AS SELECT COALESCE(a,b) AS c FROM t1;
      SHOW CREATE TABLE t2;
      

      +-------+--------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                 |
      +-------+--------------------------------------------------------------------------------------------------------------+
      | t2    | CREATE TABLE `t2` (
        `c` varchar(19) CHARACTER SET utf8 DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+--------------------------------------------------------------------------------------------------------------+
      

      Result field metadata should be fixed to match the column type created in CREATE..SELECT.

        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:
                Resolved: