Skip to content

Commit 27c25ce

Browse files
committed
MDEV-31030 Assertion `!error' failed in ha_partition::update_row on UPDATE
Removing wrong assertion as division by zero was caused by valid input.
1 parent 55b5993 commit 27c25ce

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

mysql-test/main/partition.result

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,3 +2857,23 @@ id select_type table type possible_keys key key_len ref rows Extra
28572857
2 DEPENDENT SUBQUERY t3 ref_or_null a1,b a1 10 func,test.t2.a 198 Using where; Full scan on NULL key
28582858
set optimizer_switch=@tmp_os;
28592859
drop table t1,t2,t3;
2860+
#
2861+
# MDEV-31030 Assertion `!error' failed in ha_partition::update_row on UPDATE
2862+
#
2863+
create table t (c int)
2864+
partition by list (1 div c) (
2865+
partition p0 values in (null),
2866+
partition p values in (1));
2867+
insert ignore into t values (0), (1), (0);
2868+
Warnings:
2869+
Warning 1365 Division by 0
2870+
Warning 1365 Division by 0
2871+
update t set c= 2;
2872+
ERROR HY000: Table has no partition for value 0
2873+
update ignore t set c= 3;
2874+
select * from t;
2875+
c
2876+
0
2877+
0
2878+
1
2879+
drop table t;

mysql-test/main/partition.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,3 +3068,19 @@ set optimizer_switch=@tmp_os;
30683068

30693069
drop table t1,t2,t3;
30703070

3071+
--echo #
3072+
--echo # MDEV-31030 Assertion `!error' failed in ha_partition::update_row on UPDATE
3073+
--echo #
3074+
3075+
create table t (c int)
3076+
partition by list (1 div c) (
3077+
partition p0 values in (null),
3078+
partition p values in (1));
3079+
insert ignore into t values (0), (1), (0);
3080+
--error ER_NO_PARTITION_FOR_GIVEN_VALUE
3081+
update t set c= 2;
3082+
--disable_warnings
3083+
update ignore t set c= 3;
3084+
--enable_warnings
3085+
select * from t;
3086+
drop table t;

sql/ha_partition.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4591,7 +4591,10 @@ int ha_partition::update_row(const uchar *old_data, const uchar *new_data)
45914591
Notice that HA_READ_BEFORE_WRITE_REMOVAL does not require this protocol,
45924592
so this is not supported for this engine.
45934593
*/
4594-
error= get_part_for_buf(old_data, m_rec0, m_part_info, &old_part_id);
4594+
{
4595+
Abort_on_warning_instant_set old_abort_on_warning(thd, 0);
4596+
error= get_part_for_buf(old_data, m_rec0, m_part_info, &old_part_id);
4597+
}
45954598
DBUG_ASSERT(!error);
45964599
DBUG_ASSERT(old_part_id == m_last_part);
45974600
DBUG_ASSERT(bitmap_is_set(&(m_part_info->read_partitions), old_part_id));

0 commit comments

Comments
 (0)