From 9aebfa7b5d5d400b7d27d29b1f7b50a4850cc440 Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Tue, 29 Apr 2025 14:50:41 -0300 Subject: [PATCH] open cursors for write only once --- core/translate/emitter.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/translate/emitter.rs b/core/translate/emitter.rs index b1f98959e..19d018689 100644 --- a/core/translate/emitter.rs +++ b/core/translate/emitter.rs @@ -688,6 +688,23 @@ fn emit_update_insns( }) .collect::>(); + let open_indices_label = program.allocate_label(); + // Open all cursors Once + program.emit_insn(Insn::Once { + target_pc_when_reentered: open_indices_label, + }); + + // Open all the index btrees for writing + for idx_cursor in idx_cursors.iter() { + program.emit_insn(Insn::OpenWrite { + cursor_id: idx_cursor.2, + root_page: idx_cursor.1.into(), + name: idx_cursor.0.clone(), + }); + } + + program.resolve_label(open_indices_label, program.offset()); + for cond in plan .where_clause .iter()