SQLite Forum

Bug report: Complex CTE generates segmentation fault depending on the order of joined tables in its body
Login
Maybe it might be a good idea to add a `SQLITE_INDEX_SCAN_NO_MATERIALIZE` flag to force it to not materialize the table (in case the data is infinite or otherwise way too big, or possibly other reasons that I don't know)? (In this case, if the query specifies a `ORDER BY` clause that cannot be consumed by the virtual table, then it is an error.)

Trying to force it to do certain things (rather than only suggesting them) by setting the estimated cost seems like klugy to me. (Also is klugy to force it to reject the query plan by setting the cost, but this has already been fixed; now you can return `SQLITE_CONSTRAINT` to force it to reject the query plan, which is better.)