Commit 5896a498 authored by Nikita Malyavin's avatar Nikita Malyavin

MDEV-19130 Assertion failed in handler::update_auto_increment

add store/restore_auto_increment in period portion insert/update functions
parent c2ac0ce1
......@@ -368,3 +368,23 @@ drop procedure sp;
drop table t,t2,t3,log_tbl;
drop view v;
drop procedure log;
# MDEV-19130 Assertion
# `next_insert_id >= auto_inc_interval_for_cur_row.minimum()'
# failed in handler::update_auto_increment after error 167
create or replace table t (f tinyint auto_increment null,
s timestamp, e timestamp,
period for app(s,e), key(f, s));
insert into t (s,e) values
('2021-08-22 10:28:43', '2023-09-17 00:00:00'),
('2019-05-09 21:45:24', '2020-04-22 14:38:49');
insert into t (s,e) select s,e from t;
insert into t (s,e) select s,e from t;
insert into t (s,e) select s,e from t;
insert into t (s,e) values ('2015-07-07 00:00:00','2020-03-11 08:48:52');
insert into t (s,e) select s,e from t;
insert into t (s,e) select s,e from t;
insert into t select * from t;
ERROR 22003: Out of range value for column 'f' at row ROW
delete ignore from t
for portion of app from '2015-07-07 00:00:00' to '2020-03-11 08:48:52';
drop table t;
......@@ -281,3 +281,14 @@ create table t1 (s date, e date, period for app(s,e), f varchar(8)) engine=aria
insert into t1 values ('2024-05-13','2026-03-25','foo');
update t1 for portion of app from '2024-04-02' to '2026-03-15' set f = 'bar';
drop table t1;
# MDEV-19130 Assertion
# `next_insert_id >= auto_inc_interval_for_cur_row.minimum()'
# failed in handler::update_auto_increment after error 167
create table t1 (id int auto_increment, f int, s datetime, e datetime, period for p(s,e), primary key(id));
insert into t1 (s,e) values ('1994-01-06','2004-11-30'),('1994-06-21','1997-06-20');
update ignore t1 set id = 2429681664;
Warnings:
Warning 1264 Out of range value for column 'id' at row 1
Warning 1264 Out of range value for column 'id' at row 2
update ignore t1 for portion of p from '1995-07-06' to '2009-01-12' set f = 1;
drop table t1;
......@@ -194,7 +194,34 @@ call sp;
drop table t1;
drop procedure sp;
drop table t,t2,t3,log_tbl;
drop view v;
drop procedure log;
--echo # MDEV-19130 Assertion
--echo # `next_insert_id >= auto_inc_interval_for_cur_row.minimum()'
--echo # failed in handler::update_auto_increment after error 167
create or replace table t (f tinyint auto_increment null,
s timestamp, e timestamp,
period for app(s,e), key(f, s));
insert into t (s,e) values
('2021-08-22 10:28:43', '2023-09-17 00:00:00'),
('2019-05-09 21:45:24', '2020-04-22 14:38:49');
insert into t (s,e) select s,e from t;
insert into t (s,e) select s,e from t;
insert into t (s,e) select s,e from t;
insert into t (s,e) values ('2015-07-07 00:00:00','2020-03-11 08:48:52');
insert into t (s,e) select s,e from t;
insert into t (s,e) select s,e from t;
--replace_regex /row \d+/row ROW/
--error HA_ERR_AUTOINC_ERANGE
insert into t select * from t;
--disable_warnings
delete ignore from t
for portion of app from '2015-07-07 00:00:00' to '2020-03-11 08:48:52';
--enable_warnings
drop table t;
......@@ -173,3 +173,13 @@ update t1 for portion of app from '2024-04-02' to '2026-03-15' set f = 'bar';
# cleanup
drop table t1;
--echo # MDEV-19130 Assertion
--echo # `next_insert_id >= auto_inc_interval_for_cur_row.minimum()'
--echo # failed in handler::update_auto_increment after error 167
create table t1 (id int auto_increment, f int, s datetime, e datetime, period for p(s,e), primary key(id));
insert into t1 (s,e) values ('1994-01-06','2004-11-30'),('1994-06-21','1997-06-20');
update ignore t1 set id = 2429681664;
update ignore t1 for portion of p from '1995-07-06' to '2009-01-12' set f = 1;
drop table t1;
......@@ -260,6 +260,7 @@ int update_portion_of_time(THD *thd, TABLE *table,
uint dst_fieldno= lcond ? table->s->period.end_fieldno
: table->s->period.start_fieldno;
table->file->store_auto_increment();
store_record(table, record[1]);
if (likely(!res))
res= src->save_in_field(table->field[dst_fieldno], true);
......@@ -274,6 +275,8 @@ int update_portion_of_time(THD *thd, TABLE *table,
res= table->triggers->process_triggers(thd, TRG_EVENT_INSERT,
TRG_ACTION_AFTER, true);
restore_record(table, record[1]);
if (res)
table->file->restore_auto_increment();
if (likely(!res) && lcond && rcond)
res= table->period_make_insert(period_conds.end.item,
......
......@@ -8499,6 +8499,7 @@ int TABLE::period_make_insert(Item *src, Field *dst)
{
THD *thd= in_use;
file->store_auto_increment();
store_record(this, record[1]);
int res= src->save_in_field(dst, true);
......@@ -8517,6 +8518,8 @@ int TABLE::period_make_insert(Item *src, Field *dst)
TRG_ACTION_AFTER, true);
restore_record(this, record[1]);
if (res)
file->restore_auto_increment();
return res;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment