SQL language reference (PostgreSQL dialect)
This part of Volume II describes the SQL that the core query engine executes when a client speaks PostgreSQL. Other wires (MySQL, SQL Server, Oracle, SQLite, ClickHouse) reuse the same engine with dialect switches; their differences are documented with each wire. Everything here is derived from the code snapshot main 8a689c5c (2026-11-30). Where a feature has a test, the test or suite is named. Where no test was found, the text says Not verified:. Where code exists but is not reachable, or a statement is accepted and ignored, the text says Not wired:.
Pages
Read them in this order:
- Statements: every statement the parser and engine accept, what each one does, which are accepted and ignored, and the SQLSTATE codes errors map to.
- Data types: the value model, type names and OIDs, how values are coerced on write, ranges, enums, domains, composites, inet, vector.
- Functions and operators: the full operator set and every scalar function the evaluator dispatches, by category, plus names that parse but are not evaluated.
- Aggregates and window functions: aggregates, ordered-set aggregates, GROUPING SETS, window functions and frames.
- JSON, JSONB and arrays: JSON operators, builders, set-returning JSON functions, array syntax and functions.
- Full-text search and trigram matching: tsvector, tsquery, ranking, GIN FTS indexes, pg_trgm-style similarity.
- Constraints, sequences and identity columns: primary keys, UNIQUE, CHECK, NOT NULL, foreign keys and their actions, generated columns, sequences, SERIAL and identity.
- PL/pgSQL, user functions and triggers: CREATE FUNCTION, the PL/pgSQL interpreter, DO blocks, triggers.
- System catalogs and information_schema: which pg_catalog and information_schema relations are served, and catalog functions.
- Session settings, prepared statements and the slow-query log: SET, SHOW, RESET, which settings change behaviour, SQL-level PREPARE, query logging.
Where a statement goes
A statement arrives through QueryEngine::execute, which applies the PostgreSQL aborted-transaction rule and records undo for transactional DDL, then execute_unguarded (SQL-level PREPARE, EXECUTE and DEALLOCATE), then execute_with_timeout, which starts the slow-query timer. execute_with_timeout_inner handles a set of statements directly from their text before the parser sees them (transaction control, SET/RESET/SHOW, ANALYZE, VACUUM, REINDEX, DISCARD, schema DDL, CREATE/DROP DATABASE, advisory locks, sequence calls, COMMENT ON, catalog queries). Everything else is parsed by Parser::parse_statement into a LogicalPlan and run by execute_plan (source: src/query/engine.rs, execute, execute_top, execute_unguarded, execute_with_timeout_inner, execute_plan; src/query/sql/parser.rs, parse_statement). Parsed plans are cached per engine: 512 entries, statement text up to 16 KB (source: src/query/engine.rs, plan_cache). The pipeline as a whole is described in Statement lifecycle.
COPY, LISTEN, UNLISTEN, NOTIFY and pg_sleep are handled by the PostgreSQL wire layer, not the engine (source: src/protocol/postgres/copy.rs; src/protocol/postgres/mod.rs). They are covered in Statements and in the PostgreSQL wire page.
How the dialect is tested
| Suite | What it checks | Result recorded on 2026-11-30 |
|---|---|---|
Differential query corpus (test-scripts/diff/corpus.py, diff_harness.py --strict) |
279 queries on a users/orders/depts schema compared value by value and by result column type OID against PostgreSQL 16 | 276/279; the 3 differences are float4 sum/avg precision and the digit count of stddev
|
Second connection and restart phases (test-scripts/diff/phases_pg.py) |
Visibility across connections, persistence across restart | 14/14 and 21/21 |
Feature matrix (test-scripts/feature-matrix/features.py) |
295 scenarios in 17 categories, each run on SynergyDB and PostgreSQL 16 | 295/295 in the proof log |
| ORM suites | Prisma, Drizzle, Knex, TypeORM | 12/12, 21/21, 19/19, 13/13 |
| Engine unit tests | 492 #[test] functions inside src/query/engine.rs, plus engine_*_tests.rs modules |
not counted per area here |
(source: README.md, wire scorecard and Known gaps; docs/proof/2026-11-30/proof-pack-a3232c9/logs/postgres-feature-matrix.txt; docs/status/2026-11-30-pg-json-result-gaps.md; test-scripts/feature-matrix/features.py; test-scripts/diff/corpus.py)
The committed test-scripts/feature-matrix/FEATURE_MATRIX.md still shows an older 269/295 run (for example where-similar-to as UNSUPPORTED); the proof log of the same date shows 295/295 (source: test-scripts/feature-matrix/FEATURE_MATRIX.md; docs/proof/2026-11-30/proof-pack-a3232c9/logs/postgres-feature-matrix.txt). The feature-matrix categories and diff-corpus tags are quoted on each page.
To rerun: make prove ARGS='--wires postgres', python test-scripts/diff/diff_harness.py --strict, python test-scripts/feature-matrix/feature_matrix.py (source: PostgreSQL wire).
Behaviour that differs from PostgreSQL everywhere
These points apply across the whole dialect and are repeated on the relevant pages:
-
An unknown function name returns NULL in the PostgreSQL dialect instead of raising
42883 function does not exist. Only the ClickHouse dialect raises "Unknown function" (source:src/query/engine.rs,evaluate_row_expr, function fallback arm). -
Many DDL forms are accepted and ignored so that schema dumps and ORM migrations load:
ALTER TABLE ... DROP CONSTRAINT(the constraint stays enforced),EXCLUDEconstraints, partitioning clauses,ALTER INDEX,CREATE PROCEDURE,CREATE AGGREGATE,CREATE OPERATOR,CREATE EXTENSIONand others. The full list is in Statements. -
No statement timeout.
statement_timeoutis stored but no code reads it (source:src/query/engine.rs,get_configcall sites;src/query/types.rs,QueryTimeout). -
server_versionreports 15.0 (server_version_num150000), while the differential suites compare against PostgreSQL 16 (source:src/query/engine.rs,guc_default;README.md). - Isolation, locking and snapshot behaviour are described in Isolation levels and How SynergyDB works; roles, GRANT and row-level security in Security.