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

Table with RANGE or LIST COLUMNS partitioning on a BIGINT UNSIGNED column and a value over 2^63-1 cannot be opened after CREATE TABLE

    XMLWordPrintable

Details

    Description

      --source include/have_partition.inc
       
      CREATE TABLE t1 (a BIGINT UNSIGNED) PARTITION BY RANGE COLUMNS (a) (PARTITION p0 VALUES LESS THAN (9223372036854775808), PARTITION p1 VALUES LESS THAN (MAXVALUE));
      --error 0,ER_WRONG_TYPE_COLUMN_VALUE_ERROR
      INSERT INTO t1 VALUES (1);
      if ($mysql_errno)
      {
        --die The table was created but cannot be opened: its partition value 9223372036854775808 for a BIGINT UNSIGNED column is refused when the table is opened
      }
      DROP TABLE t1;

      Leads to:

      CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Debug, Clang 22.1.8-20260622) Build 06/10/2026

      mysqltest: At line 8: The table was created but cannot be opened: its partition value 9223372036854775808 for a BIGINT UNSIGNED column is refused when the table is opened

      The CREATE TABLE succeeds. The INSERT, a SELECT and SHOW CREATE TABLE then fail with ERROR 1654 (HY000): Partition column values of incorrect type. Only DROP TABLE works. The table definition holds PARTITION `p0` VALUES LESS THAN (-9223372036854775808). LIST COLUMNS with 18446744073709551615, and an ALTER TABLE ... ADD PARTITION with 9223372036854775808 on a BIGINT UNSIGNED column, give the same result. With 9223372036854775807, with PARTITION BY RANGE (a), and with 3000000000 on an INT UNSIGNED column, the table works. Optimized builds give the same result.

      From the code it seems that Type_handler_general_purpose_int::partition_field_append_value() in sql/sql_type.cc writes the value with String::set(longlong), which prints it as signed. When the table is opened, partition_info::fix_column_value_functions() in sql/partition_info.cc stores -9223372036854775808 in the unsigned column, gets a warning and gives ER_WRONG_TYPE_COLUMN_VALUE_ERROR.

      Attachments

        Activity

          People

            ycp Yuchen Pei
            Roel Roel Van de Paar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - Not Specified
                Not Specified
                Logged:
                Time Spent - 0.75h
                0.75h

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.