Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions mysql-test/main/partition_range_interval.result
Original file line number Diff line number Diff line change
Expand Up @@ -2557,3 +2557,72 @@ INTERVAL "hello" DAY
PARTITION p0 VALUES LESS THAN ('2026-04-20')
);
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'INTERVAL'
#
# MDEV-40467 Auto-partition fails when using maximum timestamp
#
SET time_zone='+00:00';
set timestamp=4294967295;
## out of range with TIMESTAMP
create table t1 (c timestamp) engine=innodb
PARTITION BY RANGE COLUMNS (c)
INTERVAL 1 day
(
PARTITION p0 VALUES LESS THAN ('2106-02-01')
);
insert into t1 values ('2026-04-20');
ERROR 22003: timestamp value is out of range in 'INTERVAL'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
PARTITION BY RANGE COLUMNS(`c`) INTERVAL 1 DAY
(PARTITION `p0` VALUES LESS THAN ('2106-02-01') ENGINE = InnoDB)
drop table t1;
## fine with DATE type
create table t1 (c date) engine=innodb
PARTITION BY RANGE COLUMNS (c)
INTERVAL 1 day
(
PARTITION p0 VALUES LESS THAN ('2106-02-01')
);
insert into t1 values ('2026-04-20');
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
PARTITION BY RANGE COLUMNS(`c`) INTERVAL 1 DAY
(PARTITION `p0` VALUES LESS THAN ('2106-02-01') ENGINE = InnoDB,
PARTITION `p1` VALUES LESS THAN ('2106-02-02') ENGINE = InnoDB,
PARTITION `p2` VALUES LESS THAN ('2106-02-03') ENGINE = InnoDB,
PARTITION `p3` VALUES LESS THAN ('2106-02-04') ENGINE = InnoDB,
PARTITION `p4` VALUES LESS THAN ('2106-02-05') ENGINE = InnoDB,
PARTITION `p5` VALUES LESS THAN ('2106-02-06') ENGINE = InnoDB,
PARTITION `p6` VALUES LESS THAN ('2106-02-07') ENGINE = InnoDB,
PARTITION `p7` VALUES LESS THAN ('2106-02-08') ENGINE = InnoDB)
drop table t1;
## fine with DATETIME type
create table t1 (c datetime) engine=innodb
PARTITION BY RANGE COLUMNS (c)
INTERVAL 1 day
(
PARTITION p0 VALUES LESS THAN ('2106-02-01')
);
insert into t1 values ('2026-04-20');
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
PARTITION BY RANGE COLUMNS(`c`) INTERVAL 1 DAY
(PARTITION `p0` VALUES LESS THAN ('2106-02-01') ENGINE = InnoDB,
PARTITION `p1` VALUES LESS THAN ('2106-02-02 00:00:00') ENGINE = InnoDB,
PARTITION `p2` VALUES LESS THAN ('2106-02-03 00:00:00') ENGINE = InnoDB,
PARTITION `p3` VALUES LESS THAN ('2106-02-04 00:00:00') ENGINE = InnoDB,
PARTITION `p4` VALUES LESS THAN ('2106-02-05 00:00:00') ENGINE = InnoDB,
PARTITION `p5` VALUES LESS THAN ('2106-02-06 00:00:00') ENGINE = InnoDB,
PARTITION `p6` VALUES LESS THAN ('2106-02-07 00:00:00') ENGINE = InnoDB,
PARTITION `p7` VALUES LESS THAN ('2106-02-08 00:00:00') ENGINE = InnoDB)
drop table t1;
SET time_zone=default;
45 changes: 45 additions & 0 deletions mysql-test/main/partition_range_interval.test
Original file line number Diff line number Diff line change
Expand Up @@ -1032,3 +1032,48 @@ INTERVAL "hello" DAY
(
PARTITION p0 VALUES LESS THAN ('2026-04-20')
);

--echo #
--echo # MDEV-40467 Auto-partition fails when using maximum timestamp
--echo #

SET time_zone='+00:00';
set timestamp=4294967295;

--echo ## out of range with TIMESTAMP
create table t1 (c timestamp) engine=innodb
PARTITION BY RANGE COLUMNS (c)
INTERVAL 1 day
(
PARTITION p0 VALUES LESS THAN ('2106-02-01')
);

--error ER_DATA_OUT_OF_RANGE
insert into t1 values ('2026-04-20');
show create table t1;
drop table t1;

--echo ## fine with DATE type
create table t1 (c date) engine=innodb
PARTITION BY RANGE COLUMNS (c)
INTERVAL 1 day
(
PARTITION p0 VALUES LESS THAN ('2106-02-01')
);

insert into t1 values ('2026-04-20');
show create table t1;
drop table t1;

--echo ## fine with DATETIME type
create table t1 (c datetime) engine=innodb
PARTITION BY RANGE COLUMNS (c)
INTERVAL 1 day
(
PARTITION p0 VALUES LESS THAN ('2106-02-01')
);

insert into t1 values ('2026-04-20');
show create table t1;
drop table t1;
SET time_zone=default;
8 changes: 8 additions & 0 deletions sql/sql_partition_auto_interval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ bool check_range_interval_constants(THD *thd, partition_info *part_info)
column_item= new (thd->mem_root) Item_datetime_literal(thd, &dt, dec);
break;
case MYSQL_TYPE_TIMESTAMP:
/* Likely Year 2038/2106 Problem */
if (error)
{
my_error(ER_DATA_OUT_OF_RANGE, MYF(0),
part_info->part_field_array[0]->type_handler()->name().ptr(),
"INTERVAL");
return TRUE;
}
column_item= new (thd->mem_root) Item_timestamp_literal(thd, ts, dec);
break;
default:
Expand Down