From ec2ff9f2a0f77a3a94a6c8885aa7fa0502d9e56c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 29 Sep 2024 10:49:01 +0200 Subject: [PATCH] MDEV-35035 Assertion failure in ha_blackhole::position upon INSERT into blackhole table with vector index let's allow ::position() and ::rnd_pos() in blackhole. ::position() can be called directly after insert, it doesn't need a search to happen, so it's possible. ::rnd_pos() can be called with a value that ::position() produced, so, possible too. --- mysql-test/main/blackhole.result | 19 ++++++++++++++++--- mysql-test/main/blackhole.test | 27 ++++++++++++++++++--------- storage/blackhole/ha_blackhole.cc | 5 ++--- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/mysql-test/main/blackhole.result b/mysql-test/main/blackhole.result index 21ce77f700f..493cb1af5a0 100644 --- a/mysql-test/main/blackhole.result +++ b/mysql-test/main/blackhole.result @@ -8,6 +8,9 @@ CREATE TABLE t2 (a INT UNSIGNED, b INT, UNIQUE KEY (a, b)) ENGINE=BLACKHOLE; SELECT 1 FROM t1 WHERE a = ANY (SELECT a FROM t2); 1 DROP TABLE t1, t2; +# +# Bug#19786309 - CRASH IN UNLOCK TABLES AFTER LOCKING AND TRUNCATING TEMPORARY TABLE. +# create temporary table t1 (a int) engine=blackhole; lock table t1 write; truncate table t1; @@ -15,7 +18,7 @@ select * from t1; a unlock tables; drop temporary table t1; -End of 5.5 tests +# End of 5.5 tests # # Bug#13948247 DIVISION BY 0 IN GET_BEST_DISJUNCT_QUICK WITH FORCE INDEX GROUP BY # @@ -23,10 +26,20 @@ CREATE TABLE t1(a INT, b INT, c INT, KEY(c), UNIQUE(a)) ENGINE = BLACKHOLE; SELECT 0 FROM t1 FORCE INDEX FOR GROUP BY(a) WHERE a = 0 OR b = 0 AND c = 0; 0 DROP TABLE t1; -End of 5.6 tests +# End of 5.6 tests +# +# MDEV-24017 / bug 53588 test case. +# CREATE TABLE `t` ( `a` varchar(3000) NOT NULL default '', PRIMARY KEY (`a`) ) ENGINE=BLACKHOLE CHARSET=latin1; DROP TABLE `t`; -End of 10.1 tests +# End of 10.1 tests +# +# MDEV-35035 Assertion failure in ha_blackhole::position upon INSERT into blackhole table with vector index +# +create table t (a int, v blob not null, vector index (v)) engine=blackhole; +insert into t values (1,x'00000000'); +drop table t; +# End of 11.7 tests diff --git a/mysql-test/main/blackhole.test b/mysql-test/main/blackhole.test index 13490da32f3..c823ef23003 100644 --- a/mysql-test/main/blackhole.test +++ b/mysql-test/main/blackhole.test @@ -17,9 +17,9 @@ SELECT 1 FROM t1 WHERE a = ANY (SELECT a FROM t2); DROP TABLE t1, t2; -# -# Bug#19786309 - CRASH IN UNLOCK TABLES AFTER LOCKING AND TRUNCATING TEMPORARY TABLE. -# +--echo # +--echo # Bug#19786309 - CRASH IN UNLOCK TABLES AFTER LOCKING AND TRUNCATING TEMPORARY TABLE. +--echo # create temporary table t1 (a int) engine=blackhole; lock table t1 write; truncate table t1; @@ -27,7 +27,7 @@ select * from t1; unlock tables; drop temporary table t1; ---echo End of 5.5 tests +--echo # End of 5.5 tests --echo # --echo # Bug#13948247 DIVISION BY 0 IN GET_BEST_DISJUNCT_QUICK WITH FORCE INDEX GROUP BY @@ -37,11 +37,11 @@ CREATE TABLE t1(a INT, b INT, c INT, KEY(c), UNIQUE(a)) ENGINE = BLACKHOLE; SELECT 0 FROM t1 FORCE INDEX FOR GROUP BY(a) WHERE a = 0 OR b = 0 AND c = 0; DROP TABLE t1; ---echo End of 5.6 tests +--echo # End of 5.6 tests -# -# MDEV-24017 / bug 53588 test case. -# +--echo # +--echo # MDEV-24017 / bug 53588 test case. +--echo # # Create long enough index (between 1000 and 3500). 1000 is the old value, # 3500 is innodb value (see ha_innobase::max_supported_key_length()). Without # the fix the test will fail with "Specified key was too long" error. @@ -53,4 +53,13 @@ CREATE TABLE `t` ( DROP TABLE `t`; ---echo End of 10.1 tests +--echo # End of 10.1 tests + +--echo # +--echo # MDEV-35035 Assertion failure in ha_blackhole::position upon INSERT into blackhole table with vector index +--echo # +create table t (a int, v blob not null, vector index (v)) engine=blackhole; +insert into t values (1,x'00000000'); +drop table t; + +--echo # End of 11.7 tests diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc index c2c2c0a9908..4d5cbb619fe 100644 --- a/storage/blackhole/ha_blackhole.cc +++ b/storage/blackhole/ha_blackhole.cc @@ -148,15 +148,14 @@ int ha_blackhole::rnd_next(uchar *buf) int ha_blackhole::rnd_pos(uchar * buf, uchar *pos) { DBUG_ENTER("ha_blackhole::rnd_pos"); - DBUG_ASSERT(0); - DBUG_RETURN(0); + DBUG_RETURN(HA_ERR_END_OF_FILE); } void ha_blackhole::position(const uchar *record) { DBUG_ENTER("ha_blackhole::position"); - DBUG_ASSERT(0); + bzero(ref, ref_length); DBUG_VOID_RETURN; }