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

INSERT fails with ERROR 1493 when INTERVAL partitions on a TIMESTAMP column cross a change to daylight saving time

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 13.1, 13.2
    • 13.1
    • Partitioning
    • None

    Description

      --source include/have_partition.inc
       
      # In the MET time zone, the clocks go from 02:00 to 03:00 on 2026-03-29
      SET time_zone='MET';
      SET timestamp= UNIX_TIMESTAMP('2026-03-29 06:00:00');
      --error 0,ER_PARSE_ERROR,ER_PARTITIONS_MUST_BE_DEFINED_ERROR,ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
      CREATE TABLE t1 (ts TIMESTAMP) PARTITION BY RANGE COLUMNS (ts) INTERVAL 1 HOUR (PARTITION p0 VALUES LESS THAN ('2026-03-29 00:00:00'));
      if ($mysql_errno)
      {
        --skip Needs RANGE COLUMNS ... INTERVAL partitioning
      }
      # The row fits p0. The INSERT adds the partitions up to the current time
      --error 0,ER_RANGE_NOT_INCREASING_ERROR
      INSERT INTO t1 VALUES ('2026-03-28 23:00:00');
      if ($mysql_errno)
      {
        --die An INSERT into a TIMESTAMP column with INTERVAL 1 HOUR partitioning fails when the new partitions cross the change to daylight saving time
      }
      DROP TABLE t1;

      Leads to:

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

      mysqltest: At line 17: An INSERT into a TIMESTAMP column with INTERVAL 1 HOUR partitioning fails when the new partitions cross the change to daylight saving time

      The INSERT fails with ERROR 1493 (HY000): VALUES LESS THAN value must be strictly increasing for each partition and no row is added. Every later INSERT into t1 fails the same way, also with the current time set two weeks later, until a partition past the change is added with ALTER TABLE t1 ADD PARTITION. INTERVAL 30 MINUTE fails the same way. A DATETIME column, the time zone +01:00 and the change back to standard time in October work. Optimized builds give the same result.

      In MET, UNIX_TIMESTAMP() gives the same value for 2026-03-29 02:00:00, 2026-03-29 02:30:00 and 2026-03-29 03:00:00. From the code it seems that check_range_interval_constants() in sql/sql_partition_auto_interval.cc adds the interval to the bound in local time and then stores each bound in the TIMESTAMP column in the session time zone, so two new partitions get the same bound.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 0d
                  0d
                  Remaining:
                  Remaining Estimate - 1.5d
                  1.5d
                  Logged:
                  Time Spent - Not Specified
                  Not Specified

                  Git Integration

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