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
This commit is contained in:
Claude
2026-10-14 19:01:45 +00:00
parent 6bcb8e6def
commit c4ff6b5fdd
8 changed files with 137 additions and 11 deletions

View File

@@ -37,7 +37,7 @@ jobs:
- name: Check pg test syntax - name: Check pg test syntax
run: make -C postgres/conformance check run: make -C postgres/conformance check
sqltest-run-cli: sqltest-cli:
name: Run SQL tests (CLI backend) name: Run SQL tests (CLI backend)
runs-on: blacksmith-4vcpu-ubuntu-2404 runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30 timeout-minutes: 30
@@ -57,7 +57,7 @@ jobs:
- name: Run tests (MVCC) - name: Run tests (MVCC)
run: make -C sqlite/conformance run-cli MVCC=1 run: make -C sqlite/conformance run-cli MVCC=1
sqltest-run-rust: sqltest-rust:
name: Run SQL tests (Rust backend) name: Run SQL tests (Rust backend)
runs-on: blacksmith-4vcpu-ubuntu-2404 runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30 timeout-minutes: 30
@@ -74,7 +74,7 @@ jobs:
- name: Run tests (MVCC) - name: Run tests (MVCC)
run: make -C sqlite/conformance run-rust MVCC=1 run: make -C sqlite/conformance run-rust MVCC=1
sqltest-run-js: sqltest-js:
name: Run SQL tests (JS backend, ${{ matrix.mode }}) name: Run SQL tests (JS backend, ${{ matrix.mode }})
runs-on: blacksmith-4vcpu-ubuntu-2404 runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30 timeout-minutes: 30
@@ -123,7 +123,7 @@ jobs:
working-directory: sqlite/conformance working-directory: sqlite/conformance
run: make run-js MVCC=1 run: make run-js MVCC=1
sqltest-run-tursopg: sqltest-tursopg:
name: Run SQL tests (tursopg backend) name: Run SQL tests (tursopg backend)
runs-on: blacksmith-4vcpu-ubuntu-2404 runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30 timeout-minutes: 30
@@ -140,6 +140,21 @@ jobs:
- name: Run tests - name: Run tests
run: make -C postgres/conformance run run: make -C postgres/conformance run
sqltest-postgres:
name: Run SQL tests (PostgreSQL)
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: useblacksmith/rust-cache@v3
with:
prefix-key: "v1-rust"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Build test runner
run: make -C postgres/conformance build-runner
- name: Run tests against PostgreSQL
run: make -C postgres/conformance run-postgres
sqltest-sqlite: sqltest-sqlite:
name: Run SQL tests (SQLite) name: Run SQL tests (SQLite)
runs-on: blacksmith-4vcpu-ubuntu-2404 runs-on: blacksmith-4vcpu-ubuntu-2404

View File

