summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2022-08-19 11:24:51 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2022-09-27 15:27:34 +0400
commitb2cfcf1d1f260756cceb4f19e330b4955c381f98 (patch)
tree11905534cf733c2b44943dd26119a4e61a6e048b
parent47e967898283a1fef44a7b84467cf26ff6bd63a3 (diff)
downloadmariadb-git-b2cfcf1d1f260756cceb4f19e330b4955c381f98.tar.gz
MDEV-21134 Crash with partitioned table, PARTITION syntax, and index_merge.
When the partition table is cloned, the handlers for the partitions that were not opened should anyway be created (but not opened).
-rw-r--r--mysql-test/main/partition_explicit_prune.result82
-rw-r--r--mysql-test/main/partition_explicit_prune.test34
-rw-r--r--sql/ha_partition.cc15
3 files changed, 126 insertions, 5 deletions
diff --git a/mysql-test/main/partition_explicit_prune.result b/mysql-test/main/partition_explicit_prune.result
index 57068732b34..acb4175eac4 100644
--- a/mysql-test/main/partition_explicit_prune.result
+++ b/mysql-test/main/partition_explicit_prune.result
@@ -1888,7 +1888,7 @@ ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
SELECT * FROM t1 PARTITION (p0);
i
UNLOCK TABLES;
-DROP TABLE t1;
+DROP TABLE t1, t2;
#
# MDEV-18371 Server crashes in ha_innobase::cmp_ref upon UPDATE with PARTITION clause.
#
@@ -1906,4 +1906,82 @@ a b
4 3
8 2
2 6
-DROP TABLE t1, t2;
+DROP TABLE t1;
+#
+# MDEV-21134 Crash with partitioned table, PARTITION syntax, and index_merge.
+#
+create table t1 (
+pk int primary key,
+a int,
+b int,
+filler char(32),
+key (a),
+key (b)
+) engine=myisam partition by range(pk) (
+partition p0 values less than (10),
+partition p1 values less than MAXVALUE
+) ;
+insert into t1 select
+seq,
+MOD(seq, 100),
+MOD(seq, 100),
+'filler-data-filler-data'
+ from
+seq_1_to_5000;
+explain select * from t1 partition (p1) where a=10 and b=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where
+flush tables;
+select * from t1 partition (p1)where a=10 and b=10;
+pk a b filler
+10 10 10 filler-data-filler-data
+110 10 10 filler-data-filler-data
+210 10 10 filler-data-filler-data
+310 10 10 filler-data-filler-data
+410 10 10 filler-data-filler-data
+510 10 10 filler-data-filler-data
+610 10 10 filler-data-filler-data
+710 10 10 filler-data-filler-data
+810 10 10 filler-data-filler-data
+910 10 10 filler-data-filler-data
+1010 10 10 filler-data-filler-data
+1110 10 10 filler-data-filler-data
+1210 10 10 filler-data-filler-data
+1310 10 10 filler-data-filler-data
+1410 10 10 filler-data-filler-data
+1510 10 10 filler-data-filler-data
+1610 10 10 filler-data-filler-data
+1710 10 10 filler-data-filler-data
+1810 10 10 filler-data-filler-data
+1910 10 10 filler-data-filler-data
+2010 10 10 filler-data-filler-data
+2110 10 10 filler-data-filler-data
+2210 10 10 filler-data-filler-data
+2310 10 10 filler-data-filler-data
+2410 10 10 filler-data-filler-data
+2510 10 10 filler-data-filler-data
+2610 10 10 filler-data-filler-data
+2710 10 10 filler-data-filler-data
+2810 10 10 filler-data-filler-data
+2910 10 10 filler-data-filler-data
+3010 10 10 filler-data-filler-data
+3110 10 10 filler-data-filler-data
+3210 10 10 filler-data-filler-data
+3310 10 10 filler-data-filler-data
+3410 10 10 filler-data-filler-data
+3510 10 10 filler-data-filler-data
+3610 10 10 filler-data-filler-data
+3710 10 10 filler-data-filler-data
+3810 10 10 filler-data-filler-data
+3910 10 10 filler-data-filler-data
+4010 10 10 filler-data-filler-data
+4110 10 10 filler-data-filler-data
+4210 10 10 filler-data-filler-data
+4310 10 10 filler-data-filler-data
+4410 10 10 filler-data-filler-data
+4510 10 10 filler-data-filler-data
+4610 10 10 filler-data-filler-data
+4710 10 10 filler-data-filler-data
+4810 10 10 filler-data-filler-data
+4910 10 10 filler-data-filler-data
+DROP TABLE t1;
diff --git a/mysql-test/main/partition_explicit_prune.test b/mysql-test/main/partition_explicit_prune.test
index 0be21396148..b215830a068 100644
--- a/mysql-test/main/partition_explicit_prune.test
+++ b/mysql-test/main/partition_explicit_prune.test
@@ -1,5 +1,6 @@
--source include/have_innodb.inc
--source include/have_partition.inc
+--source include/have_sequence.inc
# Helper statement
let $get_handler_status_counts= SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS
@@ -874,7 +875,7 @@ SELECT * FROM t1 PARTITION (p0);
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
SELECT * FROM t1 PARTITION (p0);
UNLOCK TABLES;
-DROP TABLE t1;
+DROP TABLE t1, t2;
--echo #
--echo # MDEV-18371 Server crashes in ha_innobase::cmp_ref upon UPDATE with PARTITION clause.
@@ -885,7 +886,34 @@ 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;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-21134 Crash with partitioned table, PARTITION syntax, and index_merge.
+--echo #
+create table t1 (
+ pk int primary key,
+ a int,
+ b int,
+ filler char(32),
+ key (a),
+ key (b)
+ ) engine=myisam partition by range(pk) (
+ partition p0 values less than (10),
+ partition p1 values less than MAXVALUE
+ ) ;
+
+insert into t1 select
+seq,
+ MOD(seq, 100),
+ MOD(seq, 100),
+ 'filler-data-filler-data'
+ from
+ seq_1_to_5000;
+
+explain select * from t1 partition (p1) where a=10 and b=10;
+flush tables;
+select * from t1 partition (p1)where a=10 and b=10;
-# Cleanup
-DROP TABLE t1, t2;
+DROP TABLE t1;
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 0a8cf3b9532..1b265d7e05f 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -3637,7 +3637,22 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
for (i= 0; i < m_tot_parts; i++)
{
if (!bitmap_is_set(&m_is_clone_of->m_opened_partitions, i))
+ {
+ /* Here we should just create the handler instance, not open it. */
+ if (!(m_file[i]= get_new_handler(table->s, m_clone_mem_root,
+ file[i]->ht)))
+ {
+ error= HA_ERR_INITIALIZATION;
+ file= &m_file[i];
+ goto err_handler;
+ }
+ if (m_file[i]->set_ha_share_ref(file[i]->ha_share))
+ {
+ error= HA_ERR_INITIALIZATION;
+ goto err_handler;
+ }
continue;
+ }
if (unlikely((error= create_partition_name(name_buff, sizeof(name_buff),
name, name_buffer_ptr,