Skip to content

Commit

Permalink
Bug #30912972 ASSERTION `KEYLEN == M_START_KEY.LENGTH' FAILED
Browse files Browse the repository at this point in the history
- A bug in RefOrNullIterator::Read where we called
ha_index_next_same() with a key_part_map value instead of
using keylen triggered an assertion on partitioned tables
containing a null value.
- Fixed the issue by passing m_ref->key_length to the
index_next_same method.
- Added MTR test case that triggers this assertion without
the fix.

RB#24008 approved by Steinar H. Gunderson <steinar.gunderson@oracle.com>
  • Loading branch information
NSkeledzija authored and dahlerlend committed Mar 19, 2020
1 parent b0dc5e8 commit b28bea5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
14 changes: 14 additions & 0 deletions mysql-test/r/subquery_bugs.result
Original file line number Diff line number Diff line change
Expand Up @@ -1485,3 +1485,17 @@ RTRIM(table1.col_tinyint_key) IS NOT NULL;
field1
0
DROP TABLE t1, t2, t3;
#
# Bug #30912972 ASSERTION KEYLEN == M_START_KEY.LENGTH FAILED|PARTITION_HANDLER.CC
#
CREATE TABLE t1 (
col_int_key bigint DEFAULT NULL,
KEY(col_int_key)
) PARTITION BY KEY(col_int_key) PARTITIONS 10;
INSERT INTO t1 VALUES
(NULL);
SELECT 42
WHERE 11 NOT IN
(SELECT col_int_key FROM t1);
42
DROP TABLE t1;
18 changes: 18 additions & 0 deletions mysql-test/t/subquery_bugs.test
Original file line number Diff line number Diff line change
Expand Up @@ -1156,3 +1156,21 @@ eval explain $query;
eval $query;

DROP TABLE t1, t2, t3;

--echo #
--echo # Bug #30912972 ASSERTION KEYLEN == M_START_KEY.LENGTH FAILED|PARTITION_HANDLER.CC
--echo #

CREATE TABLE t1 (
col_int_key bigint DEFAULT NULL,
KEY(col_int_key)
) PARTITION BY KEY(col_int_key) PARTITIONS 10;

INSERT INTO t1 VALUES
(NULL);

SELECT 42
WHERE 11 NOT IN
(SELECT col_int_key FROM t1);

DROP TABLE t1;
2 changes: 1 addition & 1 deletion sql/sql_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4165,7 +4165,7 @@ int RefOrNullIterator::Read() {
HA_READ_KEY_EXACT);
} else {
error = table()->file->ha_index_next_same(
table()->record[0], key_buff_and_map.first, key_buff_and_map.second);
table()->record[0], key_buff_and_map.first, m_ref->key_length);
}

if (error == 0) {
Expand Down

0 comments on commit b28bea5

Please sign in to comment.