@@ -29,6 +29,7 @@ scripts/diff.sh "SQL" [label] # compare sqlite3 vs tursodb output
- `make test-single TEST=foo.test` - single legacy TCL test - `make test-single TEST=foo.test` - single legacy TCL test
- `make -C sqlite/conformance run-rust ARGS='--snapshot-filter __never__'` - preferred `.sqltest` runner for new coverage - `make -C sqlite/conformance run-rust ARGS='--snapshot-filter __never__'` - preferred `.sqltest` runner for new coverage
- `CI=1 make -C sqlite/conformance run-rust` - only when snapshot tests are required - `CI=1 make -C sqlite/conformance run-rust` - only when snapshot tests are required
- `make -C postgres/conformance run-postgres` - run the PostgreSQL `.sqltest` corpus against a real PostgreSQL server (needs Docker, or a server at `PG_DSN`)
### Test Organization ### Test Organization
@@ -37,7 +38,7 @@ Default: add coverage to the narrowest existing test harness that can express th
- `sqlite/conformance/sqlite-sqltests/` - preferred for SQL conformance coverage. These tests run the same scenario against both Turso and SQLite, so use them first for parser, planner, executor, and SQL semantics work that fits the `.sqltest` DSL. - `sqlite/conformance/sqlite-sqltests/` - preferred for SQL conformance coverage. These tests run the same scenario against both Turso and SQLite, so use them first for parser, planner, executor, and SQL semantics work that fits the `.sqltest` DSL.
- `tests/integration/` - primary fallback when the behavior cannot be expressed cleanly in `.sqltest`. Put API-level regressions, multi-connection orchestration, storage assertions, injected failures, timeout behavior, and other Rust-driven scenarios here. - `tests/integration/` - primary fallback when the behavior cannot be expressed cleanly in `.sqltest`. Put API-level regressions, multi-connection orchestration, storage assertions, injected failures, timeout behavior, and other Rust-driven scenarios here.
- `sqlite/conformance/upstream/` - imported upstream SQLite golden tests. Do not modify these for Turso behavior changes; use them as fixed compatibility coverage, and only touch them for intentional upstream sync or harness maintenance. - `sqlite/conformance/upstream/` - imported upstream SQLite golden tests. Do not modify these for Turso behavior changes; use them as fixed compatibility coverage, and only touch them for intentional upstream sync or harness maintenance.
- `postgres/conformance/pg-sqltests/` - `.sqltest` coverage for the PostgreSQL frontend, run via `make -C postgres/conformance run` (spawns a tursopg server per test and drives it over the wire protocol). Only assert behavior real PostgreSQL also exhibits, so the corpus stays valid for differential runs. - `postgres/conformance/pg-sqltests/` - `.sqltest` coverage for the PostgreSQL frontend.
- `testing/cli_tests/` - CLI-focused Python coverage for shell behavior and end-to-end command workflows. - `testing/cli_tests/` - CLI-focused Python coverage for shell behavior and end-to-end command workflows.
- `tests/fuzz/` - minimized fuzz regressions and targeted edge cases that are easier to keep as Rust tests. - `tests/fuzz/` - minimized fuzz regressions and targeted edge cases that are easier to keep as Rust tests.
- `testing/simulator/` and `testing/concurrent-simulator/` - deterministic concurrency, scheduling, and failure-injection coverage for state-machine and I/O correctness. - `testing/simulator/` and `testing/concurrent-simulator/` - deterministic concurrency, scheduling, and failure-injection coverage for state-machine and I/O correctness.

View File

@@ -6,13 +6,17 @@ queries through the `turso_core` engine. The goal is to behave like a real
PostgreSQL server, so most of the work is closing the gap between what real PostgreSQL server, so most of the work is closing the gap between what real
PostgreSQL does and what the front-end does today. PostgreSQL does and what the front-end does today.
Two things keep that work honest: Three things keep that work honest:
- **[`COMPAT.md`](COMPAT.md)** — feature-by-feature compatibility status, and - **[`COMPAT.md`](COMPAT.md)** — feature-by-feature compatibility status, and
where Turso intentionally diverges from PostgreSQL. where Turso intentionally diverges from PostgreSQL.
- **[`conformance/upstream/`](conformance/upstream/)** — regression tests - **[`conformance/upstream/`](conformance/upstream/)** — regression tests
imported verbatim from the PostgreSQL source tree, run against the front-end imported verbatim from the PostgreSQL source tree, run against the front-end
so divergence can't sneak in unnoticed. so divergence can't sneak in unnoticed.
- **[`conformance/pg-sqltests/`](conformance/pg-sqltests/)** — `.sqltest` tests
that CI runs against the front-end and against a real PostgreSQL server
(`make -C postgres/conformance run-postgres`). Tests of Turso-specific
behavior have `@skip-if postgres "reason"`.
## Verification workflow ## Verification workflow
@@ -21,7 +25,8 @@ When changing the parser, translator, or query behavior:
1. Check the relevant page of the PostgreSQL documentation. 1. Check the relevant page of the PostgreSQL documentation.
2. Confirm the behavior against a real PostgreSQL server. 2. Confirm the behavior against a real PostgreSQL server.
3. Encode the observed behavior in a test — an upstream regression script that 3. Encode the observed behavior in a test — an upstream regression script that
now passes, or a Rust test (see below) — so it can't regress. now passes, a `.sqltest` in `conformance/pg-sqltests/`, or a Rust test (see
below) — so it can't regress.
If Turso intentionally diverges from PostgreSQL, document that in If Turso intentionally diverges from PostgreSQL, document that in
[`COMPAT.md`](COMPAT.md). Pay particular attention to clauses that parse but [`COMPAT.md`](COMPAT.md). Pay particular attention to clauses that parse but

