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
aab6e4f2
Commit
aab6e4f2
authored
Oct 19, 2011
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge.
parents
8ad5832c
9634dcae
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
0 deletions
+65
-0
mysql-test/r/derived_view.result
mysql-test/r/derived_view.result
+30
-0
mysql-test/t/derived_view.test
mysql-test/t/derived_view.test
+26
-0
sql/item.cc
sql/item.cc
+6
-0
sql/item.h
sql/item.h
+2
-0
sql/item_subselect.cc
sql/item_subselect.cc
+1
-0
No files found.
mysql-test/r/derived_view.result
View file @
aab6e4f2
...
...
@@ -1504,4 +1504,34 @@ a b c
20 r r
DROP VIEW v1;
DROP TABLE t1,t2,t3;
#
# LP bug #877316: query over a view with correlated subquery in WHERE
#
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)) ;
INSERT INTO t1 VALUES (18,2), (19,9);
CREATE TABLE t2 (a int, b int) ;
INSERT INTO t2 VALUES (10,8), (5,10);
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT t1.a FROM t1
WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < t1.b);
a
19
EXPLAIN
SELECT t1.a FROM t1
WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < t1.b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
SELECT v1.a FROM v1
WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < v1.b);
a
19
EXPLAIN
SELECT v1.a FROM v1
WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < v1.b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
DROP VIEW v1;
DROP TABLE t1,t2;
set optimizer_switch=@exit_optimizer_switch;
mysql-test/t/derived_view.test
View file @
aab6e4f2
...
...
@@ -946,6 +946,32 @@ SELECT * FROM t3
DROP
VIEW
v1
;
DROP
TABLE
t1
,
t2
,
t3
;
--
echo
#
--
echo
# LP bug #877316: query over a view with correlated subquery in WHERE
--
echo
#
CREATE
TABLE
t1
(
a
int
,
b
int
,
PRIMARY
KEY
(
a
))
;
INSERT
INTO
t1
VALUES
(
18
,
2
),
(
19
,
9
);
CREATE
TABLE
t2
(
a
int
,
b
int
)
;
INSERT
INTO
t2
VALUES
(
10
,
8
),
(
5
,
10
);
CREATE
VIEW
v1
AS
SELECT
*
FROM
t1
;
SELECT
t1
.
a
FROM
t1
WHERE
EXISTS
(
SELECT
t2
.
a
FROM
t2
WHERE
t2
.
b
<
t1
.
b
);
EXPLAIN
SELECT
t1
.
a
FROM
t1
WHERE
EXISTS
(
SELECT
t2
.
a
FROM
t2
WHERE
t2
.
b
<
t1
.
b
);
SELECT
v1
.
a
FROM
v1
WHERE
EXISTS
(
SELECT
t2
.
a
FROM
t2
WHERE
t2
.
b
<
v1
.
b
);
EXPLAIN
SELECT
v1
.
a
FROM
v1
WHERE
EXISTS
(
SELECT
t2
.
a
FROM
t2
WHERE
t2
.
b
<
v1
.
b
);
DROP
VIEW
v1
;
DROP
TABLE
t1
,
t2
;
# The following command must be the last one the file
set
optimizer_switch
=@
exit_optimizer_switch
;
sql/item.cc
View file @
aab6e4f2
...
...
@@ -2172,6 +2172,12 @@ bool Item_field::enumerate_field_refs_processor(uchar *arg)
return
FALSE
;
}
bool
Item_field
::
covering_keys_processor
(
uchar
*
arg
)
{
if
(
field
&&
field
->
table
)
field
->
table
->
covering_keys
.
intersect
(
field
->
part_of_key
);
return
FALSE
;
}
const
char
*
Item_ident
::
full_name
()
const
{
...
...
sql/item.h
View file @
aab6e4f2
...
...
@@ -1018,6 +1018,7 @@ class Item {
virtual
bool
mark_as_eliminated_processor
(
uchar
*
arg
)
{
return
0
;
}
virtual
bool
eliminate_subselect_processor
(
uchar
*
arg
)
{
return
0
;
}
virtual
bool
set_fake_select_as_master_processor
(
uchar
*
arg
)
{
return
0
;
}
virtual
bool
covering_keys_processor
(
uchar
*
arg
)
{
return
0
;
}
virtual
bool
view_used_tables_processor
(
uchar
*
arg
)
{
return
0
;
}
virtual
bool
eval_not_null_tables
(
uchar
*
opt_arg
)
{
return
0
;
}
virtual
bool
clear_sum_processor
(
uchar
*
opt_arg
)
{
return
0
;
}
...
...
@@ -1832,6 +1833,7 @@ class Item_field :public Item_ident
bool
vcol_in_partition_func_processor
(
uchar
*
bool_arg
);
bool
check_vcol_func_processor
(
uchar
*
arg
)
{
return
FALSE
;}
bool
enumerate_field_refs_processor
(
uchar
*
arg
);
bool
covering_keys_processor
(
uchar
*
arg
);
void
cleanup
();
Item_equal
*
get_item_equal
()
{
return
item_equal
;
}
void
set_item_equal
(
Item_equal
*
item_eq
)
{
item_equal
=
item_eq
;
}
...
...
sql/item_subselect.cc
View file @
aab6e4f2
...
...
@@ -492,6 +492,7 @@ void Item_subselect::recalc_used_tables(st_select_lex *new_parent,
upper
->
item
->
walk
(
&
Item
::
enumerate_field_refs_processor
,
FALSE
,
(
uchar
*
)
&
fixer
);
used_tables_cache
|=
fixer
.
used_tables
;
upper
->
item
->
walk
(
&
Item
::
covering_keys_processor
,
FALSE
,
NULL
);
/*
if (after_pullout)
upper->item->fix_after_pullout(new_parent, &(upper->item));
...
...
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