Commit 16977474 authored by Sergei Petrunia's avatar Sergei Petrunia Committed by Oleksandr Byelkin

MDEV-32682: Assertion `range->rows >= s->found_records' failed in best_access_path

Fix the issue introduced in ec2574fd, fix for MDEV-31983:

get_quick_record_count() must set quick_count=0 when it got
IMPOSSIBLE_RANGE from test_quick_select.

Failure to do so will cause an assertion in 11.0, when the number of
quick select rows (0) is checked to be lower than the number of
found_records (which is capped up to 1).
parent b52b7b41
......@@ -2700,6 +2700,22 @@ UPDATE t1, t2 SET t1.a = 26 WHERE t2.b IN (SELECT MIN(d) FROM t3 WHERE c >= '201
ERROR 22007: Incorrect datetime value: '2012-01' for column `test`.`t3`.`c` at row 1
DROP TABLE t1, t2, t3;
#
# a followup fix:
# MDEV-32682: Assertion `range->rows >= s->found_records' failed in best_access_path
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b VARCHAR(10), pk INT, PRIMARY KEY (pk)) ENGINE=MyISAM;
ANALYZE TABLE t1, t2 PERSISTENT FOR ALL;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status Table is already up to date
SELECT STRAIGHT_JOIN t2.* FROM t1 JOIN t2 WHERE t2.b IS NULL AND t2.pk > 1;
b pk
DROP TABLE t1, t2;
#
# MDEV-32612 Assertion `tab->select->quick' failed in test_if_skip_sort_order
#
CREATE TABLE t1 (l_orderkey int, l_linenumber int, l_quantity double,
......
......@@ -2742,6 +2742,22 @@ UPDATE t1, t2 SET t1.a = 26 WHERE t2.b IN (SELECT MIN(d) FROM t3 WHERE c >= '201
ERROR 22007: Incorrect datetime value: '2012-01' for column `test`.`t3`.`c` at row 1
DROP TABLE t1, t2, t3;
#
# a followup fix:
# MDEV-32682: Assertion `range->rows >= s->found_records' failed in best_access_path
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b VARCHAR(10), pk INT, PRIMARY KEY (pk)) ENGINE=MyISAM;
ANALYZE TABLE t1, t2 PERSISTENT FOR ALL;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status Table is already up to date
SELECT STRAIGHT_JOIN t2.* FROM t1 JOIN t2 WHERE t2.b IS NULL AND t2.pk > 1;
b pk
DROP TABLE t1, t2;
#
# MDEV-32612 Assertion `tab->select->quick' failed in test_if_skip_sort_order
#
CREATE TABLE t1 (l_orderkey int, l_linenumber int, l_quantity double,
......
......@@ -2436,6 +2436,19 @@ UPDATE t1, t2 SET t1.a = 26 WHERE t2.b IN (SELECT MIN(d) FROM t3 WHERE c >= '201
# Cleanup
DROP TABLE t1, t2, t3;
--echo #
--echo # a followup fix:
--echo # MDEV-32682: Assertion `range->rows >= s->found_records' failed in best_access_path
--echo #
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b VARCHAR(10), pk INT, PRIMARY KEY (pk)) ENGINE=MyISAM;
ANALYZE TABLE t1, t2 PERSISTENT FOR ALL;
SELECT STRAIGHT_JOIN t2.* FROM t1 JOIN t2 WHERE t2.b IS NULL AND t2.pk > 1;
DROP TABLE t1, t2;
--echo #
--echo # MDEV-32612 Assertion `tab->select->quick' failed in test_if_skip_sort_order
--echo #
......
......@@ -5181,6 +5181,7 @@ static bool get_quick_record_count(THD *thd, SQL_SELECT *select,
if (error == SQL_SELECT::IMPOSSIBLE_RANGE)
{
table->reginfo.impossible_range=1;
*quick_count= 0;
DBUG_RETURN(false);
}
if (unlikely(error == SQL_SELECT::ERROR))
......
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