diff options
author | unknown <aivanov@mysql.com> | 2006-02-09 20:43:10 +0300 |
---|---|---|
committer | unknown <aivanov@mysql.com> | 2006-02-09 20:43:10 +0300 |
commit | 463ac89d01e952d63e71cab22c94be399b05c230 (patch) | |
tree | 5f9de9e0a158a0f3deba363bd65856bbd3e8113d /storage | |
parent | 4f9e66daa409df056475d28fbed853feaacd2525 (diff) | |
download | mariadb-git-463ac89d01e952d63e71cab22c94be399b05c230.tar.gz |
Fixed BUG#9680: Wrong error from cascading update
Applied 9680.patch (by Osku Salerma)
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/include/db0err.h | 4 | ||||
-rw-r--r-- | storage/innobase/row/row0ins.c | 15 | ||||
-rw-r--r-- | storage/innobase/row/row0mysql.c | 5 |
3 files changed, 22 insertions, 2 deletions
diff --git a/storage/innobase/include/db0err.h b/storage/innobase/include/db0err.h index de5ac44e73f..7f75e7e10a6 100644 --- a/storage/innobase/include/db0err.h +++ b/storage/innobase/include/db0err.h @@ -57,6 +57,10 @@ Created 5/24/1996 Heikki Tuuri buffer pool (for big transactions, InnoDB stores the lock structs in the 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 */ #define DB_FAIL 1000 diff --git a/storage/innobase/row/row0ins.c b/storage/innobase/row/row0ins.c index 5e833372299..128b46f9aa4 100644 --- a/storage/innobase/row/row0ins.c +++ b/storage/innobase/row/row0ins.c @@ -1376,6 +1376,21 @@ run_again: thr, foreign, &pcur, entry, &mtr); 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; } diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index 86d9ecf9c54..a16ffc5aa41 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -473,8 +473,9 @@ handle_new_error: ut_a(err != DB_SUCCESS); trx->error_state = DB_SUCCESS; - - if (err == DB_DUPLICATE_KEY) { + + if ((err == DB_DUPLICATE_KEY) + || (err == DB_FOREIGN_DUPLICATE_KEY)) { if (savept) { /* Roll back the latest, possibly incomplete insertion or update */ |