diff options
| author | unknown <serg@serg.mylan> | 2003-09-03 22:27:04 +0200 |
|---|---|---|
| committer | unknown <serg@serg.mylan> | 2003-09-03 22:27:04 +0200 |
| commit | b59f6efb8d9da700843cee3729f8966705791544 (patch) | |
| tree | 80e6e6693078781137ee833b781a230d81dfb390 | |
| parent | c03b19c89887fd4a205b034e8a8a514920b41e60 (diff) | |
| download | mariadb-git-b59f6efb8d9da700843cee3729f8966705791544.tar.gz | |
bug #1172 - crash on force index() and SEL_ARG::MAYBE_KEY
| -rw-r--r-- | mysql-test/r/range.result | 13 | ||||
| -rw-r--r-- | mysql-test/t/range.test | 11 | ||||
| -rw-r--r-- | 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 <t2.keya + 1) and t2.keya=3; +table type possible_keys key key_len ref rows Extra +t2 ref j1 j1 4 const 1 Using where; Using index +t1 ALL i1,i2 NULL NULL NULL 4 Range checked for each record (index map: 3) +explain select * from t1 force index(i2), t2 where (t1.key1 <t2.keya + 1) and t2.keya=3; +table type possible_keys key key_len ref rows Extra +t2 ref j1 j1 4 const 1 Using where; Using index +t1 ALL i2 NULL NULL NULL 4 Range checked for each record (index map: 2) +DROP TABLE t1,t2; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 3e749682475..75ca0fff5f2 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -203,3 +203,14 @@ explain select count(*) from t1 where x in (1); explain select count(*) from t1 where x in (1,2); drop table t1; +# +# bug #1172 +# +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 <t2.keya + 1) and t2.keya=3; +explain select * from t1 force index(i2), t2 where (t1.key1 <t2.keya + 1) and t2.keya=3; +DROP TABLE t1,t2; + diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 5049700a67f..8dad80d3eba 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -692,7 +692,7 @@ int SQL_SELECT::test_quick_select(key_map keys_to_use, table_map prev_tables, uint keynr= param.real_keynr[idx]; if ((*key)->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; |
