From 2beb8e472548b843d4955111cb661714f9852385 Mon Sep 17 00:00:00 2001 From: PThorpe92 Date: Fri, 29 Aug 2025 19:35:01 -0400 Subject: [PATCH] Add documentation and comments to translate.rs for upsert --- core/translate/insert.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/translate/insert.rs b/core/translate/insert.rs index b1338f6dc..610f54ef2 100644 --- a/core/translate/insert.rs +++ b/core/translate/insert.rs @@ -399,7 +399,8 @@ pub fn translate_insert( }); let rowid_column_name = insertion.key.column_name(); - // emit halt for every case *except* when upsert handles the conflict + // Conflict on rowid: attempt to route through UPSERT if it targets the PK, otherwise raise constraint. + // emit Halt for every case *except* when upsert handles the conflict 'emit_halt: { if let Some(ref mut upsert) = upsert_opt.as_mut() { if upsert_matches_pk(upsert, &table) { @@ -515,6 +516,7 @@ pub fn translate_insert( }, ); + // again, emit halt for every case *except* when upsert handles the conflict 'emit_halt: { if let Some(ref mut upsert) = upsert_opt.as_mut() { if upsert_matches_index(upsert, index, &table) { @@ -558,6 +560,7 @@ pub fn translate_insert( break 'emit_halt; } } + // No matching UPSERT rule: unique constraint violation. program.emit_insn(Insn::Halt { err_code: SQLITE_CONSTRAINT_PRIMARYKEY, description: column_names,