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
08af835d
Commit
08af835d
authored
Feb 10, 2006
by
osku
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply InnoDB-specific parts of the fix for bug #9680, wrong error from
cascading update.
parent
3d98fd8b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
2 deletions
+73
-2
handler/ha_innodb.cc
handler/ha_innodb.cc
+4
-0
include/db0err.h
include/db0err.h
+4
-0
mysql-test/innodb.result
mysql-test/innodb.result
+18
-0
mysql-test/innodb.test
mysql-test/innodb.test
+29
-0
row/row0ins.c
row/row0ins.c
+15
-0
row/row0mysql.c
row/row0mysql.c
+3
-2
No files found.
handler/ha_innodb.cc
View file @
08af835d
...
@@ -457,6 +457,10 @@ convert_error_code_to_mysql(
...
@@ -457,6 +457,10 @@ convert_error_code_to_mysql(
return
(
HA_ERR_FOUND_DUPP_KEY
);
return
(
HA_ERR_FOUND_DUPP_KEY
);
}
else
if
(
error
==
(
int
)
DB_FOREIGN_DUPLICATE_KEY
)
{
return
(
HA_ERR_FOREIGN_DUPLICATE_KEY
);
}
else
if
(
error
==
(
int
)
DB_RECORD_NOT_FOUND
)
{
}
else
if
(
error
==
(
int
)
DB_RECORD_NOT_FOUND
)
{
return
(
HA_ERR_NO_ACTIVE_RECORD
);
return
(
HA_ERR_NO_ACTIVE_RECORD
);
...
...
include/db0err.h
View file @
08af835d
...
@@ -57,6 +57,10 @@ Created 5/24/1996 Heikki Tuuri
...
@@ -57,6 +57,10 @@ Created 5/24/1996 Heikki Tuuri
buffer pool (for big transactions,
buffer pool (for big transactions,
InnoDB stores the lock structs in the
InnoDB stores the lock structs in the
buffer pool) */
buffer pool) */
#define DB_FOREIGN_DUPLICATE_KEY 46
/* foreign key constraints
activated by the operation would
lead to a duplicate key in some
table */
/* The following are partial failure codes */
/* The following are partial failure codes */
#define DB_FAIL 1000
#define DB_FAIL 1000
...
...
mysql-test/innodb.result
View file @
08af835d
...
@@ -3213,3 +3213,21 @@ drop trigger t2t;
...
@@ -3213,3 +3213,21 @@ drop trigger t2t;
drop trigger t3t;
drop trigger t3t;
drop trigger t4t;
drop trigger t4t;
drop table t1, t2, t3, t4, t5;
drop table t1, t2, t3, t4, t5;
CREATE TABLE t1 (
field1 varchar(8) NOT NULL DEFAULT '',
field2 varchar(8) NOT NULL DEFAULT '',
PRIMARY KEY (field1, field2)
)
ENGINE=InnoDB;
CREATE TABLE t2 (
field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY,
FOREIGN KEY (field1) REFERENCES t1 (field1)
ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE=InnoDB;
INSERT INTO t1 VALUES ('old', 'somevalu');
INSERT INTO t1 VALUES ('other', 'anyvalue');
INSERT INTO t2 VALUES ('old');
INSERT INTO t2 VALUES ('other');
UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu';
ERROR 23000: Upholding foreign key constraints for table 't1', entry 'other-somevalu', key 1 would lead to a duplicate entry
DROP TABLE t2;
DROP TABLE t1;
mysql-test/innodb.test
View file @
08af835d
...
@@ -2106,3 +2106,32 @@ drop trigger t4t;
...
@@ -2106,3 +2106,32 @@ drop trigger t4t;
drop
table
t1
,
t2
,
t3
,
t4
,
t5
;
drop
table
t1
,
t2
,
t3
,
t4
,
t5
;
disconnect
a
;
disconnect
a
;
disconnect
b
;
disconnect
b
;
#
# Test that cascading updates leading to duplicate keys give the correct
# error message (bug #9680)
#
CREATE
TABLE
t1
(
field1
varchar
(
8
)
NOT
NULL
DEFAULT
''
,
field2
varchar
(
8
)
NOT
NULL
DEFAULT
''
,
PRIMARY
KEY
(
field1
,
field2
)
)
ENGINE
=
InnoDB
;
CREATE
TABLE
t2
(
field1
varchar
(
8
)
NOT
NULL
DEFAULT
''
PRIMARY
KEY
,
FOREIGN
KEY
(
field1
)
REFERENCES
t1
(
field1
)
ON
DELETE
CASCADE
ON
UPDATE
CASCADE
)
ENGINE
=
InnoDB
;
INSERT
INTO
t1
VALUES
(
'old'
,
'somevalu'
);
INSERT
INTO
t1
VALUES
(
'other'
,
'anyvalue'
);
INSERT
INTO
t2
VALUES
(
'old'
);
INSERT
INTO
t2
VALUES
(
'other'
);
--
error
ER_FOREIGN_DUPLICATE_KEY
UPDATE
t1
SET
field1
=
'other'
WHERE
field2
=
'somevalu'
;
DROP
TABLE
t2
;
DROP
TABLE
t1
;
row/row0ins.c
View file @
08af835d
...
@@ -1386,6 +1386,21 @@ run_again:
...
@@ -1386,6 +1386,21 @@ run_again:
thr
,
foreign
,
&
pcur
,
entry
,
thr
,
foreign
,
&
pcur
,
entry
,
&
mtr
);
&
mtr
);
if
(
err
!=
DB_SUCCESS
)
{
if
(
err
!=
DB_SUCCESS
)
{
/* Since reporting a plain
"duplicate key" error
message to the user in
cases where a long CASCADE
operation would lead to a
duplicate key in some
other table is very
confusing, map duplicate
key errors resulting from
FK constraints to a
separate error code. */
if
(
err
==
DB_DUPLICATE_KEY
)
{
err
=
DB_FOREIGN_DUPLICATE_KEY
;
}
break
;
break
;
}
}
...
...
row/row0mysql.c
View file @
08af835d
...
@@ -473,8 +473,9 @@ handle_new_error:
...
@@ -473,8 +473,9 @@ handle_new_error:
ut_a
(
err
!=
DB_SUCCESS
);
ut_a
(
err
!=
DB_SUCCESS
);
trx
->
error_state
=
DB_SUCCESS
;
trx
->
error_state
=
DB_SUCCESS
;
if
(
err
==
DB_DUPLICATE_KEY
)
{
if
((
err
==
DB_DUPLICATE_KEY
)
||
(
err
==
DB_FOREIGN_DUPLICATE_KEY
))
{
if
(
savept
)
{
if
(
savept
)
{
/* Roll back the latest, possibly incomplete
/* Roll back the latest, possibly incomplete
insertion or update */
insertion or update */
...
...
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