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
48eb9e46
Commit
48eb9e46
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
67be8fe9
Changes
6
Show 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 @
48eb9e46
...
@@ -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 @
48eb9e46
...
@@ -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 @
48eb9e46
...
@@ -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 @
48eb9e46
...
@@ -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 @
48eb9e46
...
@@ -1386,6 +1386,21 @@ row_ins_check_foreign_constraint(
...
@@ -1386,6 +1386,21 @@ row_ins_check_foreign_constraint(
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 @
48eb9e46
...
@@ -474,7 +474,8 @@ row_mysql_handle_errors(
...
@@ -474,7 +474,8 @@ row_mysql_handle_errors(
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