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
1affa4df
Commit
1affa4df
authored
Jan 18, 2005
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed problem in resolving items of outer query in subqueries in view (BUG#6394)
parent
d3dc7313
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
2 deletions
+51
-2
mysql-test/r/view.result
mysql-test/r/view.result
+20
-0
mysql-test/t/view.test
mysql-test/t/view.test
+16
-0
sql/table.cc
sql/table.cc
+15
-2
No files found.
mysql-test/r/view.result
View file @
1affa4df
...
@@ -1724,3 +1724,23 @@ a b
...
@@ -1724,3 +1724,23 @@ a b
301 0
301 0
drop view v3;
drop view v3;
drop tables t1,t2;
drop tables t1,t2;
create table t1(c1 int);
create table t2(c2 int);
insert into t1 values (1),(2),(3);
insert into t2 values (1);
SELECT c1 FROM t1 WHERE c1 IN (SELECT c2 FROM t2);
c1
1
SELECT c1 FROM t1 WHERE EXISTS (SELECT c2 FROM t2 WHERE c2 = c1);
c1
1
create view v1 as SELECT c1 FROM t1 WHERE c1 IN (SELECT c2 FROM t2);
create view v2 as SELECT c1 FROM t1 WHERE EXISTS (SELECT c2 FROM t2 WHERE c2 = c1);
select * from v1;
c1
1
select * from v2;
c1
1
drop view v2, v1;
drop table t1, t2;
mysql-test/t/view.test
View file @
1affa4df
...
@@ -1654,3 +1654,19 @@ select * from v3;
...
@@ -1654,3 +1654,19 @@ select * from v3;
drop
view
v3
;
drop
view
v3
;
drop
tables
t1
,
t2
;
drop
tables
t1
,
t2
;
#
# Resolving view fields in subqueries in VIEW (Bug #6394)
#
create
table
t1
(
c1
int
);
create
table
t2
(
c2
int
);
insert
into
t1
values
(
1
),(
2
),(
3
);
insert
into
t2
values
(
1
);
SELECT
c1
FROM
t1
WHERE
c1
IN
(
SELECT
c2
FROM
t2
);
SELECT
c1
FROM
t1
WHERE
EXISTS
(
SELECT
c2
FROM
t2
WHERE
c2
=
c1
);
create
view
v1
as
SELECT
c1
FROM
t1
WHERE
c1
IN
(
SELECT
c2
FROM
t2
);
create
view
v2
as
SELECT
c1
FROM
t1
WHERE
EXISTS
(
SELECT
c2
FROM
t2
WHERE
c2
=
c1
);
select
*
from
v1
;
select
*
from
v2
;
drop
view
v2
,
v1
;
drop
table
t1
,
t2
;
sql/table.cc
View file @
1affa4df
...
@@ -1687,6 +1687,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
...
@@ -1687,6 +1687,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
Field_translator
*
transl
;
Field_translator
*
transl
;
SELECT_LEX
*
select
=
&
view
->
select_lex
;
SELECT_LEX
*
select
=
&
view
->
select_lex
;
SELECT_LEX
*
current_select_save
=
thd
->
lex
->
current_select
;
SELECT_LEX
*
current_select_save
=
thd
->
lex
->
current_select
;
byte
*
main_table_list_save
=
thd
->
lex
->
select_lex
.
table_list
.
first
;
Item
*
item
;
Item
*
item
;
TABLE_LIST
*
tbl
;
TABLE_LIST
*
tbl
;
List_iterator_fast
<
Item
>
it
(
select
->
item_list
);
List_iterator_fast
<
Item
>
it
(
select
->
item_list
);
...
@@ -1709,8 +1710,13 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
...
@@ -1709,8 +1710,13 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
if
(
field_translation
)
if
(
field_translation
)
{
{
DBUG_PRINT
(
"info"
,
(
"there are already translation table"
));
DBUG_PRINT
(
"info"
,
(
"there are already translation table"
));
/* prevent look up in SELECTs tree */
/*
prevent look up in SELECTs tree, and emulate main table list by
ancestor table list for subquery processing
*/
thd
->
lex
->
current_select
=
&
thd
->
lex
->
select_lex
;
thd
->
lex
->
current_select
=
&
thd
->
lex
->
select_lex
;
thd
->
lex
->
select_lex
.
table_list
.
first
=
(
byte
*
)
ancestor
;
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
1
;
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
1
;
thd
->
set_query_id
=
1
;
thd
->
set_query_id
=
1
;
/* this view was prepared already on previous PS/SP execution */
/* this view was prepared already on previous PS/SP execution */
...
@@ -1755,8 +1761,13 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
...
@@ -1755,8 +1761,13 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
}
}
/* prevent look up in SELECTs tree */
/*
prevent look up in SELECTs tree, and emulate main table list by ancestor
table list for subquery processing
*/
thd
->
lex
->
current_select
=
&
thd
->
lex
->
select_lex
;
thd
->
lex
->
current_select
=
&
thd
->
lex
->
select_lex
;
thd
->
lex
->
select_lex
.
table_list
.
first
=
(
byte
*
)
ancestor
;
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
1
;
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
1
;
/*
/*
...
@@ -1901,6 +1912,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
...
@@ -1901,6 +1912,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
ok:
ok:
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
save_wrapper
;
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
save_wrapper
;
thd
->
lex
->
current_select
=
current_select_save
;
thd
->
lex
->
current_select
=
current_select_save
;
thd
->
lex
->
select_lex
.
table_list
.
first
=
main_table_list_save
;
thd
->
set_query_id
=
save_set_query_id
;
thd
->
set_query_id
=
save_set_query_id
;
thd
->
allow_sum_func
=
save_allow_sum_func
;
thd
->
allow_sum_func
=
save_allow_sum_func
;
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
...
@@ -1915,6 +1927,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
...
@@ -1915,6 +1927,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
}
}
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
save_wrapper
;
thd
->
lex
->
select_lex
.
no_wrap_view_item
=
save_wrapper
;
thd
->
lex
->
current_select
=
current_select_save
;
thd
->
lex
->
current_select
=
current_select_save
;
thd
->
lex
->
select_lex
.
table_list
.
first
=
main_table_list_save
;
thd
->
set_query_id
=
save_set_query_id
;
thd
->
set_query_id
=
save_set_query_id
;
thd
->
allow_sum_func
=
save_allow_sum_func
;
thd
->
allow_sum_func
=
save_allow_sum_func
;
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
...
...
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