Commit caa5189f authored by Nikita Malyavin's avatar Nikita Malyavin

MDEV-19130 Assertion `next_insert_id >=...

MDEV-19130 Assertion `next_insert_id >= auto_inc_interval_for_cur_row.minimum()' failed in handler::update_auto_increment after error 167
parent 999a1c21
......@@ -353,6 +353,25 @@ id s e datediff(e, s)
1 1999-01-01 1999-01-03 2
1 2018-12-10 2018-12-12 2
2 1999-01-01 1999-01-03 2
# 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 74
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,t2,t3,log_tbl;
drop view v;
drop procedure log;
......@@ -181,6 +181,30 @@ delete from t for portion of apptime from '1999-01-03' to '2018-12-10';
--sorted_result
select *, datediff(e, s) from t;
--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;
--error 167
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,t2,t3,log_tbl;
drop view v;
drop procedure log;
......@@ -268,6 +268,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);
......@@ -282,6 +283,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,
......
......@@ -8436,6 +8436,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);
......@@ -8454,6 +8455,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