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

name_const() is not consistent about its signess

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.1, 10.0, 5.5
    • Fix Version/s: 10.1
    • Component/s: None
    • Labels:
      None

      Description

      $ mysql-tmp --column-type-info test
      ...
      mysql> SELECT 18446744073709551615 AS c1, name_const('a',18446744073709551615) AS c2;
      ...
      Field   1:  `c1`
      Type:       LONGLONG
      Flags:      NOT_NULL UNSIGNED BINARY NUM 
      ...
      Field   2:  `c2`
      Type:       LONGLONG
      Flags:      BINARY NUM
      ...
      +----------------------+----------------------+
      | c1                   | c2                   |
      +----------------------+----------------------+
      | 18446744073709551615 | 18446744073709551615 |
      +----------------------+----------------------
      

      Notice, metadata says LONGLONG UNSIGNED for c1 but LONGLONG SIGNED for c2, but return values are both unsigned.

      Another example of incorrect behaviour:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 AS SELECT 18446744073709551615 AS c1, name_const('a',18446744073709551615) AS c2;
      SHOW WARNINGS;
      SHOW CREATE TABLE t1;
      

      The above script returns

      +---------+------+---------------------------------------------+
      | Level   | Code | Message                                     |
      +---------+------+---------------------------------------------+
      | Warning | 1264 | Out of range value for column 'c2' at row 1 |
      +---------+------+---------------------------------------------+
      1 row in set (0.00 sec)
      
      +-------+--------------------------------------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                                               |
      +-------+--------------------------------------------------------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `c1` bigint(20) unsigned NOT NULL DEFAULT '0',
        `c2` bigint(20) DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+--------------------------------------------------------------------------------------------------------------------------------------------+
      

      The expected result is to have unsigned flag in both fields.

        Gliffy Diagrams

          Attachments

            Activity

            There are no comments yet on this issue.

              People

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

                Dates

                • Created:
                  Updated: