Repository: tursodatabase/limbo (rust)

Issue:
Panic on Update
Simulator in my branch caught an Update panic when executing `op_if`. 
Minimal repro:

```sql
CREATE TABLE amazing_marsden (creative_wood REAL,knowledgeable_walker INTEGER,imaginative_mann TEXT,super_hf BLOB,elegant_dunois BLOB,helpful_andrews REAL);
INSERT INTO amazing_marsden VALUES (4709160243.013426, -3411571621406828678, 'gorgeous_petard', X'6465766F7465645F6A6F796365', X'6C757374726F75735F6D7572726179', 1153303976.370594), (-3830873834.233324, -7006064937495209604, 'gorgeous_thropy', X'67656E65726F75735F6D636B696E6E6579', X'676976696E675F73756D6D6572', -3492137981.5867186);
UPDATE amazing_marsden SET super_hf = X'6C6F76656C795F7265766F6C74', creative_wood = 3854813203.286831 WHERE ~ 'gorgeous_thropy' OR NOT -3830873834.233324;

```

<img width="918" alt="Image" src="https://github.com/user-attachments/assets/71742cfe-f00f-4dad-8441-8031ed55fafe" />

Pull request description:
fix: Incorrect placeholder label in where clause translation
Closes #1705 

Patch:
diff --git a/core/translate/emitter.rs b/core/translate/emitter.rs
index f8be9e87..501c0d7b 100644
--- a/core/translate/emitter.rs
+++ b/core/translate/emitter.rs
@@ -1060,9 +1060,10 @@ fn emit_update_insns(
         .iter()
         .filter(|c| c.should_eval_before_loop(&[JoinOrderMember::default()]))
     {
+        let jump_target = program.allocate_label();
         let meta = ConditionMetadata {
             jump_if_condition_is_true: false,
-            jump_target_when_true: BranchOffset::Placeholder,
+            jump_target_when_true: jump_target,
             jump_target_when_false: loop_labels.next,
         };
         translate_condition_expr(
@@ -1072,6 +1073,7 @@ fn emit_update_insns(
             meta,
             &t_ctx.resolver,
         )?;
+        program.preassign_label_to_next_insn(jump_target);
     }
 
     // we scan a column at a time, loading either the column's values, or the new value
diff --git a/core/translate/expr.rs b/core/translate/expr.rs
index b89e392e..3371dbaf 100644
--- a/core/translate/expr.rs
+++ b/core/translate/expr.rs
@@ -1,4 +1,5 @@
 use limbo_sqlite3_parser::ast::{self, UnaryOperator};
+use tracing::{instrument, Level};
 
 use super::emitter::Resolver;
 use super::optimizer::Optimizable;
@@ -26,6 +27,7 @@ pub struct ConditionMetadata {
     pub jump_target_when_false: BranchOffset,
 }
 
+#[instrument(skip_all, level = Level::TRACE)]
 fn emit_cond_jump(program: &mut ProgramBuilder, cond_meta: ConditionMetadata, reg: usize) {
     if cond_meta.jump_if_condition_is_true {
         program.emit_insn(Insn::If {
@@ -129,6 +131,7 @@ macro_rules! expect_arguments_even {
     }};
 }
 
+#[instrument(skip(program, referenced_tables, expr, resolver), level = Level::TRACE)]
 pub fn translate_condition_expr(
     program: &mut ProgramBuilder,
     referenced_tables: &TableReferences,


Test patch:
diff --git a/testing/update.test b/testing/update.test
index a0719e04..2bfbc40e 100755
--- a/testing/update.test
+++ b/testing/update.test
@@ -185,3 +185,11 @@ do_execsql_test_on_specific_db {:memory:} update_index_regression_test {
 1
 2
 2}
+
+do_execsql_test_on_specific_db {:memory:} update_where_or_regression_test {
+    CREATE TABLE t (a INTEGER);
+    INSERT INTO t VALUES (1), ('hi');
+    UPDATE t SET a = X'6C6F76656C795F7265766F6C74' WHERE ~ 'gorgeous_thropy' OR NOT -3830873834.233324;  
+    SELECT * from t;
+} {lovely_revolt
+lovely_revolt}