diff --git a/mysql-test/main/partition.result b/mysql-test/main/partition.result index e18273f4fe9..8cf64927293 100644 --- a/mysql-test/main/partition.result +++ b/mysql-test/main/partition.result @@ -2857,3 +2857,23 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t3 ref_or_null a1,b a1 10 func,test.t2.a 198 Using where; Full scan on NULL key set optimizer_switch=@tmp_os; drop table t1,t2,t3; +# +# MDEV-31030 Assertion `!error' failed in ha_partition::update_row on UPDATE +# +create table t (c int) +partition by list (1 div c) ( +partition p0 values in (null), +partition p values in (1)); +insert ignore into t values (0), (1), (0); +Warnings: +Warning 1365 Division by 0 +Warning 1365 Division by 0 +update t set c= 2; +ERROR HY000: Table has no partition for value 0 +update ignore t set c= 3; +select * from t; +c +0 +0 +1 +drop table t; diff --git a/mysql-test/main/partition.test b/mysql-test/main/partition.test index b3ea7f5c274..b9e055783ca 100644 --- a/mysql-test/main/partition.test +++ b/mysql-test/main/partition.test @@ -3068,3 +3068,19 @@ set optimizer_switch=@tmp_os; drop table t1,t2,t3; +--echo # +--echo # MDEV-31030 Assertion `!error' failed in ha_partition::update_row on UPDATE +--echo # + +create table t (c int) +partition by list (1 div c) ( + partition p0 values in (null), + partition p values in (1)); +insert ignore into t values (0), (1), (0); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +update t set c= 2; +--disable_warnings +update ignore t set c= 3; +--enable_warnings +select * from t; +drop table t; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index ed7fb7fe5f9..2a06ca4300e 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4591,7 +4591,10 @@ int ha_partition::update_row(const uchar *old_data, const uchar *new_data) Notice that HA_READ_BEFORE_WRITE_REMOVAL does not require this protocol, so this is not supported for this engine. */ - error= get_part_for_buf(old_data, m_rec0, m_part_info, &old_part_id); + { + Abort_on_warning_instant_set old_abort_on_warning(thd, 0); + error= get_part_for_buf(old_data, m_rec0, m_part_info, &old_part_id); + } DBUG_ASSERT(!error); DBUG_ASSERT(old_part_id == m_last_part); DBUG_ASSERT(bitmap_is_set(&(m_part_info->read_partitions), old_part_id));