Commit f9dfc3c
feat(vdbe): seek an N-table left-deep chain of ipk joins with live cursors (B5b-2d)
Generalizes the live inner-cursor seek (B5b-2a/b/c) from a single join to a
bounded left-deep chain: the leftmost source is scanned, then each of up to
three joined tables is fetched by seeking its INTEGER PRIMARY KEY to a value
already assembled in the running prefix. This covers both a "star"
(`… JOIN t ON o.x=t.id JOIN u ON o.z=u.uid`, both seeks keyed off the outer) and
a "chain" (`… JOIN u ON t.id=u.uid`, the second seek keyed off the first seeked
inner). The single-join block became a fold over the joins that grows the
combined schema and re-seeks per prefix row.
Each seek is a unique rowid seek followed by a full re-check of that join's `ON`,
so the superset invariant holds per join and composes by induction over the fold
— the whole chain is affinity-safe (same `to_i64` coercion, no new comparison
semantics). A 2+ chain must be all INNER (a single join may still be LEFT); a
fourth join, a non-ipk join, RIGHT/FULL, LEFT inside a chain, or a comma-join in
the mix falls through to the materialized path, so correctness cannot regress.
Verified VDBE-vs-tree-walker and vs sqlite3 3.50.4 (`tests/vdbe_live_cursor.rs`).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 5ef9bb4 commit f9dfc3c
3 files changed
Lines changed: 290 additions & 202 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1201 | 1201 | | |
1202 | 1202 | | |
1203 | 1203 | | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
1204 | 1213 | | |
1205 | 1214 | | |
1206 | 1215 | | |
1207 | 1216 | | |
1208 | 1217 | | |
1209 | 1218 | | |
1210 | 1219 | | |
1211 | | - | |
| 1220 | + | |
| 1221 | + | |
1212 | 1222 | | |
1213 | 1223 | | |
1214 | 1224 | | |
| |||
0 commit comments