From f0879fd9a765a996e28408671d957992d53142fd Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 Sep 2003 22:27:04 +0200 Subject: [PATCH] bug #1172 - crash on force index() and SEL_ARG::MAYBE_KEY --- mysql-test/r/range.result | 13 +++++++++++++ mysql-test/t/range.test | 11 +++++++++++ sql/opt_range.cc | 4 ++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index a02da87b0e9..2bd80cbfba3 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -260,3 +260,16 @@ explain select count(*) from t1 where x in (1,2); table type possible_keys key key_len ref rows Extra t1 range x x 5 NULL 2 Using where; Using index drop table t1; +CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1), KEY i2 (key1)); +INSERT INTO t1 VALUES (0),(0),(1),(1); +CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya)); +INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); +explain select * from t1, t2 where (t1.key1 type == SEL_ARG::MAYBE_KEY || (*key)->maybe_flag) - needed_reg|= (key_map) 1 << keynr; + needed_reg|= (key_map) 1 << keynr; found_records=check_quick_select(¶m, idx, *key); if (found_records != HA_POS_ERROR && found_records > 2 && @@ -716,7 +716,7 @@ int SQL_SELECT::test_quick_select(key_map keys_to_use, table_map prev_tables, param.range_count, found_records)+ (double) found_records / TIME_FOR_COMPARE); - if (read_time > found_read_time) + if (read_time > found_read_time && found_records != HA_POS_ERROR) { read_time=found_read_time; records=found_records;