SQLite Forum

Unexpected Assertion Error in valueFromFunction
Login

Unexpected Assertion Error in valueFromFunction

(1) By Jinsheng Ba (bajinsheng) on 2022-06-25 00:48:06 [source]

Here is another assertion error:

CREATE TABLE t0(c0 PRIMARY KEY);
INSERT INTO t0 VALUES(1);
ANALYZE;
SELECT *FROM t0 WHERE(c0) BETWEEN(json('')) AND 0; --sqlite3: sqlite3.c:80168: valueFromFunction: Assertion `pCtx->pParse->rc==SQLITE_OK' failed.

Note that the assertion error manifests when STAT4 is enabled.

Environment:

Version: 3.39.0 (Unreleased)

Commit ID: e93fd170

(2.1) Originally by Jinsheng Ba (bajinsheng) with edits by Richard Hipp (drh) on 2022-06-25 02:40:58 from 2.0 in reply to 1 [link] [source]

It is the reproducible test case for the previous thread: https://sqlite.org/forum/forumpost/3326fadbf3

Sorry for creating duplicate threads.

(3) By Richard Hipp (drh) on 2022-06-25 02:45:03 in reply to 1 [link] [source]

Thank you for the bug report.

This is another harmless assert(). Nothing bad happens (there are no memory errors nor incorrect answers) if this assert() is simply removed. And that is the case for production builds. So even though this problem has been in the code since 2015-09-11, it should not affect any applications.

The fix in check-in cd6254fcd32798f7 is to change the assert() macro into a testcase() macro. The assert() macro was saying "This never happens", which turns out to be false. The new testcase() macro is saying "There exists a case where this does happen". And coverage testing tools verify that we run at least one test case where it does in fact happen.