1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Simplification to the upsert logic.

FossilOrigin-Name: f36d07a5b24cc48e3daa8b18dd34c50d9025c6c0ba019926610538b54f7b66ec
This commit is contained in:
drh
2018-04-17 18:18:05 +00:00
parent 2cc00423a0
commit dedbc50811
3 changed files with 16 additions and 23 deletions

View File

@@ -1440,24 +1440,17 @@ void sqlite3GenerateConstraintChecks(
** in the list. See sqlite3CreateIndex() for where that happens.
*/
/* If there is an ON CONFLICT clause without a constraint-target
** (In other words, one of "ON CONFLICT DO NOTHING" or
** "ON DUPLICATION KEY UPDATE") then change the overrideError to
** whichever is appropriate.
*/
if( pUpsert ){
if( pUpsert->pUpsertTarget==0 ){
if( pUpsert->pUpsertSet==0 ){
/* An ON CONFLICT DO NOTHING clause, without a constraint-target.
** Make all unique constraint resolution be OE_Ignore */
overrideError = OE_Ignore;
pUpsert = 0;
}else{
/* An ON DUPLICATE KEY UPDATE clause. All unique constraints
** do upsert processing */
overrideError = OE_Update;
}
/* An ON CONFLICT DO NOTHING clause, without a constraint-target.
** Make all unique constraint resolution be OE_Ignore */
assert( pUpsert->pUpsertSet==0 );
overrideError = OE_Ignore;
pUpsert = 0;
}else if( (pUpIdx = pUpsert->pUpsertIdx)!=0 ){
/* If the constraint-target is on some column other than
** then ROWID, then we might need to move the UPSERT around
** so that it occurs in the correct order. */
sAddr.upsertTop = sqlite3VdbeMakeLabel(v);
sAddr.upsertBtm = sqlite3VdbeMakeLabel(v);
}