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

name_const() is not consistent about its signess

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5, 10.0, 10.1, 10.2
    • 10.3.8
    • Data types
    • 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.

      Attachments

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.