When SQLite processes a SELECT statement for which the FROM clause contains a
single sub-select that is not eligible for the flattening optimization, it
creates a co-routine that returns one row each time it is invoked to
implement the sub-select.

Because of the way the SQL compiler works, the VerifyCookie routine is
currently being invoked the first time the co-routine is invoked, not by the
start of the main routine. If the main routine attempts to access the database
before the co-routine is invoked, then it is an error. This may occur if either
the LIMIT or the OFFSET expression of the main SELECT are themselves
sub-selects that access the database. For example: