From 5ba87d7b1b32983f777840523e0798e4c9fe7867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Francoeur?= Date: Sun, 23 Aug 2026 20:17:36 -0400 Subject: [PATCH 1/2] add snapshot tests for multi-index with intersection --- .../multi_index_intersection.sqltest | 36 +++++++++++++++ ...i_index_intersection__multi_index_and.snap | 44 +++++++++++++++++++ ...dex_intersection__multi_index_and_eqp.snap | 13 ++++++ 3 files changed, 93 insertions(+) create mode 100644 sqlite/conformance/sqlite-sqltests/snapshots/multi_index_intersection__multi_index_and.snap create mode 100644 sqlite/conformance/sqlite-sqltests/snapshots/multi_index_intersection__multi_index_and_eqp.snap diff --git a/sqlite/conformance/sqlite-sqltests/multi_index_intersection.sqltest b/sqlite/conformance/sqlite-sqltests/multi_index_intersection.sqltest index 242f99015..45f2834ed 100644 --- a/sqlite/conformance/sqlite-sqltests/multi_index_intersection.sqltest +++ b/sqlite/conformance/sqlite-sqltests/multi_index_intersection.sqltest @@ -139,3 +139,39 @@ expect { snapshot-eqp composite-index-preferred-over-intersection-eqp { SELECT id FROM t WHERE a = 10 AND b = 100; } + +setup multi_index_and_setup { + CREATE TABLE t( + a, b, + c0, c1, c2, c3, c4, c5, c6, c7, c8 + ); + + CREATE INDEX ia ON t(a); + CREATE INDEX ib ON t(b); + + WITH RECURSIVE n(x) AS ( + VALUES(0) + UNION ALL + SELECT x + 1 FROM n WHERE x < 9999 + ) + INSERT INTO t + SELECT + x % 10, + (x / 10) % 10, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL + FROM n; + + ANALYZE; +} + +@setup multi_index_and_setup +@skip-if mvcc "root page numbers are negative under mvcc" +snapshot-eqp multi_index_and_eqp { + SELECT * FROM t WHERE a = 1 AND b = 2; +} + +@skip-if mvcc "root page numbers are negative under mvcc" +@setup multi_index_and_setup +snapshot multi_index_and { + SELECT * FROM t WHERE a = 1 AND b = 2; +} \ No newline at end of file diff --git a/sqlite/conformance/sqlite-sqltests/snapshots/multi_index_intersection__multi_index_and.snap b/sqlite/conformance/sqlite-sqltests/snapshots/multi_index_intersection__multi_index_and.snap new file mode 100644 index 000000000..16e6a77f7 --- /dev/null +++ b/sqlite/conformance/sqlite-sqltests/snapshots/multi_index_intersection__multi_index_and.snap @@ -0,0 +1,44 @@ +--- +source: multi_index_intersection.sqltest +expression: SELECT * FROM t WHERE a = 1 AND b = 2; +info: + statement_type: SELECT + tables: + - t + setup_blocks: + - multi_index_and_setup + database: ':memory:' +--- +QUERY PLAN +`--MULTI-INDEX AND t (ia, ib) + +BYTECODE +addr opcode p1 p2 p3 p4 p5 comment + 0 Init 0 26 0 0 Start at 26 + 1 OpenRead 0 -2 0 k(12,B,B,B,B,B,B,B,B,B,B,B) 0 table=t, root=-2, iDb=0 + 2 OpenRead 1 -3 0 k(2,B) 0 index=ia, root=-3, iDb=0 + 3 OpenRead 2 -4 0 k(2,B) 0 index=ib, root=-4, iDb=0 + 4 Null 0 13 0 0 r[13]=NULL + 5 Null 0 14 0 0 r[14]=NULL + 6 Integer 1 15 0 0 r[15]=1 + 7 SeekGE 1 12 15 0 key=[15..15] + 8 IdxGT 1 12 15 0 key=[15..15] + 9 IdxRowId 1 12 0 0 r[12]=cursor 1 for index ia.rowid + 10 RowSetAdd 13 12 0 0 + 11 Next 1 8 0 0 + 12 Integer 2 16 0 0 r[16]=2 + 13 SeekGE 2 20 16 0 key=[16..16] + 14 IdxGT 2 20 16 0 key=[16..16] + 15 IdxRowId 2 12 0 0 r[12]=cursor 2 for index ib.rowid + 16 RowSetTest 13 18 12 -1 0 + 17 Goto 0 19 0 0 + 18 RowSetAdd 14 12 0 0 + 19 Next 2 14 0 0 + 20 RowSetRead 14 25 12 0 + 21 SeekRowid 0 12 22 0 if (r[12]!=cursor 0 for table t.rowid) goto 22 + 22 ColumnRange 0 0 1 11 0 r[1..11]=t.a..c8 + 23 ResultRow 1 11 0 0 output=r[1..11] + 24 Goto 0 20 0 0 + 25 Halt 0 0 0 0 + 26 Transaction 0 1 4 0 iDb=0 tx_mode=Read + 27 Goto 0 1 0 0 diff --git a/sqlite/conformance/sqlite-sqltests/snapshots/multi_index_intersection__multi_index_and_eqp.snap b/sqlite/conformance/sqlite-sqltests/snapshots/multi_index_intersection__multi_index_and_eqp.snap new file mode 100644 index 000000000..2aa725556 --- /dev/null +++ b/sqlite/conformance/sqlite-sqltests/snapshots/multi_index_intersection__multi_index_and_eqp.snap @@ -0,0 +1,13 @@ +--- +source: multi_index_intersection.sqltest +expression: SELECT * FROM t WHERE a = 1 AND b = 2; +info: + statement_type: SELECT + tables: + - t + setup_blocks: + - multi_index_and_setup + database: ':memory:' +--- +QUERY PLAN +`--MULTI-INDEX AND t (ia, ib) From 0ae9196ca2a22ad0f6ddd025c28f110cb89c7142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Francoeur?= Date: Mon, 24 Aug 2026 09:19:38 -0400 Subject: [PATCH 2/2] add snapshot tests for multi-index with intersection --- .../multi_index_intersection__multi_index_and.snap | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sqlite/conformance/sqlite-sqltests/snapshots/multi_index_intersection__multi_index_and.snap b/sqlite/conformance/sqlite-sqltests/snapshots/multi_index_intersection__multi_index_and.snap index 16e6a77f7..aafc084b0 100644 --- a/sqlite/conformance/sqlite-sqltests/snapshots/multi_index_intersection__multi_index_and.snap +++ b/sqlite/conformance/sqlite-sqltests/snapshots/multi_index_intersection__multi_index_and.snap @@ -15,9 +15,9 @@ QUERY PLAN BYTECODE addr opcode p1 p2 p3 p4 p5 comment 0 Init 0 26 0 0 Start at 26 - 1 OpenRead 0 -2 0 k(12,B,B,B,B,B,B,B,B,B,B,B) 0 table=t, root=-2, iDb=0 - 2 OpenRead 1 -3 0 k(2,B) 0 index=ia, root=-3, iDb=0 - 3 OpenRead 2 -4 0 k(2,B) 0 index=ib, root=-4, iDb=0 + 1 OpenRead 0 2 0 k(12,B,B,B,B,B,B,B,B,B,B,B) 0 table=t, root=2, iDb=0 + 2 OpenRead 1 3 0 k(2,B) 0 index=ia, root=3, iDb=0 + 3 OpenRead 2 4 0 k(2,B) 0 index=ib, root=4, iDb=0 4 Null 0 13 0 0 r[13]=NULL 5 Null 0 14 0 0 r[14]=NULL 6 Integer 1 15 0 0 r[15]=1