From 24d39dd6edcb8ab18f58ee0823c34d09662fb620 Mon Sep 17 00:00:00 2001 From: "D. Richard Hipp" Date: Tue, 17 Apr 2018 18:18:05 +0000 Subject: [PATCH] Simplification to the upsert logic. --- src/insert.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/insert.c b/src/insert.c index c5c92d6b77..66cda0b1d1 100644 --- a/src/insert.c +++ b/src/insert.c @@ -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); } -- 2.11.4.GIT