SQLite Forum

An infinite recursive exception
Login

An infinite recursion exception

(1.1) By Wang Ke (krking) on 2021-06-23 09:36:25 edited from 1.0 [source]

Hello developers,

We found a test case which causes an infinite recursion exception:

CREATE TABLE t1(a);
SELECT substr(a,4,lag(a,7) OVER(PARTITION BY 'cf23' ORDER BY 2)) AS ca0 FROM t1 ORDER BY ca0; -- expected: empty
SELECT substr(a,4,lag(a,7) OVER(PARTITION BY 'cf23' ORDER BY likely(2))) AS ca0 FROM t1 ORDER BY ca0; -- unexpected: Error: Expression tree is too large (maximum depth 1000)

The difference between the first and the second query is only a function likely().

The height of the first query is 4, but the second query results in infinite recursion, constantly calling the function sqlite3Select() until the exception is found by the function sqlite3ExprCheckHeight().

Besides, bisecting shows that the problem maybe first appear in check-in 57070c68bb.

(2) By Dan Kennedy (dan) on 2021-06-23 11:14:20 in reply to 1.1 [link] [source]

Thanks for this! Now fixed here:

https://sqlite.org/src/info/710f75b98bb4ac5b

Dan.