summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Petrunia <sergey@mariadb.com>2023-02-24 12:22:40 +0300
committerSergei Petrunia <sergey@mariadb.com>2023-03-16 22:33:04 +0300
commit090e5d8b945bb2d0dfad1193c23cdc1bd271344e (patch)
treed264bb06861abc198384e9ab1543426084da0bc0
parentef5bb0814a2fe9093f48ed155b2cf179a8fd14c9 (diff)
downloadmariadb-git-090e5d8b945bb2d0dfad1193c23cdc1bd271344e.tar.gz
MDEV-30442: Assertion `!m_innodb' failed in ha_partition::cmp_ref ...
The failed assertion was about encountering the same rowid value in two different partitions. This wasn't possible with InnoDB previously: InnoDB used a global counter to produce rowid values for hidden PK. After the fix for MDEV-19506, it uses per-table counters so it's easily possible to get the same hidden PK values in different tables.
-rw-r--r--mysql-test/main/partition_innodb2.result24
-rw-r--r--mysql-test/main/partition_innodb2.test30
-rw-r--r--sql/ha_partition.cc7
3 files changed, 54 insertions, 7 deletions
diff --git a/mysql-test/main/partition_innodb2.result b/mysql-test/main/partition_innodb2.result
new file mode 100644
index 00000000000..4476eb91447
--- /dev/null
+++ b/mysql-test/main/partition_innodb2.result
@@ -0,0 +1,24 @@
+#
+# MDEV-30442: Assertion `!m_innodb' failed in ha_partition::cmp_ref on MULTI-DELETE
+#
+create table t1 (a int) engine=innodb;
+insert into t1 values (1),(2),(1),(2);
+create table t2 (
+a int,
+b int,
+key(a)
+) engine=innodb partition by list(a)
+(
+partition p0 values in (1),
+partition p1 values in (2),
+partition p2 values in (0,3,4,5,6,7,8,9)
+);
+insert into t2 select
+mod(seq, 10), seq from seq_1_to_50;
+explain
+delete t1, t2 from t1, t2 where t1.a=t2.a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
+1 SIMPLE t2 ref a a 5 test.t1.a 1
+delete t1, t2 from t1, t2 where t1.a=t2.a;
+drop table t1,t2;
diff --git a/mysql-test/main/partition_innodb2.test b/mysql-test/main/partition_innodb2.test
new file mode 100644
index 00000000000..7581c5db4ca
--- /dev/null
+++ b/mysql-test/main/partition_innodb2.test
@@ -0,0 +1,30 @@
+--source include/not_embedded.inc
+--source include/have_partition.inc
+--source include/have_innodb.inc
+--source include/have_sequence.inc
+
+--echo #
+--echo # MDEV-30442: Assertion `!m_innodb' failed in ha_partition::cmp_ref on MULTI-DELETE
+--echo #
+create table t1 (a int) engine=innodb;
+insert into t1 values (1),(2),(1),(2);
+
+create table t2 (
+ a int,
+ b int,
+ key(a)
+) engine=innodb partition by list(a)
+(
+ partition p0 values in (1),
+ partition p1 values in (2),
+ partition p2 values in (0,3,4,5,6,7,8,9)
+);
+
+insert into t2 select
+ mod(seq, 10), seq from seq_1_to_50;
+
+explain
+delete t1, t2 from t1, t2 where t1.a=t2.a;
+delete t1, t2 from t1, t2 where t1.a=t2.a;
+
+drop table t1,t2;
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index fdb4726a930..5948d657305 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -10784,13 +10784,6 @@ int ha_partition::cmp_ref(const uchar *ref1, const uchar *ref2)
DBUG_RETURN(0);
}
- /*
- In Innodb we compare with either primary key value or global DB_ROW_ID so
- it is not possible that the two references are equal and are in different
- partitions, but in myisam it is possible since we are comparing offsets.
- Remove this assert if DB_ROW_ID is changed to be per partition.
- */
- DBUG_ASSERT(!m_innodb);
DBUG_RETURN(diff2 > diff1 ? -1 : 1);
}