Files
turso/sqlite/parser
roboturso 0f27dd6f76 sqlite/parser: match SQLite error for ORDER BY before compound operator
When an ORDER BY or LIMIT clause appears before a compound operator,
as in `SELECT 1 ORDER BY 1 UNION SELECT 2`, the parser stopped the
compound-select loop at the clause and then failed on the leftover
operator token with a generic `near "UNION": syntax error`. SQLite
instead reports `ORDER BY clause should come after UNION not before`,
so error-message compatibility tests failed.

After parsing a select's ORDER BY and LIMIT clauses, peek at the next
token: a compound operator there can only mean one of those clauses cut
the compound-select loop short, so report SQLite's message instead.
As in SQLite, ORDER BY takes precedence over LIMIT when both are
present and UNION ALL is named in full.

This removed the last failures in the upstream conformance files
selectE.test and subquery2.test, so promote both from "fail" to "pass"
in sqlite/conformance/upstream/all.test.

Tests: sqlite-sqltests/compound-select-order-by-before-operator-error.sqltest,
tclsh sqlite/conformance/upstream/all.test (selectE and subquery2 now
blessed), cargo test in sqlite/parser, full sqltest corpus via
make -C sqlite/conformance run-rust.

Fixes #8201
2026-08-05 17:40:19 +03:00
..
…

TODO