Skip to content
Merged
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
3 changes: 2 additions & 1 deletion pkg/executor/insert_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ func (e *InsertValues) handleErr(col *table.Column, val *types.Datum, rowIdx int
if col != nil && col.GetType() == mysql.TypeTimestamp &&
types.ErrTimestampInDSTTransition.Equal(err) {
newErr := exeerrors.ErrTruncateWrongInsertValue.FastGenByArgs(types.TypeStr(col.GetType()), val.GetString(), col.Name.O, rowIdx+1)
if e.Ctx().GetSessionVars().SQLMode.HasStrictMode() {
// IGNORE takes precedence over STRICT mode.
if !e.ignoreErr && e.Ctx().GetSessionVars().SQLMode.HasStrictMode() {
return newErr
}
// timestamp already adjusted to end of DST transition, convert error to warning
Expand Down
19 changes: 19 additions & 0 deletions tests/integrationtest/r/executor/insert.result
Original file line number Diff line number Diff line change
Expand Up @@ -2424,3 +2424,22 @@ id ts mode
DROP TABLE t;
SET @@time_zone = @old_time_zone;
SET @@sql_mode = @old_sql_mode;
SET @old_time_zone = @@time_zone;
SET @@time_zone = 'Europe/Amsterdam';
SET @old_sql_mode = @@sql_mode;
create table t (ts timestamp);
set time_zone = 'Europe/Amsterdam';
set sql_mode = 'strict_trans_tables,no_zero_date,no_zero_in_date,error_for_division_by_zero';
insert into t values ('2025-03-30 02:00:00');
Error 1292 (22007): Incorrect timestamp value: '2025-03-30 02:00:00' for column 'ts' at row 1
select * from t;
ts
insert ignore into t values ('2025-03-30 02:00:00');
Level Code Message
Warning 1292 Incorrect timestamp value: '2025-03-30 02:00:00' for column 'ts' at row 1
select * from t;
ts
2025-03-30 03:00:00
DROP TABLE t;
SET @@time_zone = @old_time_zone;
SET @@sql_mode = @old_sql_mode;
Expand Down
17 changes: 17 additions & 0 deletions tests/integrationtest/t/executor/insert.test
Original file line number Diff line number Diff line change
Expand Up @@ -1765,3 +1765,20 @@ SELECT * FROM t ORDER BY id;
DROP TABLE t;
SET @@time_zone = @old_time_zone;
SET @@sql_mode = @old_sql_mode;

# Testing INSERT IGNORE with STRICT mode, #61439
SET @old_time_zone = @@time_zone;
SET @@time_zone = 'Europe/Amsterdam';
SET @old_sql_mode = @@sql_mode;
create table t (ts timestamp);
set time_zone = 'Europe/Amsterdam';
set sql_mode = 'strict_trans_tables,no_zero_date,no_zero_in_date,error_for_division_by_zero';
--error 1292
insert into t values ('2025-03-30 02:00:00');
select * from t;
insert ignore into t values ('2025-03-30 02:00:00');
select * from t;
DROP TABLE t;
SET @@time_zone = @old_time_zone;
SET @@sql_mode = @old_sql_mode;
--disable_warnings