From ff79cd687090ec4afcdaaaf44c85849f057402c8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Mar 2007 15:20:06 +0200 Subject: WL#3527: Extend IGNORE INDEX so places where index is ignored can be specified 5.0 part of the fix. Implements IGNORE INDEX FOR JOIN as a synonym of IGNORE INDEX for backward compatibility with the 5.1 fix. mysql-test/r/select.result: WL#3527: Extend IGNORE INDEX so places where index is ignored can be specified - test case mysql-test/t/select.test: WL#3527: Extend IGNORE INDEX so places where index is ignored can be specified - test case --- mysql-test/r/select.result | 9 +++++++++ mysql-test/t/select.test | 10 ++++++++++ sql/sql_yacc.yy | 17 +++++++++++++---- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 44063c1e890..6fbe0a3b9df 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -3611,3 +3611,12 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range si,ai si 5 NULL 2 Using where 1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a INT, b INT, KEY (a)); +INSERT INTO t1 VALUES (1,1),(2,2); +EXPLAIN SELECT 1 FROM t1 WHERE a = 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 5 const 1 Using where; Using index +EXPLAIN SELECT 1 FROM t1 IGNORE INDEX FOR JOIN (a) WHERE a = 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where +DROP TABLE t1; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 0c82cef867f..033573304c7 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3092,3 +3092,13 @@ SELECT t3.a FROM t1,t2,t3 t3.c IN ('bb','ee'); DROP TABLE t1,t2,t3; + +# +# WL3527: Extend IGNORE INDEX so places where index is ignored can +# be specified +# +CREATE TABLE t1 (a INT, b INT, KEY (a)); INSERT INTO t1 VALUES (1,1),(2,2); +EXPLAIN SELECT 1 FROM t1 WHERE a = 1; +EXPLAIN SELECT 1 FROM t1 IGNORE INDEX FOR JOIN (a) WHERE a = 1; +DROP TABLE t1; + diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 90dc6d54fe1..69052e5e0d6 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -772,7 +772,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); key_alg opt_btree_or_rtree %type - key_usage_list using_list + key_usage_list key_usage_list_inner using_list %type key_part @@ -5553,6 +5553,10 @@ opt_outer: /* empty */ {} | OUTER {}; +opt_for_join: + /* empty */ + | FOR_SYM JOIN_SYM; + opt_key_definition: /* empty */ {} | USE_SYM key_usage_list @@ -5568,15 +5572,20 @@ opt_key_definition: sel->use_index_ptr= &sel->use_index; sel->table_join_options|= TL_OPTION_FORCE_INDEX; } - | IGNORE_SYM key_usage_list + | IGNORE_SYM key_or_index opt_for_join key_usage_list_inner { SELECT_LEX *sel= Select; - sel->ignore_index= *$2; + sel->ignore_index= *$4; sel->ignore_index_ptr= &sel->ignore_index; }; key_usage_list: - key_or_index { Select->interval_list.empty(); } + key_or_index key_usage_list_inner + { $$= $2; } + ; + +key_usage_list_inner: + { Select->interval_list.empty(); } '(' key_list_or_empty ')' { $$= &Select->interval_list; } ; -- cgit v1.2.1