diff --git a/mysql-test/suite/period/r/overlaps.result b/mysql-test/suite/period/r/overlaps.result index f5839a84e4b..40d38fc5a56 100644 --- a/mysql-test/suite/period/r/overlaps.result +++ b/mysql-test/suite/period/r/overlaps.result @@ -329,4 +329,12 @@ unique(f, p without overlaps)); insert into t1 values (0,'2026-02-12','2036-09-16'), (null,'2025-03-09','2032-12-05'); update ignore t join t1 set f = a; +# MDEV-22639 Assertion `inited != NONE' failed in +# handler::ha_check_overlaps upon multi-table update +create or replace table t (f int, s date, e date, period for p(s,e), +unique(f, p without overlaps)) engine=myisam; +insert into t values (1,'1988-08-25','2024-03-06'); +create or replace table t1 (a int) engine=myisam; +insert into t1 values (1),(2); +update t join t1 set s = '2020-01-01'; drop table t, t1; diff --git a/mysql-test/suite/period/t/overlaps.test b/mysql-test/suite/period/t/overlaps.test index ef2161d27a2..17005878385 100644 --- a/mysql-test/suite/period/t/overlaps.test +++ b/mysql-test/suite/period/t/overlaps.test @@ -313,5 +313,15 @@ insert into t1 values (0,'2026-02-12','2036-09-16'), update ignore t join t1 set f = a; +--echo # MDEV-22639 Assertion `inited != NONE' failed in +--echo # handler::ha_check_overlaps upon multi-table update + +create or replace table t (f int, s date, e date, period for p(s,e), + unique(f, p without overlaps)) engine=myisam; +insert into t values (1,'1988-08-25','2024-03-06'); +create or replace table t1 (a int) engine=myisam; +insert into t1 values (1),(2); + +update t join t1 set s = '2020-01-01'; drop table t, t1; diff --git a/sql/handler.cc b/sql/handler.cc index aa04b0bce1c..038effc3e5b 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6947,7 +6947,7 @@ int handler::ha_check_overlaps(const uchar *old_data, const uchar* new_data) uchar *record_buffer= lookup_buffer + table_share->max_unique_length + table_share->null_fields; - // Needs to compare record refs later is old_row_found() + // Needed to compare record refs later if (is_update) position(old_data); @@ -7003,12 +7003,8 @@ int handler::ha_check_overlaps(const uchar *old_data, const uchar* new_data) /* In case of update it could happen that the nearest neighbour is a record we are updating. It means, that there are no overlaps from this side. - - An assumption is made that during update we always have the last - fetched row in old_data. Therefore, comparing ref's is enough */ DBUG_ASSERT(lookup_handler != this); - DBUG_ASSERT(inited != NONE); DBUG_ASSERT(ref_length == lookup_handler->ref_length); lookup_handler->position(record_buffer);