From 6c0c4d77d066cd41e22f0808f50871b1fbf27dd3 Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Thu, 21 Aug 2025 14:58:12 +0300 Subject: [PATCH] Fix UPDATE inserting NULL into index instead of rowid --- core/translate/emitter.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/translate/emitter.rs b/core/translate/emitter.rs index e2498f121..7f8284e26 100644 --- a/core/translate/emitter.rs +++ b/core/translate/emitter.rs @@ -1000,10 +1000,17 @@ fn emit_update_insns( // copy each index column from the table's column registers into these scratch regs for (i, col) in index.columns.iter().enumerate() { + let col_in_table = table_ref + .columns() + .get(col.pos_in_table) + .expect("column index out of bounds"); // copy from the table's column register over to the index's scratch register - program.emit_insn(Insn::Copy { - src_reg: idx_cols_start_reg + col.pos_in_table, + src_reg: if col_in_table.is_rowid_alias { + rowid_reg + } else { + idx_cols_start_reg + col.pos_in_table + }, dst_reg: idx_start_reg + i, extra_amount: 0, });