Commit 32eeed21 authored by Varun Gupta's avatar Varun Gupta

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.
parent 20011c8b
...@@ -3457,3 +3457,16 @@ i row_number() over (partition by i order by i) ...@@ -3457,3 +3457,16 @@ i row_number() over (partition by i order by i)
deallocate prepare stmt; deallocate prepare stmt;
drop table t1; drop table t1;
drop view v1; 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;
...@@ -2216,3 +2216,14 @@ execute stmt; ...@@ -2216,3 +2216,14 @@ execute stmt;
deallocate prepare stmt; deallocate prepare stmt;
drop table t1; drop table t1;
drop view v1; 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;
...@@ -22138,9 +22138,11 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field, ...@@ -22138,9 +22138,11 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field,
} }
file->extra(HA_EXTRA_NO_CACHE); file->extra(HA_EXTRA_NO_CACHE);
(void) file->ha_rnd_end();
DBUG_RETURN(0); DBUG_RETURN(0);
err: err:
file->extra(HA_EXTRA_NO_CACHE); file->extra(HA_EXTRA_NO_CACHE);
(void) file->ha_rnd_end();
if (error) if (error)
file->print_error(error,MYF(0)); file->print_error(error,MYF(0));
DBUG_RETURN(1); DBUG_RETURN(1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment