The following query hits an assert() in the byte-code engine, or if assert()s
are disabled, goes into an endless loop in the byte code.
CREATE TABLE t1(id, b, c);
INSERT INTO t1 VALUES(1, 'A', 'one');
INSERT INTO t1 VALUES(2, 'B', 'two');
INSERT INTO t1 VALUES(3, 'C', 'three');
INSERT INTO t1 VALUES(4, 'D', 'one');
INSERT INTO t1 VALUES(5, 'E', 'two');
SELECT id, b, lead(c,1) OVER(ORDER BY c) AS x FROM t1 WHERE id>1 ORDER BY b LIMIT 1;
This problem appears to have been introduced by check-in
[206720129ed2fa8875a2] which was a fix for ticket
[9936b2fa443fec03ff25] which was the previous problem of an
endless loop due to the ORDER BY LIMIT optimization.