diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2018-02-05 18:21:28 +0200 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2018-02-05 18:21:28 +0200 |
commit | 60f51af755ea9d07c20a596ba21de184816fa265 (patch) | |
tree | 419e3b30ded268e1d2ad3f9ef095501ec68e587e /storage | |
parent | 9390ff53fc39e34976cf051ce33649f9316bb8e6 (diff) | |
download | mariadb-git-60f51af755ea9d07c20a596ba21de184816fa265.tar.gz |
MDEV-15042: INSERT ON DUPLICATE KEY UPDATE produces error 1032 (Can't find record)bb-10.2-MDEV-15042
Problem was that wrong error message was returned when insert
returned FK-error and there was no duplicate key to process.
row_ins
If error from insert was DB_NO_REFERENCED_ROW and there was
no duplicate key we should ignore ON DUPLICATE KEY UPDATE
and return original error message.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/row/row0ins.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index fc6f932db81..1f4e057a202 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -3696,12 +3696,24 @@ row_ins( placing all gaplocks. */ err = DB_DUPLICATE_KEY; break; - } else if (!node->duplicate) { + } else if (err == DB_DUPLICATE_KEY && + !node->duplicate) { /* Save 1st dup error. Ignore subsequent dup errors. */ node->duplicate = node->index; thr_get_trx(thr)->error_state = DB_DUPLICATE_KEY; + } else if (err == DB_NO_REFERENCED_ROW) { + /* As a example consider + case INSERT INTO child (id) + VALUES (1) ON DUPLICATE + KEY UPDATE id = + VALUES(id); + where (1) does not cause + duplicate key. Thus + we should return original + DB_NO_REFERENCED_ROW */ + DBUG_RETURN(err); } break; } |