diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2017-11-14 11:46:43 +0200 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2017-11-14 11:46:43 +0200 |
commit | 769166e9ddea723143630da16323a583d0f3eca4 (patch) | |
tree | a5388b50a1b9b79a24aa65f69358fa9e53c4b804 /scripts | |
parent | b2dd5232d4872d6c9ee565f1a88e70514ceb1780 (diff) | |
download | mariadb-git-bb-10.2-MDEV-13206.tar.gz |
MDEV-13206: INSERT ON DUPLICATE KEY UPDATE foreign key failbb-10.2-MDEV-13206
This is caused by following change:
commit 95d29c99f01882ffcc2259f62b3163f9b0e80c75
Author: Marko Mäkelä <marko.makela@oracle.com>
Date: Tue Nov 27 11:12:13 2012 +0200
Bug#15920445 INNODB REPORTS ER_DUP_KEY BEFORE CREATE UNIQUE INDEX COMPLETED
There is a phase during online secondary index creation where the index has
been internally completed inside InnoDB, but does not 'officially' exist yet.
We used to report ER_DUP_KEY in these situations, like this:
ERROR 23000: Can't write; duplicate key in table 't1'
What we should do is to let the 'offending' operation complete, but report an
error to the
ALTER TABLE t1 ADD UNIQUE KEY (c2):
ERROR HY000: Index c2 is corrupted
(This misleading error message should be fixed separately:
Bug#15920713 CREATE UNIQUE INDEX REPORTS ER_INDEX_CORRUPT INSTEAD OF DUPLICATE)
row_ins_sec_index_entry_low(): flag the index corrupted instead of
reporting a duplicate, in case the index has not been published yet.
rb:1614 approved by Jimmy Yang
Problem is that after we have found duplicate key on primary key
we continue to get necessary gap locks in secondary indexes to
block concurrent transactions from inserting the searched records.
However, search from unique index used in foreign key constraint
could return DB_NO_REFERENCED_ROW if INSERT .. ON DUPLICATE KEY UPDATE
does not contain value for foreign key column. In this case
we should return the original DB_DUPLICATE_KEY error instead
of DB_NO_REFERENCED_ROW.
Imported also missing test case from MySQL 5.7 for
commit 25781c154396dbbc21023786aa3be070057d6999
Author: Annamalai Gurusami <annamalai.gurusami@oracle.com>
Date: Mon Feb 24 14:00:03 2014 +0530
Bug #17604730 ASSERTION: *CURSOR->INDEX->NAME == TEMP_INDEX_PREFIX
Problem:
When INSERT ... ON DUPLICATE UPDATE or REPLACE statements are used, then
after encountering a DB_DUPLICATE_KEY error, we continue to process all
the unique secondary indexes to place the necessary gap locks. The
problem is in the following scenario:
1. The table has one primary index, one unique secondary index and
one non-unique secondary index.
2. The INSERT ... ON DUPLICATE UPDATE ... is executed on the table.
3. Insert into the clustered index reported DB_DUPLICATE_KEY. This
error information is saved. We proceed to take gap locks in all
unique secondary indexes.
4. Insert into the unique secondary index reported DB_LOCK_WAIT.
5. Step 4 is repeated from a higher layer row_ins(). When this is
done, the earlier error information saved in step 3 is lost.
6. Next instead of taking just gap locks or skipping non-unique
secondary indexes, because of loss of information regarding the
error already saved, an actual insert is performed on the non-unique
secondary index. This triggers the assert.
Solution:
Save the error information in a non-local location so that it is not lost.
rb#4723 approved by Kevin.
Diffstat (limited to 'scripts')
0 files changed, 0 insertions, 0 deletions