From 04c590f5a6bb6411c5dbf78cf2ff02a295e6b634 Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Thu, 12 Jun 2025 12:36:53 +0300 Subject: [PATCH] Add comment about re-entrancy of op_idx_insert() --- core/vdbe/execute.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/vdbe/execute.rs b/core/vdbe/execute.rs index 50b8befa7..fc8da4cc8 100644 --- a/core/vdbe/execute.rs +++ b/core/vdbe/execute.rs @@ -4077,6 +4077,11 @@ pub fn op_idx_insert( // a) nothing, or // b) the first entry greater than the key we are inserting. // In both cases, we can insert the new entry without moving again. + // + // This is re-entrant, because once we call cursor.insert() with moved_before=true, + // we will immediately set BTreeCursor::state to CursorState::Write(WriteInfo::new()), + // in BTreeCursor::insert_into_page; thus, if this function is called again, + // moved_before will again be true due to cursor.is_write_in_progress() returning true. true } else { flags.has(IdxInsertFlags::USE_SEEK)