summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2020-07-17 12:20:23 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2020-07-17 12:20:23 +0400
commit2cae58f8918f64c77227cfa07ab2fd24c3580f81 (patch)
treeafc69562c22406442d109d15e201a9de60cfdca1
parent73aa31fbfd793bdb597bb19c52118ab4e637f4bc (diff)
downloadmariadb-git-2cae58f8918f64c77227cfa07ab2fd24c3580f81.tar.gz
MDEV-18371 Server crashes in ha_innobase::cmp_ref upon UPDATE with PARTITION clause.
m_file[0] not always is a good sample.
-rw-r--r--mysql-test/main/partition_explicit_prune.result18
-rw-r--r--mysql-test/main/partition_explicit_prune.test12
-rw-r--r--sql/ha_partition.cc7
3 files changed, 34 insertions, 3 deletions
diff --git a/mysql-test/main/partition_explicit_prune.result b/mysql-test/main/partition_explicit_prune.result
index 951b21db3e1..0c102501a9d 100644
--- a/mysql-test/main/partition_explicit_prune.result
+++ b/mysql-test/main/partition_explicit_prune.result
@@ -1888,4 +1888,22 @@ ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
SELECT * FROM t1 PARTITION (p0);
i
UNLOCK TABLES;
+DROP TABLE t1;
+#
+# MDEV-18371 Server crashes in ha_innobase::cmp_ref upon UPDATE with PARTITION clause.
+#
+CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE=InnoDB PARTITION BY KEY(b) PARTITIONS 4;
+INSERT INTO t1 VALUES (3,0),(8,2),(7,8),(3,4),(2,4),(0,7),(4,3),(3,6);
+FLUSH TABLES;
+UPDATE t1 PARTITION (p3,p1) SET a = 2 WHERE a = 3;
+SELECT * FROM t1;
+a b
+2 0
+7 8
+2 4
+2 4
+0 7
+4 3
+8 2
+2 6
DROP TABLE t1, t2;
diff --git a/mysql-test/main/partition_explicit_prune.test b/mysql-test/main/partition_explicit_prune.test
index b8b6e480ce9..0be21396148 100644
--- a/mysql-test/main/partition_explicit_prune.test
+++ b/mysql-test/main/partition_explicit_prune.test
@@ -874,6 +874,18 @@ SELECT * FROM t1 PARTITION (p0);
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
SELECT * FROM t1 PARTITION (p0);
UNLOCK TABLES;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-18371 Server crashes in ha_innobase::cmp_ref upon UPDATE with PARTITION clause.
+--echo #
+
+CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE=InnoDB PARTITION BY KEY(b) PARTITIONS 4;
+INSERT INTO t1 VALUES (3,0),(8,2),(7,8),(3,4),(2,4),(0,7),(4,3),(3,6);
+FLUSH TABLES;
+UPDATE t1 PARTITION (p3,p1) SET a = 2 WHERE a = 3;
+SELECT * FROM t1;
+
# Cleanup
DROP TABLE t1, t2;
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index e19f21de006..92f527de3bc 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -5580,8 +5580,9 @@ extern "C" int cmp_key_rowid_part_id(void *ptr, uchar *ref1, uchar *ref2)
{
return res;
}
- if ((res= file->m_file[0]->cmp_ref(ref1 + PARTITION_BYTES_IN_POS + file->m_rec_length,
- ref2 + PARTITION_BYTES_IN_POS + file->m_rec_length)))
+ if ((res= file->get_open_file_sample()->cmp_ref(ref1 +
+ PARTITION_BYTES_IN_POS + file->m_rec_length,
+ ref2 + PARTITION_BYTES_IN_POS + file->m_rec_length)))
{
return res;
}
@@ -9577,7 +9578,7 @@ uint8 ha_partition::table_cache_type()
{
DBUG_ENTER("ha_partition::table_cache_type");
- DBUG_RETURN(m_file[0]->table_cache_type());
+ DBUG_RETURN(get_open_file_sample()->table_cache_type());
}