Commit Graph

4 Commits

Author SHA1 Message Date
Claude
c4ff6b5fdd postgres/conformance: run the pg-sqltests on PostgreSQL in CI
`make -C postgres/conformance run-postgres` runs the corpus with the
postgres backend. It uses the server at PG_DSN. If PG_DSN is not set,
with-postgres.sh starts a throwaway PostgreSQL container with Docker and
gives it a role that has CREATEDB and is not a superuser. A new CI job,
"Run SQL tests (PostgreSQL)", runs the target.

The container keeps its data on tmpfs and runs with fsync,
synchronous_commit, full_page_writes, autovacuum and JIT off, and with
wal_level=minimal. These settings do not change query results. The
target runs two tests per CPU, because a test often waits for the
server. With the LATERAL tests of #9468, 848 tests take about 6 s on 4
CPUs, against about 60 s with the default settings.

The PostgreSQL version is one line in with-postgres.sh, and
POSTGRES_VERSION changes it for one run. The image comes from
mirror.gcr.io, because Docker Hub limits the pull rate of anonymous
clients.

40 of the 187 tests failed on PostgreSQL 17. They check Turso-specific
behavior: the EXPLAIN output, the catalogs that Turso keeps empty, and
the error for a write to a catalog table. Three of them fail because
Turso has the ACLs of PostgreSQL 16, without the MAINTAIN privilege of
PostgreSQL 17. Mark them with @skip-if postgres, with a reason that
tells what PostgreSQL does.

Tests: make -C postgres/conformance run-postgres, which failed 40 tests
before the skips; 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: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
Pekka Enberg
35bbb3b3e2 postgres/conformance: gate the upstream corpus with pass/fail statuses
run.py previously reported a raw pass count and always exited nonzero
while any test failed, so it could neither gate CI nor notice change in
either direction: a regression in the one passing test and a known-bad
test silently going green both looked the same as the status quo.

Now every corpus test is listed in a STATUS table in run.py, mirroring
the sqlite/conformance upstream runner: "pass" tests are blessed and
any output divergence fails the run; "fail" tests run with their diffs
reported but tolerated, and going byte-exact fails the run with a
request to bless them, so the known-bad list only ever shrinks; "skip"
is reserved for tests that cannot run (currently none, since crash and
wedge containment lets even the server-killing tests run). A validation
pass cross-checks STATUS against the schedule in both directions so a
corpus edit cannot drop a test out of the ratchet. Exit code 0 means
every test matched its status.

Also adds a `make -C postgres/conformance run-upstream` target and
documents the bless workflow in the corpus README. Only `comments` is
blessed today.

Tests: full-corpus run exits 0 with "1 blessed ok, 102 known-bad
failure(s), 0 regression(s), 0 unexpected pass(es)"; regression and
XPASS paths verified with a temporarily modified STATUS copy (both
exit 1 with the corresponding message).
2026-08-05 17:20:57 +03:00
Pekka Enberg
3127415af9 postgres: add sqltest pg backend and conformance corpus
Give the PostgreSQL frontend the same hand-written .sqltest coverage the
sqlite dialect has under sqlite/conformance. The upstream regression
harness (pg-regress branch) replays pristine psql transcripts; this
corpus instead asserts structural expectations through the sqltest DSL,
and only encodes behavior real PostgreSQL also exhibits so the corpus
stays valid for future differential runs against a stock server.

The new turso_pg_client crate is a minimal synchronous wire-protocol
client (startup handshake, simple query, row/error decoding) shared
between test tools; the upstream regression runner can adopt it when it
lands. Because the client speaks TCP to a spawned tursopg binary, the
sqltest runner gains no dependency on the pg frontend crates.

The pg backend spawns one tursopg server per database instance on an
ephemeral port and drives it over a single connection, so results
reflect the server's own wire encoding (e.g. boolean columns as t/f)
rather than a rendering the runner would have to reimplement. Whole
test blocks are sent as one simple-query message, which keeps
sqlite-dialect statement splitting out of the pg path. Wire I/O runs on
the blocking pool; a connection is discarded after a timeout since its
protocol state is indeterminate mid-stream.

The postgres/conformance Makefile honors CARGO_TARGET_DIR when locating
the tursopg binary. CI runs the corpus in a new sqltest-run-pg job and
syntax-checks it in sqltest-check.

Tests: make -C postgres/conformance run (28 tests), cargo test -p
turso_pg_client -p sqltest, make -C sqlite/conformance check
2026-07-21 07:43:48 +03:00