[Commits] 318a7d9b787: MDEV-17676: Assertion `inited==NONE || (inited==RND && scan)' failed in handler::ha_rnd_init
revision-id: 318a7d9b787d3ae38941b8e5c8111d337bb69fd1 (mariadb-10.2.18-126-g318a7d9b787) parent(s): 0d7cf06af5c952f4beaf2d61a903feacb7ca1e1d author: Varun Gupta committer: Varun Gupta timestamp: 2018-12-13 10:27:18 +0530 message: MDEV-17676: Assertion `inited==NONE || (inited==RND && scan)' failed in handler::ha_rnd_init While calculating distinct with the function remove_dup_with_compare, we don't have rnd_end calls when we have completed the scan over the temporary table. Added ha_rnd_end calls when we are done with the scan of the table. --- mysql-test/r/win.result | 13 +++++++++++++ mysql-test/t/win.test | 11 +++++++++++ sql/sql_select.cc | 2 ++ 3 files changed, 26 insertions(+) diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result index 4ffa9f34c1d..e902d62326e 100644 --- a/mysql-test/r/win.result +++ b/mysql-test/r/win.result @@ -3457,3 +3457,16 @@ i row_number() over (partition by i order by i) deallocate prepare stmt; drop table t1; drop view v1; +# +# MDEV-17676: Assertion `inited==NONE || (inited==RND && scan)' failed in handler::ha_rnd_init +# +CREATE TABLE t1 (b1 text NOT NULL); +INSERT INTO t1 VALUES ('2'),('1'); +EXPLAIN +SELECT DISTINCT MIN(b1) OVER () FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary +SELECT DISTINCT MIN(b1) OVER () FROM t1; +MIN(b1) OVER () +1 +drop table t1; diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test index 807d394edd3..b0e1a16fae6 100644 --- a/mysql-test/t/win.test +++ b/mysql-test/t/win.test @@ -2216,3 +2216,14 @@ execute stmt; deallocate prepare stmt; drop table t1; drop view v1; + +--echo # +--echo # MDEV-17676: Assertion `inited==NONE || (inited==RND && scan)' failed in handler::ha_rnd_init +--echo # + +CREATE TABLE t1 (b1 text NOT NULL); +INSERT INTO t1 VALUES ('2'),('1'); +EXPLAIN +SELECT DISTINCT MIN(b1) OVER () FROM t1; +SELECT DISTINCT MIN(b1) OVER () FROM t1; +drop table t1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1309c7bae0c..dc948ff676a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -22138,9 +22138,11 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field, } file->extra(HA_EXTRA_NO_CACHE); + (void) file->ha_rnd_end(); DBUG_RETURN(0); err: file->extra(HA_EXTRA_NO_CACHE); + (void) file->ha_rnd_end(); if (error) file->print_error(error,MYF(0)); DBUG_RETURN(1);
participants (1)
-
Varun