Merge 'Add snapshot tests for multi-index with intersection' from Mikaël Francoeur

We didn't have a snapshot test that checked multi-index with an AND
condition.

Closes #8478
This commit is contained in:
Pekka Enberg
2026-08-25 17:54:08 +03:00
committed by GitHub
3 changed files with 93 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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)