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

Out-of-range error for CREATE..SELECT unsigned_int_column+1

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.1, 10.2, 10.3
    • Fix Version/s: 10.3.1
    • Component/s: OTHER
    • Labels:

      Description

      SET sql_mode=STRICT_ALL_TABLES;
      CREATE OR REPLACE  TABLE t1 (a INT UNSIGNED NOT NULL);
      INSERT INTO t1 VALUES (0xFFFFFFFF);
      CREATE OR REPLACE TABLE t2 AS SELECT a+1 FROM t1;
      

      ERROR 1264 (22003): Out of range value for column 'a+1' at row 1
      

      Adding LIMIT 0 shows that an INT(11) instead of a BITINT(11) column is created:

      CREATE OR REPLACE TABLE t2 AS SELECT a+1 FROM t1 LIMIT 0;
      DESCRIBE t2;
      

      +-------+------------------+------+-----+---------+-------+
      | Field | Type             | Null | Key | Default | Extra |
      +-------+------------------+------+-----+---------+-------+
      | a+1   | int(11) unsigned | NO   |     | 0       |       |
      +-------+------------------+------+-----+---------+-------+
      

        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: