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
5e4a381c
Commit
5e4a381c
authored
Oct 14, 2011
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge.
parents
60e1ef85
54e296d4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
0 deletions
+91
-0
mysql-test/r/derived_view.result
mysql-test/r/derived_view.result
+38
-0
mysql-test/t/derived_view.test
mysql-test/t/derived_view.test
+33
-0
sql/item.h
sql/item.h
+5
-0
sql/sql_lex.cc
sql/sql_lex.cc
+15
-0
No files found.
mysql-test/r/derived_view.result
View file @
5e4a381c
...
@@ -1424,4 +1424,42 @@ a a c a a c b a d
...
@@ -1424,4 +1424,42 @@ a a c a a c b a d
6 23 -1 NULL NULL NULL NULL NULL 5
6 23 -1 NULL NULL NULL NULL NULL 5
DROP VIEW v2,v3;
DROP VIEW v2,v3;
DROP TABLE t1,t2,t3,t4,t5;
DROP TABLE t1,t2,t3,t4,t5;
#
# LP bug #872735: derived used in a NOT IN subquery
#
CREATE TABLE t1 (b int NOT NULL);
INSERT INTO t1 VALUES (9), (7);
CREATE TABLE t2 (a int NOT NULL) ;
INSERT INTO t2 VALUES (1), (2);
CREATE TABLE t3 (
a int NOT NULL , c int NOT NULL, d varchar(1) NOT NULL,
KEY (c,a) , PRIMARY KEY (a)
);
INSERT INTO t3 VALUES
(14,4,'a'), (15,7,'b'), (16,4,'c'), (17,1,'d'), (18,9,'e'),
(19,4,'f'), (20,8,'g');
SET SESSION optimizer_switch='derived_merge=on,subquery_cache=off';
# The following two EXPLAINs must return the same execution plan
EXPLAIN
SELECT * FROM t1 , t2
WHERE (t2.a ,t1.b) NOT IN (SELECT DISTINCT c,a FROM t3 t);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
2 DEPENDENT SUBQUERY t ref PRIMARY,c c 4 func 2 Using where; Using index
EXPLAIN
SELECT * FROM t1 , t2
WHERE (t2.a ,t1.b) NOT IN (SELECT DISTINCT c,a FROM (SELECT * FROM t3) t);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
2 DEPENDENT SUBQUERY t3 ref PRIMARY,c c 4 func 2 Using where; Using index
SELECT * FROM t1 , t2
WHERE (t2.a ,t1.b) NOT IN (SELECT DISTINCT c,a FROM (SELECT * FROM t3) t);
b a
9 1
7 1
9 2
7 2
DROP TABLE t1,t2,t3;
set optimizer_switch=@exit_optimizer_switch;
set optimizer_switch=@exit_optimizer_switch;
mysql-test/t/derived_view.test
View file @
5e4a381c
...
@@ -877,5 +877,38 @@ SELECT STRAIGHT_JOIN *
...
@@ -877,5 +877,38 @@ SELECT STRAIGHT_JOIN *
DROP
VIEW
v2
,
v3
;
DROP
VIEW
v2
,
v3
;
DROP
TABLE
t1
,
t2
,
t3
,
t4
,
t5
;
DROP
TABLE
t1
,
t2
,
t3
,
t4
,
t5
;
--
echo
#
--
echo
# LP bug #872735: derived used in a NOT IN subquery
--
echo
#
CREATE
TABLE
t1
(
b
int
NOT
NULL
);
INSERT
INTO
t1
VALUES
(
9
),
(
7
);
CREATE
TABLE
t2
(
a
int
NOT
NULL
)
;
INSERT
INTO
t2
VALUES
(
1
),
(
2
);
CREATE
TABLE
t3
(
a
int
NOT
NULL
,
c
int
NOT
NULL
,
d
varchar
(
1
)
NOT
NULL
,
KEY
(
c
,
a
)
,
PRIMARY
KEY
(
a
)
);
INSERT
INTO
t3
VALUES
(
14
,
4
,
'a'
),
(
15
,
7
,
'b'
),
(
16
,
4
,
'c'
),
(
17
,
1
,
'd'
),
(
18
,
9
,
'e'
),
(
19
,
4
,
'f'
),
(
20
,
8
,
'g'
);
SET
SESSION
optimizer_switch
=
'derived_merge=on,subquery_cache=off'
;
--
echo
# The following two EXPLAINs must return the same execution plan
EXPLAIN
SELECT
*
FROM
t1
,
t2
WHERE
(
t2
.
a
,
t1
.
b
)
NOT
IN
(
SELECT
DISTINCT
c
,
a
FROM
t3
t
);
EXPLAIN
SELECT
*
FROM
t1
,
t2
WHERE
(
t2
.
a
,
t1
.
b
)
NOT
IN
(
SELECT
DISTINCT
c
,
a
FROM
(
SELECT
*
FROM
t3
)
t
);
SELECT
*
FROM
t1
,
t2
WHERE
(
t2
.
a
,
t1
.
b
)
NOT
IN
(
SELECT
DISTINCT
c
,
a
FROM
(
SELECT
*
FROM
t3
)
t
);
DROP
TABLE
t1
,
t2
,
t3
;
# The following command must be the last one the file
# The following command must be the last one the file
set
optimizer_switch
=@
exit_optimizer_switch
;
set
optimizer_switch
=@
exit_optimizer_switch
;
sql/item.h
View file @
5e4a381c
...
@@ -1816,6 +1816,11 @@ class Item_field :public Item_ident
...
@@ -1816,6 +1816,11 @@ class Item_field :public Item_ident
bool
get_date_result
(
MYSQL_TIME
*
ltime
,
uint
fuzzydate
);
bool
get_date_result
(
MYSQL_TIME
*
ltime
,
uint
fuzzydate
);
bool
is_null
()
{
return
field
->
is_null
();
}
bool
is_null
()
{
return
field
->
is_null
();
}
void
update_null_value
();
void
update_null_value
();
void
update_used_tables
()
{
if
(
field
&&
field
->
table
)
field
->
table
->
covering_keys
.
intersect
(
field
->
part_of_key
);
}
Item
*
get_tmp_table_item
(
THD
*
thd
);
Item
*
get_tmp_table_item
(
THD
*
thd
);
bool
collect_item_field_processor
(
uchar
*
arg
);
bool
collect_item_field_processor
(
uchar
*
arg
);
bool
add_field_to_set_processor
(
uchar
*
arg
);
bool
add_field_to_set_processor
(
uchar
*
arg
);
...
...
sql/sql_lex.cc
View file @
5e4a381c
...
@@ -3411,6 +3411,21 @@ void SELECT_LEX::update_used_tables()
...
@@ -3411,6 +3411,21 @@ void SELECT_LEX::update_used_tables()
while
((
tl
=
ti
++
))
while
((
tl
=
ti
++
))
{
{
TABLE_LIST
*
embedding
;
TABLE_LIST
*
embedding
;
if
(
tl
->
table
)
{
embedding
=
tl
->
embedding
;
for
(
embedding
=
tl
->
embedding
;
embedding
;
embedding
=
embedding
->
embedding
)
{
if
(
embedding
->
is_view_or_derived
())
{
DBUG_ASSERT
(
embedding
->
is_merged_derived
());
TABLE
*
tab
=
tl
->
table
;
tab
->
covering_keys
=
tab
->
s
->
keys_for_keyread
;
tab
->
covering_keys
.
intersect
(
tab
->
keys_in_use_for_query
);
break
;
}
}
}
embedding
=
tl
;
embedding
=
tl
;
do
do
{
{
...
...
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