View File

@@ -1,8 +1,6 @@
# Turso PostgreSQL conformance test Makefile # Turso PostgreSQL conformance test Makefile
# #
# The .sqltest corpora live here; the sqltest runner crate lives in # The .sqltest corpora live here; the sqltest runner crate lives in testing/sqltest.
# testing/sqltest. The tursopg backend spawns a tursopg server per database
# instance and drives it over the PostgreSQL wire protocol.
# Paths # Paths
ROOT_DIR := $(shell cd ../.. && pwd) ROOT_DIR := $(shell cd ../.. && pwd)
@@ -25,7 +23,10 @@ SQLTEST := cargo run --manifest-path $(RUNNER_DIR)/Cargo.toml --bin sqltest $(CA
# Test corpora (relative to this directory) # Test corpora (relative to this directory)
PG_TESTS := pg-sqltests PG_TESTS := pg-sqltests
.PHONY: all build build-tursopg build-runner check run test run-one run-upstream clean # 2 * num_cpu (arbitrary multiplier)
POSTGRES_JOBS ?= $(shell expr 2 \* $$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 2))
.PHONY: all build build-tursopg build-runner check run test run-one run-postgres run-one-postgres run-upstream clean
# Build everything # Build everything
all: build all: build
@@ -56,6 +57,16 @@ test: run
run-one: build run-one: build
$(SQLTEST) run $(FILE) --backend tursopg --binary $(TURSOPG) $(SQLTEST) run $(FILE) --backend tursopg --binary $(TURSOPG)
# Run all tests against a real PostgreSQL server. Uses the server at PG_DSN,
# or starts a throwaway Docker container (see with-postgres.sh).
run-postgres: build-runner
./with-postgres.sh sh -c '$(SQLTEST) run $(PG_TESTS) --jobs $(POSTGRES_JOBS) --backend postgres --postgres-dsn "$$PG_DSN"'
# Run a single test file against a real PostgreSQL server:
# make run-one-postgres FILE=pg-sqltests/select.sqltest
run-one-postgres: build-runner
./with-postgres.sh sh -c '$(SQLTEST) run $(FILE) --jobs $(POSTGRES_JOBS) --backend postgres --postgres-dsn "$$PG_DSN"'
# Run the upstream PostgreSQL regress corpus with pass/fail statuses. # Run the upstream PostgreSQL regress corpus with pass/fail statuses.
# Exit 0 means every test matched its status in run.py's STATUS table; # Exit 0 means every test matched its status in run.py's STATUS table;
# regressions in blessed tests or unblessed new passes fail the run. # regressions in blessed tests or unblessed new passes fail the run.

View File

