[Commits] 9c2f39e: MDEV-14667 Assertion `used_parts > 0' failed in ha_partition::init_record_priority_queue.

Alexey Botchkov holyfoot at askmonty.org
Sun Apr 15 20:37:30 EEST 2018


revision-id: 9c2f39ea72e0f11565016df4d13200ccfa5e0dca (mariadb-10.3.5-154-g9c2f39e)
parent(s): 560743198604caf677c543db9719cef871df09ce
committer: Alexey Botchkov
timestamp: 2018-04-15 21:35:30 +0400
message:

MDEV-14667 Assertion `used_parts > 0' failed in ha_partition::init_record_priority_queue.

ha_partition::init_record_priority_queue() made tolerant to
the case when all the partitions were pruned away.

---
 mysql-test/main/partition_pruning.result | 10 ++++++++++
 mysql-test/main/partition_pruning.test   | 13 +++++++++++++
 sql/ha_partition.cc                      |  5 ++++-
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/mysql-test/main/partition_pruning.result b/mysql-test/main/partition_pruning.result
index 422132d..7986e09 100644
--- a/mysql-test/main/partition_pruning.result
+++ b/mysql-test/main/partition_pruning.result
@@ -3484,3 +3484,13 @@ select * from t1 where (a = 1 AND b < 'd' AND (c = 'b' OR (c = 'c' AND d = 1)) O
 a	b	c	d
 1	a	b	1
 drop table t1;
+#
+# MDEV-14667 Assertion `used_parts > 0' failed in ha_partition::init_record_priority_queue.
+#
+create table t1 (a int);
+insert into t1 values (1),(2);
+create table t2 (b int, c int, key(c,b)) partition by hash(b) partitions 2;
+insert into t2 values (3,4),(5,6);
+select straight_join * from t1, t2 where b != NULL;
+a	b	c
+drop table t1, t2;
diff --git a/mysql-test/main/partition_pruning.test b/mysql-test/main/partition_pruning.test
index 9d72e9c..592f5ba 100644
--- a/mysql-test/main/partition_pruning.test
+++ b/mysql-test/main/partition_pruning.test
@@ -1536,3 +1536,16 @@ select * from t1 where (a = 1 AND b < 'd' AND (c = 'b' OR (c = 'c' AND d = 1)) O
 drop table t1;
 
 
+--echo #
+--echo # MDEV-14667 Assertion `used_parts > 0' failed in ha_partition::init_record_priority_queue.
+--echo #
+
+create table t1 (a int);
+insert into t1 values (1),(2);
+ 
+create table t2 (b int, c int, key(c,b)) partition by hash(b) partitions 2;
+insert into t2 values (3,4),(5,6);
+ 
+select straight_join * from t1, t2 where b != NULL;
+drop table t1, t2;
+
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 30d4b33..b0f82e8 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -5210,7 +5210,10 @@ bool ha_partition::init_record_priority_queue()
   {
     size_t alloc_len;
     uint used_parts= bitmap_bits_set(&m_part_info->read_partitions);
-    DBUG_ASSERT(used_parts > 0);
+
+    if (used_parts == 0) /* Do nothing since no records expected. */
+      DBUG_RETURN(false);
+
     /* Allocate record buffer for each used partition. */
     m_priority_queue_rec_len= m_rec_length + PARTITION_BYTES_IN_POS;
     if (!m_using_extended_keys)


More information about the commits mailing list