aboutsummaryrefslogtreecommitdiff
path: root/src/insert.c
diff options
context:
space:
mode:
authordrh <>2021-12-30 02:38:43 +0000
committerdrh <>2021-12-30 02:38:43 +0000
commit66306d86abcd27aae87b39581fa54f9d3eb68d92 (patch)
treef1c528ffd027f81cccdb7ce758e1c4ebf79790b0 /src/insert.c
parent38cebe07bb41051eeeda8b11b63c02ea825f2a8b (diff)
downloadsqlite-66306d86abcd27aae87b39581fa54f9d3eb68d92.tar.gz
sqlite-66306d86abcd27aae87b39581fa54f9d3eb68d92.zip
When a table has an INTEGER PRIMARY KEY ON CONFLICT REPLACE and some other
uniqueness constraint, and it participates in an upsert on that other constraint, ensure that code that checks for conflicts on the INTEGER PRIMARY KEY is well-formed. Fix for the problem reported by [forum:/forumpost/06b16b8b29f8c8c3|forum post 06b16b8b29f8c8c3]. FossilOrigin-Name: 2f09b51b1ff37bf98f958564cc1224968caa7e33147e6666b5c1ba20b2a7813b
Diffstat (limited to 'src/insert.c')
-rw-r--r--src/insert.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/insert.c b/src/insert.c
index 96e86c9fb..6908aff4a 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -2007,6 +2007,7 @@ void sqlite3GenerateConstraintChecks(
if( onError==OE_Replace /* IPK rule is REPLACE */
&& onError!=overrideError /* Rules for other constraints are different */
&& pTab->pIndex /* There exist other constraints */
+ && !upsertIpkDelay /* IPK check already deferred by UPSERT */
){
ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1;
VdbeComment((v, "defer IPK REPLACE until last"));
@@ -2415,6 +2416,7 @@ void sqlite3GenerateConstraintChecks(
if( ipkTop ){
sqlite3VdbeGoto(v, ipkTop);
VdbeComment((v, "Do IPK REPLACE"));
+ assert( ipkBottom>0 );
sqlite3VdbeJumpHere(v, ipkBottom);
}