@@ -152,6 +152,7 @@ expect {
1|updated 1|updated
} }
@skip-if postgres "PostgreSQL fills pg_init_privs and pg_cast"
test pg-function-support-catalogs-are-empty { test pg-function-support-catalogs-are-empty {
SET search_path TO ''; SET search_path TO '';
SELECT * FROM pg_init_privs; SELECT * FROM pg_init_privs;
@@ -169,16 +170,19 @@ test pg-function-support-catalogs-are-empty {
} }
expect {} expect {}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-init-privs-is-read-only { test pg-init-privs-is-read-only {
DELETE FROM pg_init_privs; DELETE FROM pg_init_privs;
} }
expect error {cannot delete from pg_catalog table "pg_init_privs"} expect error {cannot delete from pg_catalog table "pg_init_privs"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-cast-is-read-only { test pg-cast-is-read-only {
DELETE FROM pg_cast; DELETE FROM pg_cast;
} }
expect error {cannot delete from pg_catalog table "pg_cast"} expect error {cannot delete from pg_catalog table "pg_cast"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-transform-is-read-only { test pg-transform-is-read-only {
DELETE FROM pg_transform; DELETE FROM pg_transform;
} }
@@ -195,6 +199,7 @@ expect {
pg_is_in_recovery|pg_catalog pg_is_in_recovery|pg_catalog
} }
@skip-if postgres "PostgreSQL also finds the functions of information_schema"
test pg-dump-function-discovery-excludes-builtins { test pg-dump-function-discovery-excludes-builtins {
SET search_path TO ''; SET search_path TO '';
SELECT p.tableoid, p.oid, p.proname, p.prolang, p.pronargs, p.proargtypes, SELECT p.tableoid, p.oid, p.proname, p.prolang, p.pronargs, p.proargtypes,
@@ -215,6 +220,7 @@ test pg-dump-function-discovery-excludes-builtins {
} }
expect {} expect {}
@skip-if postgres "PostgreSQL has six abs() functions, and pg_is_in_recovery() has the language internal"
test pg-object-native-function-languages { test pg-object-native-function-languages {
SET search_path TO ''; SET search_path TO '';
SELECT p.proname, l.lanname, CASE WHEN l.lanispl THEN 1 ELSE 0 END, l.tableoid SELECT p.proname, l.lanname, CASE WHEN l.lanispl THEN 1 ELSE 0 END, l.tableoid
@@ -226,6 +232,7 @@ expect {
pg_is_in_recovery|c|0|2612 pg_is_in_recovery|c|0|2612
} }
@skip-if postgres "PostgreSQL has the plpgsql language"
test pg-object-dump-language-discovery-is-empty { test pg-object-dump-language-discovery-is-empty {
SET search_path TO ''; SET search_path TO '';
SELECT tableoid, oid, lanname, lanpltrusted, lanplcallfoid, laninline, SELECT tableoid, oid, lanname, lanpltrusted, lanplcallfoid, laninline,
@@ -234,6 +241,7 @@ test pg-object-dump-language-discovery-is-empty {
} }
expect {} expect {}
@skip-if postgres "PostgreSQL fills these catalogs, and only a superuser can read pg_subscription"
test pg-object-unsupported-catalogs-are-empty { test pg-object-unsupported-catalogs-are-empty {
SET search_path TO ''; SET search_path TO '';
SELECT tableoid FROM pg_operator; SELECT tableoid FROM pg_operator;
@@ -301,86 +309,103 @@ test pg-object-unsupported-catalogs-are-empty {
} }
expect {} expect {}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-operator-is-read-only { test pg-object-operator-is-read-only {
DELETE FROM pg_operator; DELETE FROM pg_operator;
} }
expect error {cannot delete from pg_catalog table "pg_operator"} expect error {cannot delete from pg_catalog table "pg_operator"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-opclass-is-read-only { test pg-object-opclass-is-read-only {
DELETE FROM pg_opclass; DELETE FROM pg_opclass;
} }
expect error {cannot delete from pg_catalog table "pg_opclass"} expect error {cannot delete from pg_catalog table "pg_opclass"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-opfamily-is-read-only { test pg-object-opfamily-is-read-only {
DELETE FROM pg_opfamily; DELETE FROM pg_opfamily;
} }
expect error {cannot delete from pg_catalog table "pg_opfamily"} expect error {cannot delete from pg_catalog table "pg_opfamily"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-ts-parser-is-read-only { test pg-object-ts-parser-is-read-only {
DELETE FROM pg_ts_parser; DELETE FROM pg_ts_parser;
} }
expect error {cannot delete from pg_catalog table "pg_ts_parser"} expect error {cannot delete from pg_catalog table "pg_ts_parser"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-ts-template-is-read-only { test pg-object-ts-template-is-read-only {
DELETE FROM pg_ts_template; DELETE FROM pg_ts_template;
} }
expect error {cannot delete from pg_catalog table "pg_ts_template"} expect error {cannot delete from pg_catalog table "pg_ts_template"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-ts-dict-is-read-only { test pg-object-ts-dict-is-read-only {
DELETE FROM pg_ts_dict; DELETE FROM pg_ts_dict;
} }
expect error {cannot delete from pg_catalog table "pg_ts_dict"} expect error {cannot delete from pg_catalog table "pg_ts_dict"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-ts-config-is-read-only { test pg-object-ts-config-is-read-only {
DELETE FROM pg_ts_config; DELETE FROM pg_ts_config;
} }
expect error {cannot delete from pg_catalog table "pg_ts_config"} expect error {cannot delete from pg_catalog table "pg_ts_config"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-foreign-data-wrapper-is-read-only { test pg-object-foreign-data-wrapper-is-read-only {
DELETE FROM pg_foreign_data_wrapper; DELETE FROM pg_foreign_data_wrapper;
} }
expect error {cannot delete from pg_catalog table "pg_foreign_data_wrapper"} expect error {cannot delete from pg_catalog table "pg_foreign_data_wrapper"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-foreign-server-is-read-only { test pg-object-foreign-server-is-read-only {
DELETE FROM pg_foreign_server; DELETE FROM pg_foreign_server;
} }
expect error {cannot delete from pg_catalog table "pg_foreign_server"} expect error {cannot delete from pg_catalog table "pg_foreign_server"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-default-acl-is-read-only { test pg-object-default-acl-is-read-only {
DELETE FROM pg_default_acl; DELETE FROM pg_default_acl;
} }
expect error {cannot delete from pg_catalog table "pg_default_acl"} expect error {cannot delete from pg_catalog table "pg_default_acl"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-conversion-is-read-only { test pg-object-conversion-is-read-only {
DELETE FROM pg_conversion; DELETE FROM pg_conversion;
} }
expect error {cannot delete from pg_catalog table "pg_conversion"} expect error {cannot delete from pg_catalog table "pg_conversion"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-range-is-read-only { test pg-object-range-is-read-only {
DELETE FROM pg_range; DELETE FROM pg_range;
} }
expect error {cannot delete from pg_catalog table "pg_range"} expect error {cannot delete from pg_catalog table "pg_range"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-event-trigger-is-read-only { test pg-object-event-trigger-is-read-only {
DELETE FROM pg_event_trigger; DELETE FROM pg_event_trigger;
} }
expect error {cannot delete from pg_catalog table "pg_event_trigger"} expect error {cannot delete from pg_catalog table "pg_event_trigger"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-subscription-is-read-only { test pg-object-subscription-is-read-only {
DELETE FROM pg_subscription; DELETE FROM pg_subscription;
} }
expect error {cannot delete from pg_catalog table "pg_subscription"} expect error {cannot delete from pg_catalog table "pg_subscription"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-largeobject-metadata-is-read-only { test pg-object-largeobject-metadata-is-read-only {
DELETE FROM pg_largeobject_metadata; DELETE FROM pg_largeobject_metadata;
} }
expect error {cannot delete from pg_catalog table "pg_largeobject_metadata"} expect error {cannot delete from pg_catalog table "pg_largeobject_metadata"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-amop-is-read-only { test pg-object-amop-is-read-only {
DELETE FROM pg_amop; DELETE FROM pg_amop;
} }
expect error {cannot delete from pg_catalog table "pg_amop"} expect error {cannot delete from pg_catalog table "pg_amop"}
@skip-if postgres "different error message: PostgreSQL reports permission denied for the table"
test pg-object-amproc-is-read-only { test pg-object-amproc-is-read-only {
DELETE FROM pg_amproc; DELETE FROM pg_amproc;
} }
@@ -443,6 +468,7 @@ expect {
2608 2608
} }
@skip-if postgres "Turso has the ACLs of PostgreSQL 16, without the MAINTAIN privilege (m) of PostgreSQL 17"
test pg-depend-for-dump-table-query { test pg-depend-for-dump-table-query {
CREATE TABLE dump_indexed (id INTEGER PRIMARY KEY, value TEXT UNIQUE); CREATE TABLE dump_indexed (id INTEGER PRIMARY KEY, value TEXT UNIQUE);
CREATE TABLE dump_plain (value TEXT); CREATE TABLE dump_plain (value TEXT);

View File

@@ -3,6 +3,8 @@
# Simple EXPLAIN is intentionally mapped to SQLite's EXPLAIN QUERY PLAN. # Simple EXPLAIN is intentionally mapped to SQLite's EXPLAIN QUERY PLAN.
# PostgreSQL EXPLAIN options are rejected until their output semantics exist. # PostgreSQL EXPLAIN options are rejected until their output semantics exist.
@skip-file-if postgres "EXPLAIN shows the Turso query plan, and Turso rejects EXPLAIN options that PostgreSQL accepts"
@database :memory: @database :memory:
setup explain_table { setup explain_table {

View File

@@ -203,6 +203,7 @@ test pg-get-expr-null-oid-does-not-hide-invalid-expression {
} }
expect error {} expect error {}
@skip-if postgres "PostgreSQL prints (val > 0), and also lists the CHECK constraints of the information_schema domains"
test pg-get-expr-check-constraint { test pg-get-expr-check-constraint {
CREATE TABLE checked (val int CHECK (val > 0)); CREATE TABLE checked (val int CHECK (val > 0));
SELECT pg_get_expr(conbin, conrelid) FROM pg_constraint WHERE contype = 'c'; SELECT pg_get_expr(conbin, conrelid) FROM pg_constraint WHERE contype = 'c';
@@ -229,6 +230,7 @@ expect {
1 1
} }
@skip-if postgres "Turso has the ACLs of PostgreSQL 16, without the MAINTAIN privilege (m) of PostgreSQL 17"
test acldefault-object-kinds { test acldefault-object-kinds {
SELECT pg_catalog.acldefault('c', 4294967294); SELECT pg_catalog.acldefault('c', 4294967294);
SELECT acldefault('r', 4294967294); SELECT acldefault('r', 4294967294);
@@ -271,6 +273,7 @@ expect {
2615|2200|public|{owner=UC/owner} 2615|2200|public|{owner=UC/owner}
} }
@skip-if postgres "Turso has the ACLs of PostgreSQL 16, without the MAINTAIN privilege (m) of PostgreSQL 17"
test acldefault-first-byte-selects-object-kind { test acldefault-first-byte-selects-object-kind {
SELECT acldefault('rr', 4294967294); SELECT acldefault('rr', 4294967294);
SELECT acldefault('r ', 4294967294); SELECT acldefault('r ', 4294967294);

View File

@@ -0,0 +1,63 @@
#!/usr/bin/env bash
# Runs a command with PG_DSN set to the URL of a PostgreSQL server.
#
# ./with-postgres.sh sh -c 'echo "$PG_DSN"'
#
# If PG_DSN is already set, the command uses that server. Otherwise this
# script starts a throwaway PostgreSQL container with Docker, runs the
# command, and removes the container.
#
# To test against another PostgreSQL version, set POSTGRES_VERSION, for
# example POSTGRES_VERSION=18. To upgrade the version for everyone, change
# the default below.
set -euo pipefail
POSTGRES_VERSION="${POSTGRES_VERSION:-17}"
POSTGRES_IMAGE="${POSTGRES_IMAGE:-mirror.gcr.io/library/postgres:$POSTGRES_VERSION}"
if [[ -n "${PG_DSN:-}" ]]; then
exec "$@"
fi
if ! docker info >/dev/null 2>&1; then
echo "error: PG_DSN is not set and Docker is not running." >&2
echo "Start Docker, or set PG_DSN to a PostgreSQL server, for example" >&2
echo "PG_DSN=postgres://sqltest@127.0.0.1:5432/postgres." >&2
exit 2
fi
container=$(docker run --detach \
--env POSTGRES_HOST_AUTH_METHOD=trust \
--env PGDATA=/pgdata/data \
--tmpfs /pgdata \
--publish 127.0.0.1::5432 \
"$POSTGRES_IMAGE" \
-c fsync=off \
-c synchronous_commit=off \
-c full_page_writes=off \
-c wal_level=minimal \
-c max_wal_senders=0 \
-c autovacuum=off \
-c jit=off \
-c max_connections=500)
trap 'docker rm --force --volumes "$container" >/dev/null' EXIT
for _ in $(seq 1 300); do
if docker exec "$container" pg_isready --host 127.0.0.1 --username postgres >/dev/null 2>&1; then
break
fi
sleep 0.1
done
if ! docker exec "$container" pg_isready --host 127.0.0.1 --username postgres >/dev/null 2>&1; then
echo "error: PostgreSQL in container $container did not start:" >&2
docker logs "$container" >&2
exit 1
fi
docker exec "$container" psql --quiet --username postgres \
--command "CREATE ROLE sqltest LOGIN CREATEDB" >/dev/null
port=$(docker port "$container" 5432/tcp | head -n 1 | sed 's/.*://')
export PG_DSN="postgres://sqltest@127.0.0.1:${port}/postgres"
echo "Using $POSTGRES_IMAGE at $PG_DSN" >&2
"$@"