5 Commits

Author SHA1 Message Date
Claude
6bcb8e6def sqltest: add a postgres backend that runs tests on a real PostgreSQL server
The PostgreSQL corpus must expect only what PostgreSQL itself does, but
until now it ran only against tursopg. An expectation that only tursopg
meets passed CI, and nothing showed that it was wrong.

`--backend postgres --postgres-dsn <url>` runs the tests on the server at
the URL. For each test, the backend creates a new database from
template0 and drops it after the test, so tests stay isolated when they
run in parallel. At most four CREATE DATABASE and DROP DATABASE
statements run at the same time, so a run uses at most --jobs + 4
connections. A random part in the database names lets two runs share
one server.

`@skip-if postgres "reason"` and `@skip-file-if postgres "reason"` skip
tests of Turso-specific behavior on this backend. `postgres` is parsed
from an identifier, not a keyword token, so `@backend postgres` and
names such as `setup postgres` still parse.

Tests: parser and runner unit tests for the skip condition, and the
pg-sqltests corpus against PostgreSQL 17

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R3hzXhfjBgyLPUF7vd3PHW
2026-10-15 03:04:08 +00:00
Claude
a6cc01b42c sqltest: rename the pg backend to tursopg
The pg backend runs the PostgreSQL corpus against tursopg. The next
change adds a backend that runs the same corpus against a real
PostgreSQL server, and "pg" can mean either server. Name the backend
after the server that it starts.

`--backend pg` becomes `--backend tursopg`, and `@backend pg` and
`expect @pg` become `@backend tursopg` and `expect @tursopg`. No corpus
file used the old name. The CI job is now "Run SQL tests (tursopg
backend)".

Tests: test_parse_tursopg_backend, make -C postgres/conformance run

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R3hzXhfjBgyLPUF7vd3PHW
2026-10-15 03:04:07 +00:00
Jussi Saurio
d91a4bd837 test: snapshot parenthesized join bytecode
Compare generated bytecode for top-level groups, correlated result expressions, implicit rowids, and unread LEFT JOIN source columns.
2026-10-06 04:22:08 +03:00
Jussi Saurio
3b7441c338 testing/sqltest: add matrix test cases verified against a bundled SQLite oracle
A matrix block expands one SQL template over the cross-product of @var
decorators, generating an individual named case per combination:

    @var mode { ROWS | GROUPS | RANGE }
    @var end { CURRENT ROW | UNBOUNDED FOLLOWING }
    matrix frame-sums {
        SELECT sum(k) OVER (ORDER BY k $mode BETWEEN UNBOUNDED PRECEDING
            AND $end) FROM t;
    }

Cross-product spaces (frame clauses, affinities, collations) need dozens
to hundreds of structurally identical cases; writing them by hand caps
coverage at what someone is willing to type.

Matrix cases carry no expectations. Every expansion runs its setups and
statement against an in-process bundled SQLite (rusqlite) alongside
Turso, and the assertion is agreement: identical rows in order, or both
engines rejecting the statement. Results over fixed data have one
correct answer — SQLite's — so there is nothing to snapshot: storing
expected outputs would only pin engine-at-blessing-time behavior and
invite re-blessing over a regression. Both engines' values render
through the Rust backend's value formatting (including %!.15g for
reals), so the comparison is typed-value-exact and float text
differences cannot false-fail. The oracle's SQLite version is pinned by
Cargo.lock; upgrading it is a deliberate, reviewable event.

Expansions are ordinary parallel runnables: named
matrix[slug][slug]..., filterable with --filter, full decorator
support, Rust backend only (the shared formatter is that backend's).
Parse-time validation covers undeclared/unused/empty variables,
single-statement templates, name uniqueness and a 20k expansion cap.

Tests: parser, expansion and oracle unit tests; first corpus user is
the window frame matrix (738 expansions).
2026-07-31 16:02:42 +03:00
Pekka Enberg
629a492e60 testing: rename sqltests runner to sqltest
With the .sqltest corpora relocated to sqlite/conformance, the
testing/sqltests directory holds only the runner crate, so the plural
name no longer fits. Rename the directory to testing/sqltest and the
crate and binary from the generic test-runner to sqltest, matching the
DSL and file extension the tool is named after.

Update the workspace manifest, the conformance Makefile, the runner
docs, and the JS backend references accordingly. The root Makefile
targets follow suit: test-runner{,-js,-cli} become
test-sqltest{,-js,-cli}; nothing outside the aggregate test target
invokes them.

Tests: cargo test -p sqltest, make -C sqlite/conformance check
2026-07-19 10:00:20 +03:00