From e224bb15a832503b7f9d41e63b5dc8b4330adbe4 Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Thu, 21 Aug 2025 16:25:35 +0300 Subject: [PATCH] Fix incorrect UNIQUE constraint failure behavior in UPDATE UPDATE should skip over the UNIQUE constraint failure if the existing row it found during the check has the same rowid as the row we are currently updating --- core/translate/emitter.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/translate/emitter.rs b/core/translate/emitter.rs index e2498f121..670c334bd 100644 --- a/core/translate/emitter.rs +++ b/core/translate/emitter.rs @@ -1056,8 +1056,10 @@ fn emit_update_insns( dest: idx_rowid_reg, }); + // Skip over the UNIQUE constraint failure if the existing row is the one that we are currently changing + let original_rowid_reg = beg; program.emit_insn(Insn::Eq { - lhs: rowid_reg, + lhs: original_rowid_reg, rhs: idx_rowid_reg, target_pc: constraint_check, flags: CmpInsFlags::default(), // TODO: not sure what type of comparison flag is needed