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

Unexpected "BIGINT UNSIGNED value is out of range" for minus

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5, 10.6, 10.7(EOL), 10.11, 11.4, 11.6
    • 10.5, 10.6, 10.11, 11.4, 11.6
    • Data types
    • None

    Description

      This script returns an error unexpectedly:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (
        c1 BIGINT UNSIGNED,
        c2 BIGINT UNSIGNED
      );
      INSERT INTO t1 VALUES (20030516235329,20000127231341);
      SELECT c2-c1 FROM t1;
      

      ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in '(`test`.`t1`.`c2` - `test`.`t1`.`c1`)'
      

      It tries to create a BIGIN UNSIGNED column as a result:

      DROP TABLE IF EXISTS t2;
      CREATE TABLE t2 AS SELECT c2-c1 FROM t1 LIMIT 0;
      SHOW CREATE TABLE t2;
      

      +-------+-------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                          |
      +-------+-------------------------------------------------------------------------------------------------------+
      | t2    | CREATE TABLE `t2` (
        `c2-c1` bigint(21) unsigned DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+-------------------------------------------------------------------------------------------------------+
      

      The choice beween BIGINT and UNSIGNED BIGINT is controlled by the NO_UNSIGNED_SUBTRACTION flag in sql_mode.
      There should probably be a way to create a DECIMAL column instead.

      Attachments

        Issue Links

          Activity

            People

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