Assertion failure in agginfoPersistExprCb function
(1) By Song Liu (songliu) on 2023-03-28 12:55:01 [source]
I found an assertion failure while SQLite (latest, c8bedef0d61731c2) executes the following queries.
CREATE TABLE v0 (c1);
CREATE INDEX i ON v0 (c1, c1=1);
SELECT 0 FROM v0 AS a1 WHERE (SELECT count((SELECT(sum(0) OVER(PARTITION BY(c1), (a1.c1=1) )))) FROM v0 GROUP BY hex(0)) AND a1.c1=0;
Here are the outputs:
sqlite3: sqlite3.c:112197: agginfoPersistExprCb: Assertion `iAgg>=0 && iAgg<pAggInfo->nColumn' failed.
[1] 2383683 abort ./sqlite3 < poc
Here is the result of bisecting:
13 BAD 2022-11-25 16:10:48 b9190d3da70c4171 CURRENT
11 GOOD 2022-11-25 15:52:00 1ad41840c5e0fa70
The assertion failure may be caused by the optimizations. SQLite crashes by default with all optimizations enabled. If I disable the SQLITE_IndexedExpr optimization, SQLite works well.
CREATE TABLE v0 (c1);
CREATE INDEX i ON v0 (c1, c1=1);
.testctrl optimizations 0x01000000;
.print '-- disable optimization of SQLITE_IndexedExpr'
SELECT 0 FROM v0 AS a1 WHERE (SELECT count((SELECT(sum(0) OVER(PARTITION BY(c1), (a1.c1=1) )))) FROM v0 GROUP BY hex(0)) AND a1.c1=0;
My compilation flags:
export CFLAGS="-g -O0 -DSQLITE_DEBUG
-DSQLITE_ENABLE_TREETRACE
-DSQLITE_ENABLE_WHERETRACE
-DSQLITE_ENABLE_CURSOR_HINTS
-DSQLITE_COUNTOFVIEW_OPTIMIZATION
-DSQLITE_ENABLE_STAT4"
(2) By Song Liu (songliu) on 2023-03-28 16:08:18 in reply to 1 [link] [source]
It seems the bug is fixed at commit c34fd9fe1b76e0a5. Thanks for your work!