Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
bf683af4
Commit
bf683af4
authored
Jan 09, 2003
by
monty@mashka.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Post merge fix
Allow empty key list in USE|IGNORE|FORCE INDEX()
parent
f8e660d8
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
129 additions
and
67 deletions
+129
-67
mysql-test/r/myisam.result
mysql-test/r/myisam.result
+25
-19
mysql-test/t/myisam.test
mysql-test/t/myisam.test
+2
-0
mysys/my_handler.c
mysys/my_handler.c
+51
-36
sql/sql_lex.cc
sql/sql_lex.cc
+7
-1
sql/sql_lex.h
sql/sql_lex.h
+2
-2
sql/sql_parse.cc
sql/sql_parse.cc
+24
-4
sql/sql_yacc.yy
sql/sql_yacc.yy
+18
-5
No files found.
mysql-test/r/myisam.result
View file @
bf683af4
...
...
@@ -332,29 +332,35 @@ t1 1 a 2 b A 5 NULL NULL YES BTREE
t1 1 c_2 1 c A 5 NULL NULL YES BTREE
t1 1 c_2 2 a A 5 NULL NULL BTREE
explain select * from t1,t2 where t1.a=t2.a;
table type possible_keys key key_len ref rows Extra
t1 ALL a NULL NULL NULL 5
t2 ALL a NULL NULL NULL 2 Using where
id select_type
table type possible_keys key key_len ref rows Extra
1 SIMPLE
t1 ALL a NULL NULL NULL 5
1 SIMPLE
t2 ALL a NULL NULL NULL 2 Using where
explain select * from t1,t2 force index(a) where t1.a=t2.a;
table type possible_keys key key_len ref rows Extra
t2 ALL a NULL NULL NULL 2
t1 ALL a NULL NULL NULL 5 Using where
id select_type
table type possible_keys key key_len ref rows Extra
1 SIMPLE
t2 ALL a NULL NULL NULL 2
1 SIMPLE
t1 ALL a NULL NULL NULL 5 Using where
explain select * from t1 force index(a),t2 force index(a) where t1.a=t2.a;
table type possible_keys key key_len ref rows Extra
t2 ALL a NULL NULL NULL 2
t1 ref a a 4 t2.a 3
id select_type
table type possible_keys key key_len ref rows Extra
1 SIMPLE
t2 ALL a NULL NULL NULL 2
1 SIMPLE
t1 ref a a 4 t2.a 3
explain select * from t1,t2 where t1.b=t2.b;
table type possible_keys key key_len ref rows Extra
t2 ALL b NULL NULL NULL 2
t1 ref b b 5 t2.b 1 Using where
id select_type
table type possible_keys key key_len ref rows Extra
1 SIMPLE
t2 ALL b NULL NULL NULL 2
1 SIMPLE
t1 ref b b 5 t2.b 1 Using where
explain select * from t1,t2 force index(c) where t1.a=t2.a;
table type possible_keys key key_len ref rows Extra
t1 ALL a NULL NULL NULL 5
t2 ALL NULL NULL NULL NULL 2 Using where
id select_type
table type possible_keys key key_len ref rows Extra
1 SIMPLE
t1 ALL a NULL NULL NULL 5
1 SIMPLE
t2 ALL NULL NULL NULL NULL 2 Using where
explain select * from t1 where a=0 or a=2;
table type possible_keys key key_len ref rows Extra
t1 ALL a NULL NULL NULL 5 Using where
id select_type
table type possible_keys key key_len ref rows Extra
1 SIMPLE
t1 ALL a NULL NULL NULL 5 Using where
explain select * from t1 force index (a) where a=0 or a=2;
table type possible_keys key key_len ref rows Extra
t1 range a a 4 NULL 4 Using where
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 4 NULL 4 Using where
explain select * from t1 where c=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref c,c_2 c 5 const 1 Using where
explain select * from t1 use index() where c=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
drop table t1,t2;
mysql-test/t/myisam.test
View file @
bf683af4
...
...
@@ -349,4 +349,6 @@ explain select * from t1,t2 where t1.b=t2.b;
explain
select
*
from
t1
,
t2
force
index
(
c
)
where
t1
.
a
=
t2
.
a
;
explain
select
*
from
t1
where
a
=
0
or
a
=
2
;
explain
select
*
from
t1
force
index
(
a
)
where
a
=
0
or
a
=
2
;
explain
select
*
from
t1
where
c
=
1
;
explain
select
*
from
t1
use
index
() where c=1
;
drop
table
t1
,
t2
;
mysys/my_handler.c
View file @
bf683af4
This diff is collapsed.
Click to expand it.
sql/sql_lex.cc
View file @
bf683af4
...
...
@@ -1171,13 +1171,14 @@ List<String>* st_select_lex_node::get_use_index() { return 0; }
List
<
String
>*
st_select_lex_node
::
get_ignore_index
()
{
return
0
;
}
TABLE_LIST
*
st_select_lex_node
::
add_table_to_list
(
THD
*
thd
,
Table_ident
*
table
,
LEX_STRING
*
alias
,
bool
updating
,
ulong
table_join_options
,
thr_lock_type
flags
,
List
<
String
>
*
use_index
,
List
<
String
>
*
ignore_index
)
{
return
0
;
}
ulong
st_select_lex_node
::
get_table_join_options
()
{
return
0
;
}
/*
This is used for UNION & subselect to create a new table list of all used
...
...
@@ -1334,6 +1335,11 @@ List<String>* st_select_lex::get_ignore_index()
return
ignore_index_ptr
;
}
ulong
st_select_lex
::
get_table_join_options
()
{
return
table_join_options
;
}
/*
There are st_select_lex::add_table_to_list &
st_select_lex::set_lock_for_tables in sql_parse.cc
...
...
sql/sql_lex.h
View file @
bf683af4
...
...
@@ -243,7 +243,7 @@ public:
virtual
List
<
Item
>*
get_item_list
();
virtual
List
<
String
>*
get_use_index
();
virtual
List
<
String
>*
get_ignore_index
();
virtual
ulong
table_join_options
();
virtual
ulong
get_
table_join_options
();
virtual
TABLE_LIST
*
add_table_to_list
(
THD
*
thd
,
Table_ident
*
table
,
LEX_STRING
*
alias
,
ulong
table_options
,
...
...
@@ -375,7 +375,7 @@ public:
List
<
Item
>*
get_item_list
();
List
<
String
>*
get_use_index
();
List
<
String
>*
get_ignore_index
();
ulong
table_join_options
();
ulong
get_
table_join_options
();
TABLE_LIST
*
add_table_to_list
(
THD
*
thd
,
Table_ident
*
table
,
LEX_STRING
*
alias
,
ulong
table_options
,
...
...
sql/sql_parse.cc
View file @
bf683af4
...
...
@@ -3598,11 +3598,30 @@ bool add_to_list(THD *thd, SQL_LIST &list,Item *item,bool asc)
}
/*
Add a table to list of used tables
SYNOPSIS
add_table_to_list()
table Table to add
alias alias for table (or null if no alias)
table_options A set of the following bits:
TL_OPTION_UPDATING Table will be updated
TL_OPTION_FORCE_INDEX Force usage of index
lock_type How table should be locked
use_index List of indexed used in USE INDEX
ignore_index List of indexed used in IGNORE INDEX
RETURN
0 Error
# Pointer to TABLE_LIST element added to the total table list
*/
TABLE_LIST
*
st_select_lex
::
add_table_to_list
(
THD
*
thd
,
Table_ident
*
table
,
LEX_STRING
*
alias
,
bool
updating
,
thr_lock_type
flags
,
ulong
table_options
,
thr_lock_type
lock_type
,
List
<
String
>
*
use_index
,
List
<
String
>
*
ignore_index
)
{
...
...
@@ -3659,8 +3678,9 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
}
ptr
->
real_name
=
table
->
table
.
str
;
ptr
->
real_name_length
=
table
->
table
.
length
;
ptr
->
lock_type
=
flags
;
ptr
->
updating
=
updating
;
ptr
->
lock_type
=
lock_type
;
ptr
->
updating
=
test
(
table_options
&
TL_OPTION_UPDATING
);
ptr
->
force_index
=
test
(
table_options
&
TL_OPTION_FORCE_INDEX
);
ptr
->
derived
=
(
SELECT_LEX_UNIT
*
)
table
->
sel
;
if
(
use_index
)
ptr
->
use_index
=
(
List
<
String
>
*
)
thd
->
memdup
((
gptr
)
use_index
,
...
...
sql/sql_yacc.yy
View file @
bf683af4
...
...
@@ -1359,7 +1359,7 @@ opt_unique_or_fulltext:
key_alg:
/* empty */ { $$= HA_KEY_ALG_UNDEF; }
| USING opt_btree_or_rtree { $$= $2; };
| TYPE opt_btree_or_rtree { $$= $2; };
| TYPE
_SYM
opt_btree_or_rtree { $$= $2; };
opt_btree_or_rtree:
BTREE_SYM { $$= HA_KEY_ALG_BTREE; }
...
...
@@ -2516,14 +2516,14 @@ join_table:
{
SELECT_LEX *sel= Select->select_lex();
sel->use_index_ptr=sel->ignore_index_ptr=0;
sel->table_join_ptions= 0;
sel->table_join_
o
ptions= 0;
}
table_ident opt_table_alias opt_key_definition
{
LEX *lex= Lex;
SELECT_LEX_NODE *sel= lex->current_select;
if (!($$= sel->add_table_to_list(lex->thd, $2, $3,
lex->
table_join_options(),
sel->get_
table_join_options(),
lex->lock_option,
sel->get_use_index(),
sel->get_ignore_index())))
...
...
@@ -2569,6 +2569,13 @@ opt_key_definition:
sel->use_index= *$2;
sel->use_index_ptr= &sel->use_index;
}
| FORCE_SYM key_usage_list
{
SELECT_LEX *sel= Select->select_lex();
sel->use_index= *$2;
sel->use_index_ptr= &sel->use_index;
sel->table_join_options|= TL_OPTION_FORCE_INDEX;
}
| IGNORE_SYM key_usage_list
{
SELECT_LEX *sel= Select->select_lex();
...
...
@@ -2578,8 +2585,14 @@ opt_key_definition:
key_usage_list:
key_or_index { Select->select_lex()->interval_list.empty(); }
'(' key_usage_list2 ')'
{ $$= &Select->select_lex()->interval_list; };
'(' key_list_or_empty ')'
{ $$= &Select->select_lex()->interval_list; }
;
key_list_or_empty:
/* empty */ {}
| key_usage_list2 {}
;
key_usage_list2:
key_usage_list2 ',' ident
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment