From c1492f3d077e47a015c6e4c5dcd2107b803ac3f4 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Sun, 30 Mar 2025 18:54:23 +0300 Subject: [PATCH] MDEV-36115 InnoDB: assertion: node->pcur->rel_pos == BTR_PCUR_ON in row_update_for_mysql 932ec586 (MDEV-23644) in TABLE::delete_row() added ha_delete_row() for the case of HA_ERR_FOREIGN_DUPLICATE_KEY. The problem is ha_update_row() called beforewards may change m_last_part which is required for ha_delete_row() to delete from correct partition. The fix reverts m_last_part in case ha_partition::update_row() fails. --- mysql-test/suite/versioning/r/partition.result | 14 ++++++++++++++ mysql-test/suite/versioning/t/partition.test | 16 ++++++++++++++++ sql/ha_partition.cc | 3 ++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/versioning/r/partition.result b/mysql-test/suite/versioning/r/partition.result index 1ceb9c443a2..7e920fb3187 100644 --- a/mysql-test/suite/versioning/r/partition.result +++ b/mysql-test/suite/versioning/r/partition.result @@ -1791,6 +1791,20 @@ drop table t; create table t (a int) with system versioning partition by system_time partitions 3; ERROR HY000: Maybe missing parameters: no rotation condition for multiple HISTORY partitions. # +# MDEV-36115 InnoDB: assertion: node->pcur->rel_pos == BTR_PCUR_ON +# in row_update_for_mysql +# +create table t (a int key) engine=innodb +with system versioning +partition by key() partitions 3; +start transaction; +insert into t values (1),(2),(3),(4),(5),(6),(7),(8); +set timestamp=+1; +delete from t; +insert into t values (1),(2); +DELETE from t; +drop table t; +# # End of 10.5 tests # set global innodb_stats_persistent= @save_persistent; diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test index 840af2d6cec..3d31b1c6864 100644 --- a/mysql-test/suite/versioning/t/partition.test +++ b/mysql-test/suite/versioning/t/partition.test @@ -1563,6 +1563,22 @@ drop table t; --error WARN_VERS_PARAMETERS create table t (a int) with system versioning partition by system_time partitions 3; +--echo # +--echo # MDEV-36115 InnoDB: assertion: node->pcur->rel_pos == BTR_PCUR_ON +--echo # in row_update_for_mysql +--echo # +create table t (a int key) engine=innodb +with system versioning +partition by key() partitions 3; + +start transaction; +insert into t values (1),(2),(3),(4),(5),(6),(7),(8); +set timestamp=+1; +delete from t; +insert into t values (1),(2); +DELETE from t; +drop table t; + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 64ffb25d4fe..d053eed62fe 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4616,7 +4616,6 @@ int ha_partition::update_row(const uchar *old_data, const uchar *new_data) } - m_last_part= new_part_id; start_part_bulk_insert(thd, new_part_id); DBUG_ASSERT(!m_file[new_part_id]->row_logging); if (new_part_id == old_part_id) @@ -4651,6 +4650,8 @@ int ha_partition::update_row(const uchar *old_data, const uchar *new_data) goto exit; } + m_last_part= new_part_id; + exit: /* if updating an auto_increment column, update