Assertion `pRec->nField>0 && pRec->nField<=pIdx->nSampleCol' failed.
(1) By Jinsheng Ba (bajinsheng) on 2022-07-15 02:52:03 [source]
CREATE TABLE t0 (c0 INT, c1 INT PRIMARY KEY ) WITHOUT ROWID; INSERT INTO t0(c0, c1) VALUES (NULL, 1); ANALYZE; SELECT * FROM t0 WHERE (t0.c1, t0.c0) BETWEEN ('1', t0.c1 IN ()) AND (t0.c0, t0.c1); -- sqlite3: sqlite3.c:155385: whereKeyStats: Assertion `pRec->nField>0 && pRec->nField<=pIdx->nSampleCol' failed.
Version: 3.40.0 (Unreleased)
Commit ID: b6522565
(2) By Richard Hipp (drh) on 2022-07-15 12:59:59 in reply to 1 [link] [source]
This bug goes back almost 8 years to check-in ddb5f0558c445699 on 2016-09-07, version 3.15.0. On the other hand, the problem only comes up if you cmpile with -DSQLITE_ENABLE_STAT4. The STAT4 requirement means that most applications are unaffected by this problem.
The bug is now fixed on trunk and on branch-3.39.
Here is a slightly simplified alternative test case:
CREATE TABLE t1(a INT, b INT PRIMARY KEY) WITHOUT ROWID; INSERT INTO t1(a, b) VALUES (0, 1),(15,-7),(3,100); ANALYZE; SELECT * FROM t1 WHERE (b,a) BETWEEN (0,5) AND (99,-2);