An infinite recursion exception
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.