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
7e269592
Commit
7e269592
authored
Mar 10, 2010
by
Michael Widenius
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge
parents
3e32ba3f
77afc2be
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
4 deletions
+56
-4
mysql-test/r/foreign_key.result
mysql-test/r/foreign_key.result
+28
-1
mysql-test/t/foreign_key.test
mysql-test/t/foreign_key.test
+23
-1
sql/sql_delete.cc
sql/sql_delete.cc
+5
-2
No files found.
mysql-test/r/foreign_key.result
View file @
7e269592
drop table if exists t1;
drop table if exists t1
,t2
;
create table t1 (
a int not null references t2,
b int not null references t2 (c),
...
...
@@ -13,3 +13,30 @@ foreign key (a,b) references t3 (c,d) on update set null);
create index a on t1 (a);
create unique index b on t1 (a,b);
drop table t1;
create table t1 (id int primary key) engine = innodb;
create table t2 (id int PRIMARY KEY, FOREIGN KEY (id) REFERENCES t1(id)) engine=innodb;
insert into t1 values (1), (2), (3), (4), (5), (6);
insert into t2 values (3), (5);
delete from t1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))
select * from t1;
id
1
2
3
4
5
6
delete ignore from t1;
Warnings:
Error 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))
Error 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))
select row_count();
row_count()
-1
select * from t1;
id
3
5
drop table t2;
drop table t1;
mysql-test/t/foreign_key.test
View file @
7e269592
...
...
@@ -2,8 +2,10 @@
# Test syntax of foreign keys
#
--
source
include
/
have_innodb
.
inc
--
disable_warnings
drop
table
if
exists
t1
;
drop
table
if
exists
t1
,
t2
;
--
enable_warnings
create
table
t1
(
...
...
@@ -23,3 +25,23 @@ create unique index b on t1 (a,b);
drop
table
t1
;
# End of 4.1 tests
#
# Test DELETE IGNORE
# Bug#44987 DELETE IGNORE and FK constraint
#
create
table
t1
(
id
int
primary
key
)
engine
=
innodb
;
create
table
t2
(
id
int
PRIMARY
KEY
,
FOREIGN
KEY
(
id
)
REFERENCES
t1
(
id
))
engine
=
innodb
;
insert
into
t1
values
(
1
),
(
2
),
(
3
),
(
4
),
(
5
),
(
6
);
insert
into
t2
values
(
3
),
(
5
);
--
error
1451
delete
from
t1
;
select
*
from
t1
;
delete
ignore
from
t1
;
select
row_count
();
select
*
from
t1
;
drop
table
t2
;
drop
table
t1
;
sql/sql_delete.cc
View file @
7e269592
...
...
@@ -335,8 +335,11 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
InnoDB it can fail in a FOREIGN KEY error or an
out-of-tablespace error.
*/
error
=
1
;
break
;
if
(
!
select_lex
->
no_error
)
{
error
=
1
;
break
;
}
}
}
else
...
...
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