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
5327ec1d
Commit
5327ec1d
authored
Nov 17, 2003
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IGNORE option was added for DELETE statement (WL#1334)
parent
74165e72
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
96 additions
and
50 deletions
+96
-50
mysql-test/r/delete.result
mysql-test/r/delete.result
+63
-1
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+0
-29
mysql-test/t/delete.test
mysql-test/t/delete.test
+28
-1
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+0
-18
sql/sql_delete.cc
sql/sql_delete.cc
+3
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+2
-1
No files found.
mysql-test/r/delete.result
View file @
5327ec1d
drop table if exists t1;
drop table if exists t1
,t11,t12,t2
;
CREATE TABLE t1 (a tinyint(3), b tinyint(5));
CREATE TABLE t1 (a tinyint(3), b tinyint(5));
INSERT INTO t1 VALUES (1,1);
INSERT INTO t1 VALUES (1,1);
INSERT LOW_PRIORITY INTO t1 VALUES (1,2);
INSERT LOW_PRIORITY INTO t1 VALUES (1,2);
...
@@ -58,3 +58,65 @@ select count(*) from t1;
...
@@ -58,3 +58,65 @@ select count(*) from t1;
count(*)
count(*)
0
0
drop table t1;
drop table t1;
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),(0, 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
0 11
2 12
select * from t2;
a b
1 21
2 12
3 23
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
ERROR 21000: Subquery returns more than 1 row
select * from t11;
a b
0 10
1 11
2 12
select * from t12;
a b
33 10
0 11
2 12
delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
Warnings:
Error 1241 Subquery returns more than 1 row
Error 1241 Subquery returns more than 1 row
select * from t11;
a b
0 10
1 11
select * from t12;
a b
33 10
0 11
insert into t11 values (2, 12);
delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
ERROR 21000: Subquery returns more than 1 row
select * from t11;
a b
0 10
1 11
2 12
delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
Warnings:
Error 1241 Subquery returns more than 1 row
Error 1241 Subquery returns more than 1 row
select * from t11;
a b
0 10
1 11
drop table t11, t12, t2;
mysql-test/r/subselect.result
View file @
5327ec1d
...
@@ -1569,32 +1569,3 @@ INSERT INTO t2 VALUES (100, 200, 'C');
...
@@ -1569,32 +1569,3 @@ INSERT INTO t2 VALUES (100, 200, 'C');
SELECT DISTINCT COLC FROM t1 WHERE COLA = (SELECT COLA FROM t2 WHERE COLB = 200 AND COLC ='C' LIMIT 1);
SELECT DISTINCT COLC FROM t1 WHERE COLA = (SELECT COLA FROM t2 WHERE COLB = 200 AND COLC ='C' LIMIT 1);
COLC
COLC
DROP TABLE t1, t2;
DROP TABLE t1, 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
select * from t2;
a b
1 21
2 12
3 23
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b > (select b from t2);
ERROR 21000: Subquery returns more than 1 row
select * from t2;
a b
1 21
2 12
3 23
drop table t11, t12, t2;
mysql-test/t/delete.test
View file @
5327ec1d
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
#
#
--
disable_warnings
--
disable_warnings
drop
table
if
exists
t1
;
drop
table
if
exists
t1
,
t11
,
t12
,
t2
;
--
enable_warnings
--
enable_warnings
CREATE
TABLE
t1
(
a
tinyint
(
3
),
b
tinyint
(
5
));
CREATE
TABLE
t1
(
a
tinyint
(
3
),
b
tinyint
(
5
));
INSERT
INTO
t1
VALUES
(
1
,
1
);
INSERT
INTO
t1
VALUES
(
1
,
1
);
...
@@ -71,3 +71,30 @@ delete from t1 where 3 > 2;
...
@@ -71,3 +71,30 @@ delete from t1 where 3 > 2;
select
count
(
*
)
from
t1
;
select
count
(
*
)
from
t1
;
drop
table
t1
;
drop
table
t1
;
#
# IGNORE option
#
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
),(
0
,
11
),(
2
,
12
);
insert
into
t2
values
(
1
,
21
),(
2
,
12
),(
3
,
23
);
select
*
from
t11
;
select
*
from
t12
;
select
*
from
t2
;
--
error
1241
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
;
delete
ignore
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
;
insert
into
t11
values
(
2
,
12
);
--
error
1241
delete
from
t11
where
t11
.
b
<>
(
select
b
from
t2
where
t11
.
a
<
t2
.
a
);
select
*
from
t11
;
delete
ignore
from
t11
where
t11
.
b
<>
(
select
b
from
t2
where
t11
.
a
<
t2
.
a
);
select
*
from
t11
;
drop
table
t11
,
t12
,
t2
;
mysql-test/t/subselect.test
View file @
5327ec1d
...
@@ -1009,21 +1009,3 @@ INSERT INTO t1 VALUES (1,1,'1A3240'), (1,2,'4W2365');
...
@@ -1009,21 +1009,3 @@ INSERT INTO t1 VALUES (1,1,'1A3240'), (1,2,'4W2365');
INSERT
INTO
t2
VALUES
(
100
,
200
,
'C'
);
INSERT
INTO
t2
VALUES
(
100
,
200
,
'C'
);
SELECT
DISTINCT
COLC
FROM
t1
WHERE
COLA
=
(
SELECT
COLA
FROM
t2
WHERE
COLB
=
200
AND
COLC
=
'C'
LIMIT
1
);
SELECT
DISTINCT
COLC
FROM
t1
WHERE
COLA
=
(
SELECT
COLA
FROM
t2
WHERE
COLB
=
200
AND
COLC
=
'C'
LIMIT
1
);
DROP
TABLE
t1
,
t2
;
DROP
TABLE
t1
,
t2
;
#
# errors handling
#
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
;
select
*
from
t2
;
--
error
1241
delete
t11
.*
,
t12
.*
from
t11
,
t12
where
t11
.
a
=
t12
.
a
and
t11
.
b
>
(
select
b
from
t2
);
select
*
from
t2
;
drop
table
t11
,
t12
,
t2
;
sql/sql_delete.cc
View file @
5327ec1d
...
@@ -66,6 +66,9 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
...
@@ -66,6 +66,9 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
}
}
if
(
thd
->
lex
.
duplicates
==
DUP_IGNORE
)
thd
->
lex
.
select_lex
.
no_error
=
1
;
/* Test if the user wants to delete all rows */
/* Test if the user wants to delete all rows */
if
(
!
using_limit
&&
const_cond
&&
(
!
conds
||
conds
->
val_int
())
&&
if
(
!
using_limit
&&
const_cond
&&
(
!
conds
||
conds
->
val_int
())
&&
!
(
specialflag
&
(
SPECIAL_NO_NEW_FUNC
|
SPECIAL_SAFE_MODE
)))
!
(
specialflag
&
(
SPECIAL_NO_NEW_FUNC
|
SPECIAL_SAFE_MODE
)))
...
...
sql/sql_yacc.yy
View file @
5327ec1d
...
@@ -3895,7 +3895,8 @@ opt_delete_options:
...
@@ -3895,7 +3895,8 @@ opt_delete_options:
opt_delete_option:
opt_delete_option:
QUICK { Select->options|= OPTION_QUICK; }
QUICK { Select->options|= OPTION_QUICK; }
| LOW_PRIORITY { Lex->lock_option= TL_WRITE_LOW_PRIORITY; };
| LOW_PRIORITY { Lex->lock_option= TL_WRITE_LOW_PRIORITY; }
| IGNORE_SYM { Lex->duplicates= DUP_IGNORE; };
truncate:
truncate:
TRUNCATE_SYM opt_table_sym table_name
TRUNCATE_SYM opt_table_sym table_name
...
...
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