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
b8f5fc3a
Commit
b8f5fc3a
authored
Nov 25, 2002
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
subselet in delete (SCRUM)
parent
f5dab36a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
2 deletions
+36
-2
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+19
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+11
-0
sql/sql_delete.cc
sql/sql_delete.cc
+6
-2
No files found.
mysql-test/r/subselect.result
View file @
b8f5fc3a
...
...
@@ -335,3 +335,22 @@ a b
1 21
2 22
drop table t1, t2;
drop table if exists t1, t2;
create table t1 (a int NOT NULL, b int, primary key (a));
create table t2 (a int NOT NULL, b int, primary key (a));
insert into t1 values (0, 10),(1, 11),(2, 12);
insert into t2 values (1, 21),(2, 12),(3, 23);
select * from t1;
a b
0 10
1 11
2 12
select * from t1 where b = (select b from t2 where t1.a = t2.a);
a b
2 12
delete from t1 where b = (select b from t2 where t1.a = t2.a);
select * from t1;
a b
0 10
1 11
drop table t1, t2;
mysql-test/t/subselect.test
View file @
b8f5fc3a
...
...
@@ -215,3 +215,14 @@ update t1 set b= (select b from t2 where t1.a = t2.a);
select
*
from
t1
;
drop
table
t1
,
t2
;
#delete with subselects
drop
table
if
exists
t1
,
t2
;
create
table
t1
(
a
int
NOT
NULL
,
b
int
,
primary
key
(
a
));
create
table
t2
(
a
int
NOT
NULL
,
b
int
,
primary
key
(
a
));
insert
into
t1
values
(
0
,
10
),(
1
,
11
),(
2
,
12
);
insert
into
t2
values
(
1
,
21
),(
2
,
12
),(
3
,
23
);
select
*
from
t1
;
select
*
from
t1
where
b
=
(
select
b
from
t2
where
t1
.
a
=
t2
.
a
);
delete
from
t1
where
b
=
(
select
b
from
t2
where
t1
.
a
=
t2
.
a
);
select
*
from
t1
;
drop
table
t1
,
t2
;
sql/sql_delete.cc
View file @
b8f5fc3a
...
...
@@ -37,14 +37,18 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
bool
using_limit
=
limit
!=
HA_POS_ERROR
;
bool
transactional_table
,
log_delayed
,
safe_update
,
const_cond
;
ha_rows
deleted
;
TABLE_LIST
*
delete_table_list
=
(
TABLE_LIST
*
)
thd
->
lex
.
select_lex
.
table_list
.
first
;
DBUG_ENTER
(
"mysql_delete"
);
if
(
!
(
table
=
open_ltable
(
thd
,
table_list
,
table_list
->
lock_type
)))
if
(
(
open_and_lock_tables
(
thd
,
table_list
)))
DBUG_RETURN
(
-
1
);
fix_tables_pointers
(
&
thd
->
lex
.
select_lex
);
table
=
table_list
->
table
;
table
->
file
->
info
(
HA_STATUS_VARIABLE
|
HA_STATUS_NO_LOCK
);
thd
->
proc_info
=
"init"
;
table
->
map
=
1
;
if
(
setup_conds
(
thd
,
table_list
,
&
conds
)
||
if
(
setup_conds
(
thd
,
delete_table_list
,
&
conds
)
||
setup_ftfuncs
(
&
thd
->
lex
.
select_lex
))
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