{"record":{"id":"fbfa2f9393df0871","repo":"tursodatabase/turso","slug":"unexpected-cursor-type","errorCode":null,"errorMessage":"unexpected cursor type","messagePattern":"unexpected cursor type","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/vdbe/execute.rs","lineNumber":2029,"sourceCode":"            op_column_range_fetch(program, state, *cursor_id, *start_column, *dest, defaults)?;\n        if matches!(result, InsnFunctionStepResult::Step) {\n            state.pc += 1;\n        }\n        return Ok(result);\n    }\n    op_column_deferred(\n        program,\n        state,\n        *cursor_id,\n        ColumnFetch::Range {\n            start_column: *start_column,\n            dest: *dest,\n            defaults,\n        },\n    )\n}\n\n/// What a Column-family instruction fetches once the cursor is positioned.\n#[derive(Clone, Copy)]\nenum ColumnFetch<'a> {\n    /// A single column.\n    Single {\n        column: usize,\n        dest: usize,\n        default: &'a Option<Value>,\n    },\n    /// A range of consecutive columns to be copied to consecutive destination registers.\n    Range {\n        start_column: usize,\n        dest: usize,\n        defaults: &'a [Option<Value>],\n    },\n}\n\nimpl ColumnFetch<'_> {\n    /// Writes NULL to every destination register of this fetch.","sourceCodeStart":2011,"sourceCodeEnd":2047,"githubUrl":"https://github.com/tursodatabase/turso/blob/8d4a589f8d13ac184700d2a8f724f27e1995be3b/core/vdbe/execute.rs#L2011-L2047","documentation":"Inside op_column's resumable state machine, the Rowid state reads the current rowid from the index cursor before seeking the paired table cursor. The panic fires when that cursor is neither Cursor::BTree nor Cursor::IndexMethod at runtime — the bytecode arranged a rowid fetch through a cursor kind that cannot supply one (sorter, pseudo, virtual table). An internal program inconsistency hit mid-execution.","triggerScenarios":"Column-extraction plans that pair an index cursor with a table cursor (index scan then row lookup) where the index slot actually holds a sorter/pseudo/vtab cursor — typically after cursor renumbering, or when index-method cursors are mis-tagged in the plan.","commonSituations":"Plan flips between covering-index and table-lookup access paths; custom index-method features; engine upgrades changing index cursor handling.","solutions":["Report with SQL and EXPLAIN — the index-cursor slot holds an incompatible kind at runtime","Force a different plan (drop/disable the index or use NOT INDEXED) so the paired-cursor path is not used","Rewrite the index-driven lookup as a join to change the access path","Upgrade"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// before entering the paired index/table column path, verify the index slot kind\nif !matches!(\n    program.cursor_ref.get(index_cursor_id).map(|(_, t)| t),\n    Some(CursorType::BTreeIndex(_)) | Some(CursorType::IndexMethod(..))\n) {\n    crate::bail_parse_error!(\"index cursor {index_cursor_id} cannot supply a rowid\");\n}","typeGuard":"fn rowid_capable(t: &CursorType) -> bool {\n    matches!(t, CursorType::BTreeIndex(_) | CursorType::IndexMethod(..))\n}","tryCatchPattern":null,"preventionTips":["Cover covering-index vs table-lookup plan switches in conformance tests","If using custom index methods, test them through the paired-cursor column path","Report reproducible cases with EXPLAIN output"],"tags":["vdbe","executor","op-column","cursor-type","rowid","panic","runtime"],"backgroundTag":"cursor-type-mismatch","analyzedSha":"8d4a589f8d13ac184700d2a8f724f27e1995be3b","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}