diff options
author | Alexey Botchkov <holyfoot@askmonty.org> | 2020-07-17 12:20:23 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@askmonty.org> | 2020-07-17 12:20:23 +0400 |
commit | 2cae58f8918f64c77227cfa07ab2fd24c3580f81 (patch) | |
tree | afc69562c22406442d109d15e201a9de60cfdca1 | |
parent | 73aa31fbfd793bdb597bb19c52118ab4e637f4bc (diff) | |
download | mariadb-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.result | 18 | ||||
-rw-r--r-- | mysql-test/main/partition_explicit_prune.test | 12 | ||||
-rw-r--r-- | sql/ha_partition.cc | 7 |
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()); } |