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
5d1b299f
Commit
5d1b299f
authored
Sep 14, 2003
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/dlenev/src/mysql-4.1-868
parents
b15eba88
e3b11b1d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
52 deletions
+54
-52
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+8
-8
mysql-test/r/subselect2.result
mysql-test/r/subselect2.result
+5
-5
sql/item_subselect.cc
sql/item_subselect.cc
+9
-9
sql/item_subselect.h
sql/item_subselect.h
+11
-11
sql/sql_select.cc
sql/sql_select.cc
+20
-18
sql/sql_select.h
sql/sql_select.h
+1
-1
No files found.
mysql-test/r/subselect.result
View file @
5d1b299f
...
@@ -840,7 +840,7 @@ a t1.a in (select t2.a from t2)
...
@@ -840,7 +840,7 @@ a t1.a in (select t2.a from t2)
explain SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
explain SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 Using index
1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 Using index
2 DEPENDENT SUBQUERY t2 index_
in
a a 5 func 2 Using index
2 DEPENDENT SUBQUERY t2 index_
subquery
a a 5 func 2 Using index
CREATE TABLE t3 (a int(11) default '0');
CREATE TABLE t3 (a int(11) default '0');
INSERT INTO t3 VALUES (1),(2),(3);
INSERT INTO t3 VALUES (1),(2),(3);
SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
...
@@ -1253,7 +1253,7 @@ a
...
@@ -1253,7 +1253,7 @@ a
explain select * from t2 where t2.a in (select a from t1);
explain select * from t2 where t2.a in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 Using where; Using index
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1
simple_in
PRIMARY PRIMARY 4 func 1 Using index
2 DEPENDENT SUBQUERY t1
unique_subquery
PRIMARY PRIMARY 4 func 1 Using index
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
a
a
2
2
...
@@ -1261,7 +1261,7 @@ a
...
@@ -1261,7 +1261,7 @@ a
explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 Using where; Using index
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1
simple_in
PRIMARY PRIMARY 4 func 1 Using index; Using where
2 DEPENDENT SUBQUERY t1
unique_subquery
PRIMARY PRIMARY 4 func 1 Using index; Using where
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
a
a
2
2
...
@@ -1286,7 +1286,7 @@ a
...
@@ -1286,7 +1286,7 @@ a
explain select * from t2 where t2.a in (select a from t1);
explain select * from t2 where t2.a in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1 index_
in
a a 5 func 1001 Using index
2 DEPENDENT SUBQUERY t1 index_
subquery
a a 5 func 1001 Using index
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
a
a
2
2
...
@@ -1294,7 +1294,7 @@ a
...
@@ -1294,7 +1294,7 @@ a
explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1 index_
in
a a 5 func 1001 Using index; Using where
2 DEPENDENT SUBQUERY t1 index_
subquery
a a 5 func 1001 Using index; Using where
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
a
a
2
2
...
@@ -1317,7 +1317,7 @@ a
...
@@ -1317,7 +1317,7 @@ a
explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1 index_
in
a a 5 func 1001 Using index; Using where
2 DEPENDENT SUBQUERY t1 index_
subquery
a a 5 func 1001 Using index; Using where
drop table t1, t2, t3;
drop table t1, t2, t3;
create table t1 (a int, b int);
create table t1 (a int, b int);
create table t2 (a int, b int);
create table t2 (a int, b int);
...
@@ -1405,9 +1405,9 @@ a3 1
...
@@ -1405,9 +1405,9 @@ a3 1
explain select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
explain select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
2 DEPENDENT SUBQUERY t2 index_
in
s1 s1 6 func 2 Using index
2 DEPENDENT SUBQUERY t2 index_
subquery
s1 s1 6 func 2 Using index
explain select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
explain select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
2 DEPENDENT SUBQUERY t2 index_
in
s1 s1 6 func 1 Using index; Using where
2 DEPENDENT SUBQUERY t2 index_
subquery
s1 s1 6 func 1 Using index; Using where
drop table t1,t2;
drop table t1,t2;
mysql-test/r/subselect2.result
View file @
5d1b299f
...
@@ -123,9 +123,9 @@ id select_type table type possible_keys key key_len ref rows Extra
...
@@ -123,9 +123,9 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 0 const row not found
1 PRIMARY t1 system PRIMARY NULL NULL NULL 0 const row not found
1 PRIMARY t2 ALL DDOCTYPEID_IDX NULL NULL NULL 9 Using where
1 PRIMARY t2 ALL DDOCTYPEID_IDX NULL NULL NULL 9 Using where
1 PRIMARY t4 eq_ref PRIMARY PRIMARY 32 test.t2.DOCTYPEID 1
1 PRIMARY t4 eq_ref PRIMARY PRIMARY 32 test.t2.DOCTYPEID 1
2 DEPENDENT SUBQUERY t3
simple_in
PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
2 DEPENDENT SUBQUERY t3
unique_subquery
PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
3 DEPENDENT SUBQUERY t3
simple_in
PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
3 DEPENDENT SUBQUERY t3
unique_subquery
PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
4 DEPENDENT SUBQUERY t3
simple_in
PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
4 DEPENDENT SUBQUERY t3
unique_subquery
PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
5 DEPENDENT SUBQUERY t3
simple_in
PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
5 DEPENDENT SUBQUERY t3
unique_subquery
PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
6 DEPENDENT SUBQUERY t3
simple_in
PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 32 func 1 Using index; Using where
6 DEPENDENT SUBQUERY t3
unique_subquery
PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 32 func 1 Using index; Using where
drop table t1, t2, t3, t4;
drop table t1, t2, t3, t4;
sql/item_subselect.cc
View file @
5d1b299f
...
@@ -773,7 +773,7 @@ int subselect_union_engine::prepare()
...
@@ -773,7 +773,7 @@ int subselect_union_engine::prepare()
return
unit
->
prepare
(
thd
,
result
,
0
);
return
unit
->
prepare
(
thd
,
result
,
0
);
}
}
int
subselect_
simplein
_engine
::
prepare
()
int
subselect_
uniquesubquery
_engine
::
prepare
()
{
{
//this never should be called
//this never should be called
DBUG_ASSERT
(
0
);
DBUG_ASSERT
(
0
);
...
@@ -860,7 +860,7 @@ void subselect_union_engine::fix_length_and_dec(Item_cache **row)
...
@@ -860,7 +860,7 @@ void subselect_union_engine::fix_length_and_dec(Item_cache **row)
}
}
}
}
void
subselect_
simplein
_engine
::
fix_length_and_dec
(
Item_cache
**
row
)
void
subselect_
uniquesubquery
_engine
::
fix_length_and_dec
(
Item_cache
**
row
)
{
{
//this never should be called
//this never should be called
DBUG_ASSERT
(
0
);
DBUG_ASSERT
(
0
);
...
@@ -919,9 +919,9 @@ int subselect_union_engine::exec()
...
@@ -919,9 +919,9 @@ int subselect_union_engine::exec()
return
res
;
return
res
;
}
}
int
subselect_
simplein
_engine
::
exec
()
int
subselect_
uniquesubquery
_engine
::
exec
()
{
{
DBUG_ENTER
(
"subselect_
simplein
_engine::exec"
);
DBUG_ENTER
(
"subselect_
uniquesubquery
_engine::exec"
);
int
error
;
int
error
;
TABLE
*
table
=
tab
->
table
;
TABLE
*
table
=
tab
->
table
;
if
((
tab
->
ref
.
key_err
=
(
*
tab
->
ref
.
key_copy
)
->
copy
()))
if
((
tab
->
ref
.
key_err
=
(
*
tab
->
ref
.
key_copy
)
->
copy
()))
...
@@ -949,9 +949,9 @@ int subselect_simplein_engine::exec()
...
@@ -949,9 +949,9 @@ int subselect_simplein_engine::exec()
DBUG_RETURN
(
end_exec
(
table
)
||
(
error
!=
0
));
DBUG_RETURN
(
end_exec
(
table
)
||
(
error
!=
0
));
}
}
int
subselect_
simplein
_engine
::
end_exec
(
TABLE
*
table
)
int
subselect_
uniquesubquery
_engine
::
end_exec
(
TABLE
*
table
)
{
{
DBUG_ENTER
(
"subselect_
simplein
_engine::end_exec"
);
DBUG_ENTER
(
"subselect_
uniquesubquery
_engine::end_exec"
);
int
error
=
0
,
tmp
;
int
error
=
0
,
tmp
;
if
((
tmp
=
table
->
file
->
extra
(
HA_EXTRA_NO_CACHE
)))
if
((
tmp
=
table
->
file
->
extra
(
HA_EXTRA_NO_CACHE
)))
{
{
...
@@ -968,9 +968,9 @@ int subselect_simplein_engine::end_exec(TABLE *table)
...
@@ -968,9 +968,9 @@ int subselect_simplein_engine::end_exec(TABLE *table)
DBUG_RETURN
(
error
!=
0
);
DBUG_RETURN
(
error
!=
0
);
}
}
int
subselect_index
in
_engine
::
exec
()
int
subselect_index
subquery
_engine
::
exec
()
{
{
DBUG_ENTER
(
"subselect_index
in
_engine::exec"
);
DBUG_ENTER
(
"subselect_index
subselect
_engine::exec"
);
int
error
;
int
error
;
bool
null_finding
=
0
;
bool
null_finding
=
0
;
TABLE
*
table
=
tab
->
table
;
TABLE
*
table
=
tab
->
table
;
...
@@ -1075,7 +1075,7 @@ void subselect_union_engine::exclude()
...
@@ -1075,7 +1075,7 @@ void subselect_union_engine::exclude()
unit
->
exclude_level
();
unit
->
exclude_level
();
}
}
void
subselect_
simplein
_engine
::
exclude
()
void
subselect_
uniquesubquery
_engine
::
exclude
()
{
{
//this never should be called
//this never should be called
DBUG_ASSERT
(
0
);
DBUG_ASSERT
(
0
);
...
...
sql/item_subselect.h
View file @
5d1b299f
...
@@ -183,8 +183,8 @@ public:
...
@@ -183,8 +183,8 @@ public:
void
fix_length_and_dec
();
void
fix_length_and_dec
();
friend
class
select_exists_subselect
;
friend
class
select_exists_subselect
;
friend
class
subselect_
simplein
_engine
;
friend
class
subselect_
uniquesubquery
_engine
;
friend
class
subselect_index
in
_engine
;
friend
class
subselect_index
subquery
_engine
;
};
};
/* IN subselect */
/* IN subselect */
...
@@ -227,7 +227,7 @@ public:
...
@@ -227,7 +227,7 @@ public:
friend
class
Item_ref_null_helper
;
friend
class
Item_ref_null_helper
;
friend
class
Item_is_not_null_test
;
friend
class
Item_is_not_null_test
;
friend
class
subselect_index
in
_engine
;
friend
class
subselect_index
subquery
_engine
;
};
};
/* ALL/ANY/SOME subselect */
/* ALL/ANY/SOME subselect */
...
@@ -313,14 +313,14 @@ public:
...
@@ -313,14 +313,14 @@ public:
};
};
struct
st_join_table
;
struct
st_join_table
;
class
subselect_
simplein
_engine
:
public
subselect_engine
class
subselect_
uniquesubquery
_engine
:
public
subselect_engine
{
{
protected:
protected:
st_join_table
*
tab
;
st_join_table
*
tab
;
Item
*
cond
;
Item
*
cond
;
public:
public:
subselect_
simplein
_engine
(
THD
*
thd
,
st_join_table
*
tab_arg
,
subselect_
uniquesubquery
_engine
(
THD
*
thd
,
st_join_table
*
tab_arg
,
Item_subselect
*
subs
,
Item
*
where
)
Item_subselect
*
subs
,
Item
*
where
)
:
subselect_engine
(
thd
,
subs
,
0
),
tab
(
tab_arg
),
cond
(
where
)
:
subselect_engine
(
thd
,
subs
,
0
),
tab
(
tab_arg
),
cond
(
where
)
{}
{}
...
@@ -335,14 +335,14 @@ public:
...
@@ -335,14 +335,14 @@ public:
static
int
end_exec
(
TABLE
*
table
);
static
int
end_exec
(
TABLE
*
table
);
};
};
class
subselect_index
in_engine
:
public
subselect_simplein
_engine
class
subselect_index
subquery_engine
:
public
subselect_uniquesubquery
_engine
{
{
bool
check_null
;
bool
check_null
;
public:
public:
subselect_index
in
_engine
(
THD
*
thd
,
st_join_table
*
tab_arg
,
subselect_index
subquery
_engine
(
THD
*
thd
,
st_join_table
*
tab_arg
,
Item_subselect
*
subs
,
Item
*
where
,
Item_subselect
*
subs
,
Item
*
where
,
bool
chk_null
)
bool
chk_null
)
:
subselect_
simplein
_engine
(
thd
,
tab_arg
,
subs
,
where
),
:
subselect_
uniquesubquery
_engine
(
thd
,
tab_arg
,
subs
,
where
),
check_null
(
chk_null
)
check_null
(
chk_null
)
{}
{}
int
exec
();
int
exec
();
...
...
sql/sql_select.cc
View file @
5d1b299f
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
const
char
*
join_type_str
[]
=
{
"UNKNOWN"
,
"system"
,
"const"
,
"eq_ref"
,
"ref"
,
const
char
*
join_type_str
[]
=
{
"UNKNOWN"
,
"system"
,
"const"
,
"eq_ref"
,
"ref"
,
"MAYBE_REF"
,
"ALL"
,
"range"
,
"index"
,
"fulltext"
,
"MAYBE_REF"
,
"ALL"
,
"range"
,
"index"
,
"fulltext"
,
"ref_or_null"
,
"
simple_in"
,
"index_in
"
"ref_or_null"
,
"
unique_subquery"
,
"index_subquery
"
};
};
static
void
optimize_keyuse
(
JOIN
*
join
,
DYNAMIC_ARRAY
*
keyuse_array
);
static
void
optimize_keyuse
(
JOIN
*
join
,
DYNAMIC_ARRAY
*
keyuse_array
);
...
@@ -773,10 +773,11 @@ JOIN::optimize()
...
@@ -773,10 +773,11 @@ JOIN::optimize()
{
{
if
(
test_in_subselect
(
&
where
))
if
(
test_in_subselect
(
&
where
))
{
{
join_tab
[
0
].
type
=
JT_
SIMPLE_IN
;
join_tab
[
0
].
type
=
JT_
UNIQUE_SUBQUERY
;
error
=
0
;
error
=
0
;
DBUG_RETURN
(
unit
->
item
->
DBUG_RETURN
(
unit
->
item
->
change_engine
(
new
subselect_simplein_engine
(
thd
,
change_engine
(
new
subselect_uniquesubquery_engine
(
thd
,
join_tab
,
join_tab
,
unit
->
item
,
unit
->
item
,
where
)));
where
)));
...
@@ -787,10 +788,11 @@ JOIN::optimize()
...
@@ -787,10 +788,11 @@ JOIN::optimize()
{
{
if
(
test_in_subselect
(
&
where
))
if
(
test_in_subselect
(
&
where
))
{
{
join_tab
[
0
].
type
=
JT_INDEX_
IN
;
join_tab
[
0
].
type
=
JT_INDEX_
SUBQUERY
;
error
=
0
;
error
=
0
;
DBUG_RETURN
(
unit
->
item
->
DBUG_RETURN
(
unit
->
item
->
change_engine
(
new
subselect_indexin_engine
(
thd
,
change_engine
(
new
subselect_indexsubquery_engine
(
thd
,
join_tab
,
join_tab
,
unit
->
item
,
unit
->
item
,
where
,
where
,
...
@@ -803,7 +805,7 @@ JOIN::optimize()
...
@@ -803,7 +805,7 @@ JOIN::optimize()
((
Item_func
*
)
having
)
->
functype
()
==
((
Item_func
*
)
having
)
->
functype
()
==
Item_func
::
ISNOTNULLTEST_FUNC
)
Item_func
::
ISNOTNULLTEST_FUNC
)
{
{
join_tab
[
0
].
type
=
JT_INDEX_
IN
;
join_tab
[
0
].
type
=
JT_INDEX_
SUBQUERY
;
error
=
0
;
error
=
0
;
if
((
conds
=
remove_additional_cond
(
conds
)))
if
((
conds
=
remove_additional_cond
(
conds
)))
...
@@ -812,7 +814,7 @@ JOIN::optimize()
...
@@ -812,7 +814,7 @@ JOIN::optimize()
join_tab
->
info
=
"Using index"
;
join_tab
->
info
=
"Using index"
;
DBUG_RETURN
(
unit
->
item
->
DBUG_RETURN
(
unit
->
item
->
change_engine
(
new
subselect_index
in
_engine
(
thd
,
change_engine
(
new
subselect_index
subquery
_engine
(
thd
,
join_tab
,
join_tab
,
unit
->
item
,
unit
->
item
,
conds
,
conds
,
...
...
sql/sql_select.h
View file @
5d1b299f
...
@@ -76,7 +76,7 @@ typedef struct st_join_cache {
...
@@ -76,7 +76,7 @@ typedef struct st_join_cache {
enum
join_type
{
JT_UNKNOWN
,
JT_SYSTEM
,
JT_CONST
,
JT_EQ_REF
,
JT_REF
,
JT_MAYBE_REF
,
enum
join_type
{
JT_UNKNOWN
,
JT_SYSTEM
,
JT_CONST
,
JT_EQ_REF
,
JT_REF
,
JT_MAYBE_REF
,
JT_ALL
,
JT_RANGE
,
JT_NEXT
,
JT_FT
,
JT_REF_OR_NULL
,
JT_ALL
,
JT_RANGE
,
JT_NEXT
,
JT_FT
,
JT_REF_OR_NULL
,
JT_
SIMPLE_IN
,
JT_INDEX_IN
};
JT_
UNIQUE_SUBQUERY
,
JT_INDEX_SUBQUERY
};
class
JOIN
;
class
JOIN
;
...
...
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