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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
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
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
...
@@ -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 1 c A 5 NULL NULL YES BTREE
t1 1 c_2 2 a A 5 NULL NULL BTREE
t1 1 c_2 2 a A 5 NULL NULL BTREE
explain select * from t1,t2 where t1.a=t2.a;
explain select * from t1,t2 where t1.a=t2.a;
table type possible_keys key key_len ref rows Extra
id select_type
table type possible_keys key key_len ref rows Extra
t1 ALL a NULL NULL NULL 5
1 SIMPLE
t1 ALL a NULL NULL NULL 5
t2 ALL a NULL NULL NULL 2 Using where
1 SIMPLE
t2 ALL a NULL NULL NULL 2 Using where
explain select * from t1,t2 force index(a) where t1.a=t2.a;
explain select * from t1,t2 force index(a) where t1.a=t2.a;
table type possible_keys key key_len ref rows Extra
id select_type
table type possible_keys key key_len ref rows Extra
t2 ALL a NULL NULL NULL 2
1 SIMPLE
t2 ALL a NULL NULL NULL 2
t1 ALL a NULL NULL NULL 5 Using where
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;
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
id select_type
table type possible_keys key key_len ref rows Extra
t2 ALL a NULL NULL NULL 2
1 SIMPLE
t2 ALL a NULL NULL NULL 2
t1 ref a a 4 t2.a 3
1 SIMPLE
t1 ref a a 4 t2.a 3
explain select * from t1,t2 where t1.b=t2.b;
explain select * from t1,t2 where t1.b=t2.b;
table type possible_keys key key_len ref rows Extra
id select_type
table type possible_keys key key_len ref rows Extra
t2 ALL b NULL NULL NULL 2
1 SIMPLE
t2 ALL b NULL NULL NULL 2
t1 ref b b 5 t2.b 1 Using where
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;
explain select * from t1,t2 force index(c) where t1.a=t2.a;
table type possible_keys key key_len ref rows Extra
id select_type
table type possible_keys key key_len ref rows Extra
t1 ALL a NULL NULL NULL 5
1 SIMPLE
t1 ALL a NULL NULL NULL 5
t2 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE
t2 ALL NULL NULL NULL NULL 2 Using where
explain select * from t1 where a=0 or a=2;
explain select * from t1 where a=0 or a=2;
table type possible_keys key key_len ref rows Extra
id select_type
table type possible_keys key key_len ref rows Extra
t1 ALL a NULL NULL NULL 5 Using where
1 SIMPLE
t1 ALL a NULL NULL NULL 5 Using where
explain select * from t1 force index (a) where a=0 or a=2;
explain select * from t1 force index (a) where a=0 or a=2;
table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
t1 range a a 4 NULL 4 Using where
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;
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;
...
@@ -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
,
t2
force
index
(
c
)
where
t1
.
a
=
t2
.
a
;
explain
select
*
from
t1
where
a
=
0
or
a
=
2
;
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
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
;
drop
table
t1
,
t2
;
mysys/my_handler.c
View file @
bf683af4
...
@@ -40,15 +40,33 @@ static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
...
@@ -40,15 +40,33 @@ static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
return
(
int
)
(
a_length
-
b_length
);
return
(
int
)
(
a_length
-
b_length
);
}
}
#define FCMP(A,B) ((int) (A) - (int) (B))
/*
/*
Compare two keys
Compare two keys
Returns <0, 0, >0 acording to which is bigger
Key_length specifies length of key to use. Number-keys can't be splited
SYNOPSIS
If flag <> SEARCH_FIND compare also position
ha_key_cmp()
keyseg Key segments of key to compare
a First key to compare, in format from _mi_pack_key()
This is normally key specified by user
b Second key to compare. This is always from a row
key_length Length of key to compare. This can be shorter than
a to just compare sub keys
next_flag How keys should be compared
If bit SEARCH_FIND is not set the keys includes the row
position and this should also be compared
NOTES
Number-keys can't be splited
RETURN VALUES
<0 If a < b
0 If a == b
>0 If a > b
*/
*/
#define FCMP(A,B) ((int) (A) - (int) (B))
int
ha_key_cmp
(
register
HA_KEYSEG
*
keyseg
,
register
uchar
*
a
,
int
ha_key_cmp
(
register
HA_KEYSEG
*
keyseg
,
register
uchar
*
a
,
register
uchar
*
b
,
uint
key_length
,
uint
nextflag
,
register
uchar
*
b
,
uint
key_length
,
uint
nextflag
,
uint
*
diff_pos
)
uint
*
diff_pos
)
...
@@ -59,9 +77,10 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -59,9 +77,10 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
uint32
u_1
,
u_2
;
uint32
u_1
,
u_2
;
float
f_1
,
f_2
;
float
f_1
,
f_2
;
double
d_1
,
d_2
;
double
d_1
,
d_2
;
uint
next_key_length
;
*
diff_pos
=
0
;
*
diff_pos
=
0
;
for
(
;
(
int
)
key_length
>
0
;
keyseg
++
)
for
(
;
(
int
)
key_length
>
0
;
key
_length
=
next_key_length
,
key
seg
++
)
{
{
uchar
*
end
;
uchar
*
end
;
uint
piks
=!
(
keyseg
->
flag
&
HA_NO_SORT
);
uint
piks
=!
(
keyseg
->
flag
&
HA_NO_SORT
);
...
@@ -81,10 +100,21 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -81,10 +100,21 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
{
{
if
(
nextflag
==
(
SEARCH_FIND
|
SEARCH_UPDATE
))
if
(
nextflag
==
(
SEARCH_FIND
|
SEARCH_UPDATE
))
nextflag
=
SEARCH_SAME
;
/* Allow duplicate keys */
nextflag
=
SEARCH_SAME
;
/* Allow duplicate keys */
else
if
(
nextflag
&
SEARCH_NULL_ARE_NOT_EQUAL
)
{
/*
This is only used from mi_check() to calculate cardinality.
It can't be used when searching for a key as this would cause
compare of (a,b) and (b,a) to return the same value.
*/
return
-
1
;
}
next_key_length
=
key_length
;
continue
;
/* To next key part */
continue
;
/* To next key part */
}
}
}
}
end
=
a
+
min
(
keyseg
->
length
,
key_length
);
end
=
a
+
min
(
keyseg
->
length
,
key_length
);
next_key_length
=
key_length
-
keyseg
->
length
;
switch
((
enum
ha_base_keytype
)
keyseg
->
type
)
{
switch
((
enum
ha_base_keytype
)
keyseg
->
type
)
{
case
HA_KEYTYPE_TEXT
:
/* Ascii; Key is converted */
case
HA_KEYTYPE_TEXT
:
/* Ascii; Key is converted */
...
@@ -93,12 +123,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -93,12 +123,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
int
a_length
,
b_length
,
pack_length
;
int
a_length
,
b_length
,
pack_length
;
get_key_length
(
a_length
,
a
);
get_key_length
(
a_length
,
a
);
get_key_pack_length
(
b_length
,
pack_length
,
b
);
get_key_pack_length
(
b_length
,
pack_length
,
b
);
key_length
-=
b_length
+
pack_length
;
next_key_length
=
key_length
-
b_length
-
pack_length
;
if
(
piks
&&
if
(
piks
&&
(
flag
=
mi_compare_text
(
keyseg
->
charset
,
a
,
a_length
,
b
,
b_length
,
(
flag
=
mi_compare_text
(
keyseg
->
charset
,
a
,
a_length
,
b
,
b_length
,
(
my_bool
)
((
nextflag
&
SEARCH_PREFIX
)
&&
(
my_bool
)
((
nextflag
&
SEARCH_PREFIX
)
&&
key_length
<=
0
))))
next_
key_length
<=
0
))))
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
+=
a_length
;
a
+=
a_length
;
b
+=
b_length
;
b
+=
b_length
;
...
@@ -107,7 +137,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -107,7 +137,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
else
else
{
{
uint
length
=
(
uint
)
(
end
-
a
),
a_length
=
length
,
b_length
=
length
;
uint
length
=
(
uint
)
(
end
-
a
),
a_length
=
length
,
b_length
=
length
;
key_length
-=
keyseg
->
length
;
if
(
!
(
nextflag
&
SEARCH_PREFIX
))
if
(
!
(
nextflag
&
SEARCH_PREFIX
))
{
{
while
(
a_length
&&
a
[
a_length
-
1
]
==
' '
)
while
(
a_length
&&
a
[
a_length
-
1
]
==
' '
)
...
@@ -116,9 +145,9 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -116,9 +145,9 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
b_length
--
;
b_length
--
;
}
}
if
(
piks
&&
if
(
piks
&&
(
flag
=
mi_compare_text
(
keyseg
->
charset
,
a
,
a_length
,
b
,
b_length
,
(
flag
=
mi_compare_text
(
keyseg
->
charset
,
a
,
a_length
,
b
,
b_length
,
(
my_bool
)
((
nextflag
&
SEARCH_PREFIX
)
&&
(
my_bool
)
((
nextflag
&
SEARCH_PREFIX
)
&&
key_length
<=
0
))))
next_
key_length
<=
0
))))
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
=
end
;
a
=
end
;
b
+=
length
;
b
+=
length
;
...
@@ -130,12 +159,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -130,12 +159,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
int
a_length
,
b_length
,
pack_length
;
int
a_length
,
b_length
,
pack_length
;
get_key_length
(
a_length
,
a
);
get_key_length
(
a_length
,
a
);
get_key_pack_length
(
b_length
,
pack_length
,
b
);
get_key_pack_length
(
b_length
,
pack_length
,
b
);
key_length
-=
b_length
+
pack_length
;
next_key_length
=
key_length
-
b_length
-
pack_length
;
if
(
piks
&&
if
(
piks
&&
(
flag
=
compare_bin
(
a
,
a_length
,
b
,
b_length
,
(
flag
=
compare_bin
(
a
,
a_length
,
b
,
b_length
,
(
my_bool
)
((
nextflag
&
SEARCH_PREFIX
)
&&
(
my_bool
)
((
nextflag
&
SEARCH_PREFIX
)
&&
key_length
<=
0
))))
next_
key_length
<=
0
))))
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
+=
a_length
;
a
+=
a_length
;
b
+=
b_length
;
b
+=
b_length
;
...
@@ -144,11 +173,10 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -144,11 +173,10 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
else
else
{
{
uint
length
=
keyseg
->
length
;
uint
length
=
keyseg
->
length
;
key_length
-=
keyseg
->
length
;
if
(
piks
&&
if
(
piks
&&
(
flag
=
compare_bin
(
a
,
length
,
b
,
length
,
(
flag
=
compare_bin
(
a
,
length
,
b
,
length
,
(
my_bool
)
((
nextflag
&
SEARCH_PREFIX
)
&&
(
my_bool
)
((
nextflag
&
SEARCH_PREFIX
)
&&
key_length
<=
0
))))
next_
key_length
<=
0
))))
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
+=
length
;
a
+=
length
;
b
+=
length
;
b
+=
length
;
...
@@ -159,12 +187,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -159,12 +187,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
int
a_length
,
b_length
,
pack_length
;
int
a_length
,
b_length
,
pack_length
;
get_key_length
(
a_length
,
a
);
get_key_length
(
a_length
,
a
);
get_key_pack_length
(
b_length
,
pack_length
,
b
);
get_key_pack_length
(
b_length
,
pack_length
,
b
);
key_length
-=
b_length
+
pack_length
;
next_key_length
=
key_length
-
b_length
-
pack_length
;
if
(
piks
&&
if
(
piks
&&
(
flag
=
mi_compare_text
(
keyseg
->
charset
,
a
,
a_length
,
b
,
b_length
,
(
flag
=
mi_compare_text
(
keyseg
->
charset
,
a
,
a_length
,
b
,
b_length
,
(
my_bool
)
((
nextflag
&
SEARCH_PREFIX
)
&&
(
my_bool
)
((
nextflag
&
SEARCH_PREFIX
)
&&
key_length
<=
0
))))
next_
key_length
<=
0
))))
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
+=
a_length
;
a
+=
a_length
;
b
+=
b_length
;
b
+=
b_length
;
...
@@ -176,12 +204,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -176,12 +204,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
int
a_length
,
b_length
,
pack_length
;
int
a_length
,
b_length
,
pack_length
;
get_key_length
(
a_length
,
a
);
get_key_length
(
a_length
,
a
);
get_key_pack_length
(
b_length
,
pack_length
,
b
);
get_key_pack_length
(
b_length
,
pack_length
,
b
);
key_length
-=
b_length
+
pack_length
;
next_key_length
=
key_length
-
b_length
-
pack_length
;
if
(
piks
&&
if
(
piks
&&
(
flag
=
compare_bin
(
a
,
a_length
,
b
,
b_length
,
(
flag
=
compare_bin
(
a
,
a_length
,
b
,
b_length
,
(
my_bool
)
((
nextflag
&
SEARCH_PREFIX
)
&&
(
my_bool
)
((
nextflag
&
SEARCH_PREFIX
)
&&
key_length
<=
0
))))
next_
key_length
<=
0
))))
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
+=
a_length
;
a
+=
a_length
;
b
+=
b_length
;
b
+=
b_length
;
...
@@ -196,7 +224,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -196,7 +224,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
=
end
;
a
=
end
;
b
++
;
b
++
;
key_length
-=
keyseg
->
length
;
break
;
break
;
}
}
case
HA_KEYTYPE_SHORT_INT
:
case
HA_KEYTYPE_SHORT_INT
:
...
@@ -206,7 +233,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -206,7 +233,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
=
end
;
a
=
end
;
b
+=
2
;
/* sizeof(short int); */
b
+=
2
;
/* sizeof(short int); */
key_length
-=
keyseg
->
length
;
break
;
break
;
case
HA_KEYTYPE_USHORT_INT
:
case
HA_KEYTYPE_USHORT_INT
:
{
{
...
@@ -217,7 +243,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -217,7 +243,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
=
end
;
a
=
end
;
b
+=
2
;
/* sizeof(short int); */
b
+=
2
;
/* sizeof(short int); */
key_length
-=
keyseg
->
length
;
break
;
break
;
}
}
case
HA_KEYTYPE_LONG_INT
:
case
HA_KEYTYPE_LONG_INT
:
...
@@ -227,7 +252,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -227,7 +252,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
=
end
;
a
=
end
;
b
+=
4
;
/* sizeof(long int); */
b
+=
4
;
/* sizeof(long int); */
key_length
-=
keyseg
->
length
;
break
;
break
;
case
HA_KEYTYPE_ULONG_INT
:
case
HA_KEYTYPE_ULONG_INT
:
u_1
=
mi_sint4korr
(
a
);
u_1
=
mi_sint4korr
(
a
);
...
@@ -236,7 +260,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -236,7 +260,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
=
end
;
a
=
end
;
b
+=
4
;
/* sizeof(long int); */
b
+=
4
;
/* sizeof(long int); */
key_length
-=
keyseg
->
length
;
break
;
break
;
case
HA_KEYTYPE_INT24
:
case
HA_KEYTYPE_INT24
:
l_1
=
mi_sint3korr
(
a
);
l_1
=
mi_sint3korr
(
a
);
...
@@ -245,7 +268,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -245,7 +268,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
=
end
;
a
=
end
;
b
+=
3
;
b
+=
3
;
key_length
-=
keyseg
->
length
;
break
;
break
;
case
HA_KEYTYPE_UINT24
:
case
HA_KEYTYPE_UINT24
:
l_1
=
mi_uint3korr
(
a
);
l_1
=
mi_uint3korr
(
a
);
...
@@ -254,7 +276,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -254,7 +276,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
=
end
;
a
=
end
;
b
+=
3
;
b
+=
3
;
key_length
-=
keyseg
->
length
;
break
;
break
;
case
HA_KEYTYPE_FLOAT
:
case
HA_KEYTYPE_FLOAT
:
mi_float4get
(
f_1
,
a
);
mi_float4get
(
f_1
,
a
);
...
@@ -263,7 +284,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -263,7 +284,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
=
end
;
a
=
end
;
b
+=
4
;
/* sizeof(float); */
b
+=
4
;
/* sizeof(float); */
key_length
-=
keyseg
->
length
;
break
;
break
;
case
HA_KEYTYPE_DOUBLE
:
case
HA_KEYTYPE_DOUBLE
:
mi_float8get
(
d_1
,
a
);
mi_float8get
(
d_1
,
a
);
...
@@ -272,13 +292,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -272,13 +292,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
=
end
;
a
=
end
;
b
+=
8
;
/* sizeof(double); */
b
+=
8
;
/* sizeof(double); */
key_length
-=
keyseg
->
length
;
break
;
break
;
case
HA_KEYTYPE_NUM
:
/* Numeric key */
case
HA_KEYTYPE_NUM
:
/* Numeric key */
{
{
int
swap_flag
=
0
;
int
swap_flag
=
0
;
int
alength
,
blength
;
int
alength
,
blength
;
if
(
keyseg
->
flag
&
HA_REVERSE_SORT
)
if
(
keyseg
->
flag
&
HA_REVERSE_SORT
)
{
{
swap
(
uchar
*
,
a
,
b
);
swap
(
uchar
*
,
a
,
b
);
...
@@ -289,7 +308,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -289,7 +308,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
{
{
alength
=
*
a
++
;
blength
=
*
b
++
;
alength
=
*
a
++
;
blength
=
*
b
++
;
end
=
a
+
alength
;
end
=
a
+
alength
;
key_length
-=
blength
+
1
;
next_key_length
=
key_length
-
blength
-
1
;
}
}
else
else
{
{
...
@@ -298,9 +317,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -298,9 +317,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
/* remove pre space from keys */
/* remove pre space from keys */
for
(
;
alength
&&
*
a
==
' '
;
a
++
,
alength
--
)
;
for
(
;
alength
&&
*
a
==
' '
;
a
++
,
alength
--
)
;
for
(
;
blength
&&
*
b
==
' '
;
b
++
,
blength
--
)
;
for
(
;
blength
&&
*
b
==
' '
;
b
++
,
blength
--
)
;
key_length
-=
keyseg
->
length
;
}
}
if
(
piks
)
if
(
piks
)
{
{
if
(
*
a
==
'-'
)
if
(
*
a
==
'-'
)
...
@@ -350,7 +367,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -350,7 +367,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
=
end
;
a
=
end
;
b
+=
8
;
b
+=
8
;
key_length
-=
keyseg
->
length
;
break
;
break
;
}
}
case
HA_KEYTYPE_ULONGLONG
:
case
HA_KEYTYPE_ULONGLONG
:
...
@@ -362,7 +378,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
...
@@ -362,7 +378,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
return
((
keyseg
->
flag
&
HA_REVERSE_SORT
)
?
-
flag
:
flag
);
a
=
end
;
a
=
end
;
b
+=
8
;
b
+=
8
;
key_length
-=
keyseg
->
length
;
break
;
break
;
}
}
#endif
#endif
...
...
sql/sql_lex.cc
View file @
bf683af4
...
@@ -1171,13 +1171,14 @@ List<String>* st_select_lex_node::get_use_index() { return 0; }
...
@@ -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
;
}
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
,
TABLE_LIST
*
st_select_lex_node
::
add_table_to_list
(
THD
*
thd
,
Table_ident
*
table
,
LEX_STRING
*
alias
,
LEX_STRING
*
alias
,
bool
updating
,
ulong
table_join_options
,
thr_lock_type
flags
,
thr_lock_type
flags
,
List
<
String
>
*
use_index
,
List
<
String
>
*
use_index
,
List
<
String
>
*
ignore_index
)
List
<
String
>
*
ignore_index
)
{
{
return
0
;
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
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()
...
@@ -1334,6 +1335,11 @@ List<String>* st_select_lex::get_ignore_index()
return
ignore_index_ptr
;
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 &
There are st_select_lex::add_table_to_list &
st_select_lex::set_lock_for_tables in sql_parse.cc
st_select_lex::set_lock_for_tables in sql_parse.cc
...
...
sql/sql_lex.h
View file @
bf683af4
...
@@ -243,7 +243,7 @@ class st_select_lex_node {
...
@@ -243,7 +243,7 @@ class st_select_lex_node {
virtual
List
<
Item
>*
get_item_list
();
virtual
List
<
Item
>*
get_item_list
();
virtual
List
<
String
>*
get_use_index
();
virtual
List
<
String
>*
get_use_index
();
virtual
List
<
String
>*
get_ignore_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
,
virtual
TABLE_LIST
*
add_table_to_list
(
THD
*
thd
,
Table_ident
*
table
,
LEX_STRING
*
alias
,
LEX_STRING
*
alias
,
ulong
table_options
,
ulong
table_options
,
...
@@ -375,7 +375,7 @@ class st_select_lex: public st_select_lex_node
...
@@ -375,7 +375,7 @@ class st_select_lex: public st_select_lex_node
List
<
Item
>*
get_item_list
();
List
<
Item
>*
get_item_list
();
List
<
String
>*
get_use_index
();
List
<
String
>*
get_use_index
();
List
<
String
>*
get_ignore_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
,
TABLE_LIST
*
add_table_to_list
(
THD
*
thd
,
Table_ident
*
table
,
LEX_STRING
*
alias
,
LEX_STRING
*
alias
,
ulong
table_options
,
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)
...
@@ -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_LIST
*
st_select_lex
::
add_table_to_list
(
THD
*
thd
,
Table_ident
*
table
,
Table_ident
*
table
,
LEX_STRING
*
alias
,
LEX_STRING
*
alias
,
bool
updating
,
ulong
table_options
,
thr_lock_type
flags
,
thr_lock_type
lock_type
,
List
<
String
>
*
use_index
,
List
<
String
>
*
use_index
,
List
<
String
>
*
ignore_index
)
List
<
String
>
*
ignore_index
)
{
{
...
@@ -3659,8 +3678,9 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
...
@@ -3659,8 +3678,9 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
}
}
ptr
->
real_name
=
table
->
table
.
str
;
ptr
->
real_name
=
table
->
table
.
str
;
ptr
->
real_name_length
=
table
->
table
.
length
;
ptr
->
real_name_length
=
table
->
table
.
length
;
ptr
->
lock_type
=
flags
;
ptr
->
lock_type
=
lock_type
;
ptr
->
updating
=
updating
;
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
;
ptr
->
derived
=
(
SELECT_LEX_UNIT
*
)
table
->
sel
;
if
(
use_index
)
if
(
use_index
)
ptr
->
use_index
=
(
List
<
String
>
*
)
thd
->
memdup
((
gptr
)
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:
...
@@ -1359,7 +1359,7 @@ opt_unique_or_fulltext:
key_alg:
key_alg:
/* empty */ { $$= HA_KEY_ALG_UNDEF; }
/* empty */ { $$= HA_KEY_ALG_UNDEF; }
| USING opt_btree_or_rtree { $$= $2; };
| USING opt_btree_or_rtree { $$= $2; };
| TYPE opt_btree_or_rtree { $$= $2; };
| TYPE
_SYM
opt_btree_or_rtree { $$= $2; };
opt_btree_or_rtree:
opt_btree_or_rtree:
BTREE_SYM { $$= HA_KEY_ALG_BTREE; }
BTREE_SYM { $$= HA_KEY_ALG_BTREE; }
...
@@ -2516,14 +2516,14 @@ join_table:
...
@@ -2516,14 +2516,14 @@ join_table:
{
{
SELECT_LEX *sel= Select->select_lex();
SELECT_LEX *sel= Select->select_lex();
sel->use_index_ptr=sel->ignore_index_ptr=0;
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
table_ident opt_table_alias opt_key_definition
{
{
LEX *lex= Lex;
LEX *lex= Lex;
SELECT_LEX_NODE *sel= lex->current_select;
SELECT_LEX_NODE *sel= lex->current_select;
if (!($$= sel->add_table_to_list(lex->thd, $2, $3,
if (!($$= sel->add_table_to_list(lex->thd, $2, $3,
lex->
table_join_options(),
sel->get_
table_join_options(),
lex->lock_option,
lex->lock_option,
sel->get_use_index(),
sel->get_use_index(),
sel->get_ignore_index())))
sel->get_ignore_index())))
...
@@ -2569,6 +2569,13 @@ opt_key_definition:
...
@@ -2569,6 +2569,13 @@ opt_key_definition:
sel->use_index= *$2;
sel->use_index= *$2;
sel->use_index_ptr= &sel->use_index;
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
| IGNORE_SYM key_usage_list
{
{
SELECT_LEX *sel= Select->select_lex();
SELECT_LEX *sel= Select->select_lex();
...
@@ -2578,8 +2585,14 @@ opt_key_definition:
...
@@ -2578,8 +2585,14 @@ opt_key_definition:
key_usage_list:
key_usage_list:
key_or_index { Select->select_lex()->interval_list.empty(); }
key_or_index { Select->select_lex()->interval_list.empty(); }
'(' key_usage_list2 ')'
'(' key_list_or_empty ')'
{ $$= &Select->select_lex()->interval_list; };
{ $$= &Select->select_lex()->interval_list; }
;
key_list_or_empty:
/* empty */ {}
| key_usage_list2 {}
;
key_usage_list2:
key_usage_list2:
key_usage_list2 ',' ident
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