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
e419b767
Commit
e419b767
authored
Nov 26, 2002
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multi-delete with subselects (SCRUM)
parent
6b403114
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletion
+45
-1
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+27
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+15
-0
sql/sql_parse.cc
sql/sql_parse.cc
+3
-1
No files found.
mysql-test/r/subselect.result
View file @
e419b767
...
@@ -353,6 +353,33 @@ a b
...
@@ -353,6 +353,33 @@ a b
0 10
0 10
1 11
1 11
drop table t1, t2;
drop table t1, t2;
drop table if exists t11, t12, t2;
create table t11 (a int NOT NULL, b int, primary key (a));
create table t12 (a int NOT NULL, b int, primary key (a));
create table t2 (a int NOT NULL, b int, primary key (a));
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
insert into t2 values (1, 21),(2, 12),(3, 23);
select * from t11;
a b
0 10
1 11
2 12
select * from t12;
a b
33 10
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
select * from t11;
a b
0 10
1 11
select * from t12;
a b
33 10
22 11
drop table t11, t12, t2;
CREATE TABLE t1 (x int);
CREATE TABLE t1 (x int);
create table t2 (a int);
create table t2 (a int);
insert into t2 values (1);
insert into t2 values (1);
...
...
mysql-test/t/subselect.test
View file @
e419b767
...
@@ -226,6 +226,21 @@ delete from t1 where b = (select b from t2 where t1.a = t2.a);
...
@@ -226,6 +226,21 @@ delete from t1 where b = (select b from t2 where t1.a = t2.a);
select
*
from
t1
;
select
*
from
t1
;
drop
table
t1
,
t2
;
drop
table
t1
,
t2
;
#multi-delete with subselects
drop
table
if
exists
t11
,
t12
,
t2
;
create
table
t11
(
a
int
NOT
NULL
,
b
int
,
primary
key
(
a
));
create
table
t12
(
a
int
NOT
NULL
,
b
int
,
primary
key
(
a
));
create
table
t2
(
a
int
NOT
NULL
,
b
int
,
primary
key
(
a
));
insert
into
t11
values
(
0
,
10
),(
1
,
11
),(
2
,
12
);
insert
into
t12
values
(
33
,
10
),(
22
,
11
),(
2
,
12
);
insert
into
t2
values
(
1
,
21
),(
2
,
12
),(
3
,
23
);
select
*
from
t11
;
select
*
from
t12
;
delete
t11
.*
,
t12
.*
from
t11
,
t12
where
t11
.
a
=
t12
.
a
and
t11
.
b
=
(
select
b
from
t2
where
t11
.
a
=
t2
.
a
);
select
*
from
t11
;
select
*
from
t12
;
drop
table
t11
,
t12
,
t2
;
#insert with subselects
#insert with subselects
CREATE
TABLE
t1
(
x
int
);
CREATE
TABLE
t1
(
x
int
);
create
table
t2
(
a
int
);
create
table
t2
(
a
int
);
...
...
sql/sql_parse.cc
View file @
e419b767
...
@@ -2095,10 +2095,12 @@ mysql_execute_command(THD *thd)
...
@@ -2095,10 +2095,12 @@ mysql_execute_command(THD *thd)
/* Fix tables-to-be-deleted-from list to point at opened tables */
/* Fix tables-to-be-deleted-from list to point at opened tables */
for
(
auxi
=
(
TABLE_LIST
*
)
aux_tables
;
auxi
;
auxi
=
auxi
->
next
)
for
(
auxi
=
(
TABLE_LIST
*
)
aux_tables
;
auxi
;
auxi
=
auxi
->
next
)
auxi
->
table
=
auxi
->
table_list
->
table
;
auxi
->
table
=
auxi
->
table_list
->
table
;
fix_tables_pointers
(
&
lex
->
select_lex
);
if
(
!
thd
->
fatal_error
&&
(
result
=
new
multi_delete
(
thd
,
aux_tables
,
if
(
!
thd
->
fatal_error
&&
(
result
=
new
multi_delete
(
thd
,
aux_tables
,
table_count
)))
table_count
)))
{
{
res
=
mysql_select
(
thd
,
tables
,
select_lex
->
item_list
,
res
=
mysql_select
(
thd
,
select_lex
->
get_table_list
(),
select_lex
->
item_list
,
select_lex
->
where
,
select_lex
->
where
,
(
ORDER
*
)
NULL
,(
ORDER
*
)
NULL
,(
Item
*
)
NULL
,
(
ORDER
*
)
NULL
,(
ORDER
*
)
NULL
,(
Item
*
)
NULL
,
(
ORDER
*
)
NULL
,
(
ORDER
*
)
NULL
,
...
...
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