mirror of
https://github.com/allankoechke/turso.git
synced 2026-11-30 11:12:58 +00:00
`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
380 lines
7.8 KiB
Plaintext
380 lines
7.8 KiB
Plaintext
# Scalar function behavior through the PostgreSQL frontend.
|
|
#
|
|
# Coverage here asserts behavior that real PostgreSQL also exhibits, so the
|
|
# corpus is valid for differential runs against a stock server.
|
|
# Server-specific outputs (version(), current_database(), pg_backend_pid())
|
|
# are covered in postgres/tests/integration instead.
|
|
|
|
@database :memory:
|
|
|
|
test quote-ident-plain-lowercase {
|
|
SELECT quote_ident('abc');
|
|
}
|
|
expect {
|
|
abc
|
|
}
|
|
|
|
test quote-ident-underscore-and-digits {
|
|
SELECT quote_ident('a_1');
|
|
}
|
|
expect {
|
|
a_1
|
|
}
|
|
|
|
test quote-ident-mixed-case {
|
|
SELECT quote_ident('Abc');
|
|
}
|
|
expect {
|
|
"Abc"
|
|
}
|
|
|
|
test quote-ident-embedded-space {
|
|
SELECT quote_ident('a b');
|
|
}
|
|
expect {
|
|
"a b"
|
|
}
|
|
|
|
test quote-ident-embedded-quote-doubled {
|
|
SELECT quote_ident('a"b');
|
|
}
|
|
expect {
|
|
"a""b"
|
|
}
|
|
|
|
test quote-ident-reserved-keyword {
|
|
SELECT quote_ident('select');
|
|
}
|
|
expect {
|
|
"select"
|
|
}
|
|
|
|
test quote-ident-unreserved-keyword-unquoted {
|
|
SELECT quote_ident('commit');
|
|
}
|
|
expect {
|
|
commit
|
|
}
|
|
|
|
test quote-ident-col-name-keyword {
|
|
SELECT quote_ident('between');
|
|
}
|
|
expect {
|
|
"between"
|
|
}
|
|
|
|
test quote-ident-type-func-name-keyword {
|
|
SELECT quote_ident('binary');
|
|
}
|
|
expect {
|
|
"binary"
|
|
}
|
|
|
|
test quote-ident-empty-string {
|
|
SELECT quote_ident('');
|
|
}
|
|
expect {
|
|
""
|
|
}
|
|
|
|
test quote-ident-leading-digit {
|
|
SELECT quote_ident('1a');
|
|
}
|
|
expect {
|
|
"1a"
|
|
}
|
|
|
|
test quote-ident-null-is-null {
|
|
SELECT quote_ident(NULL);
|
|
}
|
|
expect {
|
|
}
|
|
|
|
test quote-literal-plain {
|
|
SELECT quote_literal('abc');
|
|
}
|
|
expect {
|
|
'abc'
|
|
}
|
|
|
|
test quote-literal-embedded-quote {
|
|
SELECT quote_literal('O''Reilly');
|
|
}
|
|
expect {
|
|
'O''Reilly'
|
|
}
|
|
|
|
test quote-literal-integer {
|
|
SELECT quote_literal(42);
|
|
}
|
|
expect {
|
|
'42'
|
|
}
|
|
|
|
test quote-literal-null-is-null {
|
|
SELECT quote_literal(NULL);
|
|
}
|
|
expect {
|
|
}
|
|
|
|
# The sqltest lexer collapses \\ to \, so the expected E'a\\b' is written
|
|
# with doubled backslashes here.
|
|
test quote-literal-backslash-uses-escape-string {
|
|
SELECT quote_literal('a\b');
|
|
}
|
|
expect {
|
|
E'a\\\\b'
|
|
}
|
|
|
|
test current-schema-default {
|
|
SELECT current_schema();
|
|
}
|
|
expect {
|
|
public
|
|
}
|
|
|
|
test current-schema-bare-keyword {
|
|
SELECT current_schema;
|
|
}
|
|
expect {
|
|
public
|
|
}
|
|
|
|
test current-schema-in-from-position {
|
|
SELECT * FROM current_schema();
|
|
}
|
|
expect {
|
|
public
|
|
}
|
|
|
|
test obj-description-unknown-oid-is-null {
|
|
SELECT obj_description(0, 'pg_class');
|
|
}
|
|
expect {
|
|
}
|
|
|
|
test col-description-unknown-oid-is-null {
|
|
SELECT col_description(0, 1);
|
|
}
|
|
expect {
|
|
}
|
|
|
|
test version-wrong-arity-errors {
|
|
SELECT version(1);
|
|
}
|
|
expect error {}
|
|
|
|
test quote-ident-wrong-arity-errors {
|
|
SELECT quote_ident();
|
|
}
|
|
expect error {}
|
|
|
|
test pg-get-expr-default-two-args {
|
|
CREATE TABLE demo (id int DEFAULT 7, label text);
|
|
SELECT pg_get_expr(adbin, adrelid) FROM pg_attrdef;
|
|
}
|
|
expect {
|
|
7
|
|
}
|
|
|
|
test pg-get-expr-default-three-args {
|
|
CREATE TABLE demo (id int DEFAULT 7, label text);
|
|
SELECT pg_get_expr(adbin, adrelid, true) FROM pg_attrdef;
|
|
}
|
|
expect {
|
|
7
|
|
}
|
|
|
|
test pg-get-expr-null-oid-is-null {
|
|
CREATE TABLE demo (id int DEFAULT 7, label text);
|
|
SELECT pg_get_expr(adbin, NULL, true) FROM pg_attrdef;
|
|
}
|
|
expect {
|
|
}
|
|
|
|
test pg-get-expr-non-text-expression-errors {
|
|
CREATE TABLE demo (id int DEFAULT 7, label text);
|
|
SELECT pg_get_expr(42, 1::oid) FROM pg_attrdef;
|
|
}
|
|
expect error {}
|
|
|
|
test pg-get-expr-null-oid-does-not-hide-invalid-expression {
|
|
SELECT pg_get_expr(42, NULL::oid);
|
|
}
|
|
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 {
|
|
CREATE TABLE checked (val int CHECK (val > 0));
|
|
SELECT pg_get_expr(conbin, conrelid) FROM pg_constraint WHERE contype = 'c';
|
|
}
|
|
expect {
|
|
val > 0
|
|
}
|
|
|
|
test percentile-cont-within-group {
|
|
CREATE TABLE demo (value int);
|
|
INSERT INTO demo (value) VALUES (1), (2);
|
|
SELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY value) FROM demo;
|
|
}
|
|
expect {
|
|
1.5
|
|
}
|
|
|
|
test mode-within-group {
|
|
CREATE TABLE demo (value int);
|
|
INSERT INTO demo VALUES (2), (2), (1), (1);
|
|
SELECT mode() WITHIN GROUP (ORDER BY value) FROM demo;
|
|
}
|
|
expect {
|
|
1
|
|
}
|
|
|
|
@skip-if postgres "Turso has the ACLs of PostgreSQL 16, without the MAINTAIN privilege (m) of PostgreSQL 17"
|
|
test acldefault-object-kinds {
|
|
SELECT pg_catalog.acldefault('c', 4294967294);
|
|
SELECT acldefault('r', 4294967294);
|
|
SELECT acldefault('s', 4294967294);
|
|
SELECT acldefault('d', 4294967294);
|
|
SELECT acldefault('f', 4294967294);
|
|
SELECT acldefault('l', 4294967294);
|
|
SELECT acldefault('L', 4294967294);
|
|
SELECT acldefault('n', 4294967294);
|
|
SELECT acldefault('p', 4294967294);
|
|
SELECT acldefault('t', 4294967294);
|
|
SELECT acldefault('F', 4294967294);
|
|
SELECT acldefault('S', 4294967294);
|
|
SELECT acldefault('T', 4294967294);
|
|
}
|
|
expect {
|
|
{}
|
|
{4294967294=arwdDxt/4294967294}
|
|
{4294967294=rwU/4294967294}
|
|
{=Tc/4294967294,4294967294=CTc/4294967294}
|
|
{=X/4294967294,4294967294=X/4294967294}
|
|
{=U/4294967294,4294967294=U/4294967294}
|
|
{4294967294=rw/4294967294}
|
|
{4294967294=UC/4294967294}
|
|
{4294967294=sA/4294967294}
|
|
{4294967294=C/4294967294}
|
|
{4294967294=U/4294967294}
|
|
{4294967294=U/4294967294}
|
|
{=U/4294967294,4294967294=U/4294967294}
|
|
}
|
|
|
|
test acldefault-catalog-owner {
|
|
SET search_path TO '';
|
|
SELECT n.tableoid, n.oid, n.nspname,
|
|
replace(acldefault('n', n.nspowner)::text,
|
|
pg_get_userbyid(n.nspowner), 'owner')
|
|
FROM pg_namespace n WHERE n.nspname = 'public';
|
|
}
|
|
expect {
|
|
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 {
|
|
SELECT acldefault('rr', 4294967294);
|
|
SELECT acldefault('r ', 4294967294);
|
|
SELECT acldefault('Table', 4294967294);
|
|
SELECT acldefault('ré', 4294967294);
|
|
}
|
|
expect {
|
|
{4294967294=arwdDxt/4294967294}
|
|
{4294967294=arwdDxt/4294967294}
|
|
{=U/4294967294,4294967294=U/4294967294}
|
|
{4294967294=arwdDxt/4294967294}
|
|
}
|
|
|
|
test acldefault-null-arguments {
|
|
SELECT acldefault(NULL, 4294967294), acldefault('r', NULL);
|
|
}
|
|
expect {
|
|
|
|
|
}
|
|
|
|
test acldefault-unknown-object-kind-errors {
|
|
SELECT acldefault('?', 4294967294);
|
|
}
|
|
expect error {}
|
|
|
|
test acldefault-empty-object-kind-errors {
|
|
SELECT acldefault('', 4294967294);
|
|
}
|
|
expect error {}
|
|
|
|
test acldefault-leading-space-object-kind-errors {
|
|
SELECT acldefault(' r', 4294967294);
|
|
}
|
|
expect error {}
|
|
|
|
test acldefault-uppercase-object-kind-errors {
|
|
SELECT acldefault('R', 4294967294);
|
|
}
|
|
expect error {}
|
|
|
|
test acldefault-non-ascii-object-kind-errors {
|
|
SELECT acldefault('é', 4294967294);
|
|
}
|
|
expect error {}
|
|
|
|
test format-type-expanded {
|
|
SELECT format_type(16, -1);
|
|
SELECT format_type(23, -1);
|
|
SELECT format_type(25, -1);
|
|
SELECT format_type(114, -1);
|
|
SELECT format_type(3802, -1);
|
|
SELECT format_type(2950, -1);
|
|
SELECT format_type(1082, -1);
|
|
SELECT format_type(1114, -1);
|
|
SELECT format_type(1184, -1);
|
|
SELECT format_type(1186, -1);
|
|
SELECT format_type(2278, -1);
|
|
SELECT format_type(2205, -1);
|
|
SELECT format_type(2206, -1);
|
|
SELECT format_type(1000, -1);
|
|
SELECT format_type(1007, -1);
|
|
SELECT format_type(1009, -1);
|
|
SELECT format_type(1043, 54);
|
|
}
|
|
expect {
|
|
boolean
|
|
integer
|
|
text
|
|
json
|
|
jsonb
|
|
uuid
|
|
date
|
|
timestamp without time zone
|
|
timestamp with time zone
|
|
interval
|
|
void
|
|
regclass
|
|
regtype
|
|
boolean[]
|
|
integer[]
|
|
text[]
|
|
character varying(50)
|
|
}
|
|
|
|
test pg-type-is-visible {
|
|
SELECT CASE WHEN pg_type_is_visible(23) THEN 1 ELSE 0 END;
|
|
}
|
|
expect {
|
|
1
|
|
}
|
|
|
|
test lpad-rpad {
|
|
SELECT quote_literal(lpad('hi', 5, '*'));
|
|
SELECT quote_literal(rpad('hi', 5, '-'));
|
|
SELECT quote_literal(lpad('hi', 5));
|
|
SELECT quote_literal(lpad('hello world', 5));
|
|
}
|
|
expect {
|
|
'***hi'
|
|
'hi---'
|
|
' hi'
|
|
'hello'
|
|
}
|