Statements

This page lists every statement the PostgreSQL dialect accepts and what the engine does with it. Statements fall into three groups: those executed from their raw text before parsing, those parsed into a LogicalPlan, and those handled by the PostgreSQL wire layer. A statement the parser does not recognise fails with "Expected statement" (SQLSTATE 42601) (source: src/query/sql/parser.rs, parse_statement; src/protocol/postgres/mod.rs, error_to_sqlstate).

The marker accepted, ignored means the statement or clause parses and returns success but changes nothing. ORMs and pg_dump output rely on these forms loading; the effect a PostgreSQL user expects does not happen.

Statement dispatch

The parser chooses a statement by its first keyword:

First keyword Result
empty text, comment only Empty (no-op)
WITH query with CTEs, including data-modifying CTEs (LogicalPlan::WithDml) and WITH RECURSIVE
SELECT, ( query
VALUES row constructor (LogicalPlan::Values)
INSERT, UPDATE, DELETE DML
REPLACE, RENAME TABLE MySQL forms, accepted in every dialect
CREATE, DROP, ALTER DDL, see below
GRANT, REVOKE privileges and role membership
BEGIN, START, COMMIT, END, ROLLBACK, ABORT, SAVEPOINT, RELEASE transaction control
SET, RESET, SHOW session settings
EXPLAIN plan display
TRUNCATE delete all rows
DECLARE, FETCH, MOVE, CLOSE cursors
DO anonymous PL/pgSQL block
REFRESH MATERIALIZED VIEW recompute a materialized view
COMMENT see COMMENT ON below
DISCARD, LOCK, FLUSH accepted, ignored at the parser (DISCARD is handled earlier from raw text)
anything else error 42601

(source: src/query/sql/parser.rs, parse_statement)

Statements executed before parsing

execute_with_timeout_inner recognises the following from the statement text and never sends them to the parser (source: src/query/engine.rs, execute_with_timeout_inner).

Statement Behaviour
BEGIN, START TRANSACTION [isolation, READ ONLY/WRITE] Starts a transaction. A redundant BEGIN inside a transaction is ignored. Default isolation READ COMMITTED
COMMIT, END, END WORK, END TRANSACTION Runs deferred foreign-key checks, validates, writes the batch, releases locks. A commit that fails aborts and undoes transactional DDL
ROLLBACK, ABORT Rolls back and undoes DDL done in the transaction
SET ..., RESET ..., SHOW ..., SELECT set_config(...) See Session settings
TRUNCATE a, b, ... Split into one truncate per table. Foreign keys between tables in the same list do not block it (test test_multi_table_truncate_ignores_fks_between_listed_tables)
ANALYZE [table] Collects table statistics into the statistics manager used by EXPLAIN and the planner
VACUUM FULL, VACUUM (FULL) Runs a full LSM compaction (compact_full)
VACUUM (other forms) Accepted, ignored
REINDEX TABLE t Rebuilds row-key indexes for t, outside a transaction only. Other REINDEX forms: accepted, ignored
DISCARD ALL, DISCARD TEMP, DISCARD TEMPORARY Drops the session's temporary tables; ALL also resets the session role
CREATE SCHEMA, DROP SCHEMA, ALTER SCHEMA Real namespaces, see Schemas
CREATE DATABASE, ALTER DATABASE ... OWNER TO, DROP DATABASE Real. CREATE needs superuser or CREATEDB; the owner is OWNER or the creator, and a non-superuser may only name itself. DROP purges the namespace and needs owner or superuser
CREATE EXTENSION, DROP EXTENSION Accepted; the extension name is recorded for pg_extension. No code is loaded
CREATE/DROP TEXT SEARCH ..., CREATE AGGREGATE, CREATE LANGUAGE Accepted, ignored
SELECT nextval(..), currval, setval, lastval as a whole statement Fast path to the sequence code
Advisory lock calls as a whole statement See Advisory locks
DEALLOCATE [PREPARE] name \| ALL Drops SQL-level prepared statements
COMMENT ON TABLE \| VIEW \| MATERIALIZED VIEW \| FOREIGN TABLE \| COLUMN Stored and returned by obj_description / col_description. COMMENT ON any other object: accepted, ignored
Catalog queries Answered by handle_system_query or the system catalog; see System catalogs

(source: src/query/engine.rs, execute_with_timeout_inner, handle_analyze, handle_schema_ddl, try_handle_advisory_lock, set_object_comment)

Inside a failed transaction every statement except COMMIT, END (both roll back), ROLLBACK, ABORT and RELEASE fails with 25P02, as in PostgreSQL. In a READ ONLY transaction or on a read-only cluster node, writes fail with 25006 (source: src/query/engine.rs, execute_top). Transaction semantics are in Isolation levels and Locking.

Queries

SELECT supports:

  • DISTINCT and DISTINCT ON (...); WHERE; GROUP BY by column, ordinal or expression; GROUPING SETS and ROLLUP; HAVING; ORDER BY by expression or ordinal with ASC/DESC and NULLS FIRST/NULLS LAST; LIMIT/OFFSET; FETCH FIRST n ROWS ONLY and WITH TIES (LogicalPlan::LimitWithTies).
  • Joins: INNER, LEFT, RIGHT, FULL, CROSS, USING, NATURAL is not listed in the feature matrix; LATERAL subqueries (LogicalPlan::LateralJoin); self joins.
  • Set operations UNION [ALL], INTERSECT, EXCEPT.
  • WITH and WITH RECURSIVE (LogicalPlan::RecursiveCTE), and data-modifying CTEs.
  • Subqueries: scalar, IN, EXISTS, NOT EXISTS, correlated, ARRAY(subquery), = ANY/ALL (subquery).
  • A named WINDOW clause, inlined into each OVER name (resolve_named_windows).
  • Row locking: FOR UPDATE, FOR NO KEY UPDATE, FOR SHARE, FOR KEY SHARE, OF table, ..., NOWAIT, SKIP LOCKED (LogicalPlan::LockRows).
  • Table functions in FROM, listed in Functions and operators.

(source: src/query/sql/parser.rs, parse_statement, resolve_named_windows; src/plan/logical.rs, LogicalPlan)

Feature-matrix coverage (category DML, 70 scenarios, all passing in the 2026-11-30 proof log) includes distinct-on, rollup, grouping-sets, fetch-first, join-lateral, cte-recursive, corr-scalar, not-in-null-trap, and all join and set-operation kinds above. Transactions scenarios cover select-for-update, select-for-share, for-update-skip-locked, for-update-nowait (source: test-scripts/feature-matrix/features.py). The diff corpus tags join (11), subquery (8), setop (5), cte (3), limit (5), distinct (3), orderby (6) compare results and column types with PostgreSQL 16 (source: test-scripts/diff/corpus.py).

Not verified: NATURAL JOIN: no feature-matrix scenario or diff-corpus query was found.

INSERT, UPDATE, DELETE, TRUNCATE

Form Notes
INSERT INTO t [(cols)] VALUES ... \| SELECT ... \| DEFAULT VALUES Multi-row VALUES; INSERT ... SELECT (LogicalPlan::InsertSelect). Values are coerced to the column type, see Data types
ON CONFLICT [(cols) \| ON CONSTRAINT name] DO NOTHING With no conflict target, every unique key is checked (test test_on_conflict_no_target_uses_every_unique_key)
ON CONFLICT ... DO UPDATE SET ... [WHERE ...] EXCLUDED.col refers to the proposed row
ON DUPLICATE KEY UPDATE MySQL form, also parsed
RETURNING expr, ... On INSERT, UPDATE and DELETE; the command tag still reports the affected count
UPDATE t SET ... [FROM src, ...] [WHERE ...] A FROM source may be a table or a subquery with alias. At most 5,000,000 source rows (UPDATE_FROM_MAX_SOURCE_ROWS)
DELETE FROM t [USING src, ...] [WHERE ...]  
TRUNCATE [TABLE] [ONLY] t [RESTART IDENTITY \| CONTINUE IDENTITY] [CASCADE \| RESTRICT] Lowered to a DELETE with no WHERE. The identity and cascade options are consumed and not acted on; sequences are not restarted

(source: src/query/sql/parser.rs, parse_statement, parse_truncate, test_parse_insert_on_conflict_*; src/query/engine.rs, UPDATE_FROM_MAX_SOURCE_ROWS, execute_plan)

Coverage: feature-matrix DML scenarios insert-returning, insert-select, insert-on-conflict-do-update, insert-on-conflict-do-nothing, update-returning, update-from, delete-returning, delete-using, truncate (source: test-scripts/feature-matrix/features.py).

Not wired: TRUNCATE ... RESTART IDENTITY does not reset the sequences behind SERIAL columns; PostgreSQL does (source: src/query/sql/parser.rs, parse_truncate; src/query/engine.rs, comment "the parser drops the option").

Autocommit multi-row UPDATE and DELETE write row by row; a concurrent snapshot can see part of one (source: How SynergyDB works).

COPY

COPY is handled by the PostgreSQL wire layer, not by the engine, so it is available only over the PostgreSQL protocol (source: src/protocol/postgres/copy.rs, is_copy_command, CopyCommand::parse).

Feature Support
COPY t [(cols)] FROM STDIN Yes; the \. end marker is honoured
COPY t [(cols)] TO STDOUT, COPY (SELECT ...) TO STDOUT Yes
FORMAT text (default), FORMAT csv Yes
FORMAT binary Rejected when the command is parsed (test test_parse_copy_binary_rejected_at_parse_level)
Options DELIMITER, NULL, HEADER, QUOTE, ESCAPE, FORCE_NULL, FORCE_NOT_NULL
COPY ... FROM 'file' / TO 'file' / PROGRAM Not verified: no server-side file path handling was found in copy.rs

(source: src/protocol/postgres/copy.rs, CopyCommand::parse, handle_copy_from, handle_copy_to)

COPY FROM inserts in batches of 5,000 rows and commits every 250,000 rows by default. SYNERGYDB_COPY_COMMIT_ROWS changes the chunk size; 0 loads the whole stream in one transaction. Committed chunks are visible to other sessions while the load runs. When a chunked load into a table that was empty fails, the table is truncated, so the load is all or nothing for that case (source: src/protocol/postgres/copy.rs, COPY_BATCH_ROWS, COPY_COMMIT_ROWS_DEFAULT; docs/status/2026-11-30-copy-bounded-memory.md). Tests: cargo test --test copy_wire_atomic --test copy_bulk_parity (source: tests/copy_wire_atomic.rs, tests/copy_bulk_parity.rs).

The README Known gaps still lists a COPY FROM out-of-memory bug as open, but the chunked commit that addresses it is in the snapshot (source: README.md, Known gaps; docs/status/2026-11-30-copy-bounded-memory.md).

LISTEN, UNLISTEN, NOTIFY

Handled in the PostgreSQL wire layer; notifications are delivered to listening sessions (source: src/protocol/postgres/mod.rs). The feature matrix lists LISTEN/NOTIFY as wire-verified separately rather than as a scenario (source: test-scripts/feature-matrix/features.py). pg_notify() as a function was not found in the engine's function dispatch.

CREATE TABLE

Clause Support
TEMP/TEMPORARY Session-private table, with ON COMMIT PRESERVE ROWS \| DELETE ROWS \| DROP
GLOBAL, LOCAL, UNLOGGED Accepted, ignored
IF NOT EXISTS Yes
Schema-qualified name Yes, see Schemas
Column DEFAULT, NOT NULL, NULL, PRIMARY KEY, UNIQUE, CHECK, REFERENCES Enforced, see Constraints
CONSTRAINT name PRIMARY KEY \| UNIQUE \| FOREIGN KEY \| CHECK (table level) Enforced
GENERATED ALWAYS AS (expr) STORED Computed on write; VIRTUAL is treated as STORED
GENERATED { ALWAYS \| BY DEFAULT } AS IDENTITY [(options)] Lowered to SERIAL, see Identity columns
COLLATE name on a column Accepted, ignored (there is no collation model)
CREATE TABLE t AS SELECT ... (CTAS) Yes (LogicalPlan::CreateTableAsSelect)
INHERITS (parent, ...) The parent's columns are copied into the child; the children share the parent's sequence (test inheritance_children_share_parent_sequence). Queries on the parent do not include child rows: Not verified: no test of parent-scan semantics was found
PARTITION BY RANGE \| LIST \| HASH (...) Accepted, ignored: a plain table is created
CREATE TABLE c PARTITION OF p ... Accepted, ignored: all rows go into the parent
WITH (storage params), TABLESPACE Accepted, ignored
EXCLUDE USING ... Accepted, ignored: no exclusion enforcement

(source: src/query/sql/parser.rs, parse_create, parse_create_table; src/query/engine.rs, execute_plan)

CREATE INDEX

CREATE [UNIQUE] INDEX [CONCURRENTLY] [IF NOT EXISTS] [name] ON [ONLY] table
    [USING method] ( key [COLLATE c] [opclass] [ASC|DESC] [NULLS FIRST|LAST], ... )
    [INCLUDE (...)] [NULLS [NOT] DISTINCT] [WITH (...)] [TABLESPACE t] [WHERE predicate]

A key is a column or an expression. When the name is omitted, one is synthesised as <table>_<col>_..._idx. CONCURRENTLY, INCLUDE, NULLS NOT DISTINCT, WITH (...) and TABLESPACE are accepted and ignored (source: src/query/sql/parser.rs, parse_create_index_with_unique, test_index_ordering_and_nulls, test_index_expression_keys).

What the index does depends on the method and key (source: src/query/engine.rs, execute_create_index):

Method and key Effect
UNIQUE (any method, column or expression keys, optional WHERE) Enforced uniqueness, including expression and partial unique indexes
btree or hash on a plain column Secondary index used for equality lookups on the leading column
gin on a tsvector column or on to_tsvector('cfg', col) Full-text posting lists used by @@, see Full-text search
gin on a JSONB or array column Containment index used by @>
hnsw or ivfflat on one vector column In-memory HNSW graph, rebuilt on first use after a restart. The opclass vector_l2_ops, vector_cosine_ops or vector_ip_ops picks the metric. The ivfflat lists parameter is ignored
gist, brin, spgist, other methods Metadata only
Any index on a materialized view Metadata only
WHERE predicate on a non-unique index Recorded, not used

Coverage: feature-matrix DDL-indexes scenarios btree, partial, expression, multicolumn, desc-order, concurrently, gin-jsonb, gin-trgm, gist, hash, and DDL-constraints partial-unique-dup-allowed, partial-unique-true-rejected, expression-unique (source: test-scripts/feature-matrix/features.py). These scenarios check that the statements succeed and queries return the same rows as PostgreSQL; they do not check that an index is used. Index internals are in Indexes overview and How SynergyDB works.

DROP INDEX [IF EXISTS] name removes the index. ALTER INDEX (any form, including RENAME) is accepted and ignored (source: src/query/sql/parser.rs, parse_alter, parse_drop).

ALTER TABLE

ALTER TABLE [IF EXISTS] [ONLY] name action [, action ...] (source: src/query/sql/parser.rs, parse_alter, parse_alter_table_action):

Action Effect
ADD [COLUMN] [IF NOT EXISTS] col type [constraints] Adds the column; several ADDs per statement allowed
DROP [COLUMN] [IF EXISTS] col [CASCADE\|RESTRICT] Drops the column; CASCADE/RESTRICT ignored
RENAME [COLUMN] a TO b, RENAME TO new Renames
ALTER [COLUMN] col [SET DATA] TYPE t [USING expr] Changes type and rewrites values
ALTER [COLUMN] col SET DEFAULT e \| DROP DEFAULT Yes
ALTER [COLUMN] col SET NOT NULL \| DROP NOT NULL Yes
ALTER [COLUMN] col ADD GENERATED ... AS IDENTITY Lowered to an auto-sequence
ADD [CONSTRAINT name] PRIMARY KEY \| UNIQUE \| FOREIGN KEY \| CHECK Enforced from then on. NOT VALID is accepted, but the constraint is enforced immediately
ADD CONSTRAINT ... PRIMARY KEY\|UNIQUE USING INDEX idx Accepted, ignored
ADD CONSTRAINT ... EXCLUDE ... Accepted, ignored
DROP CONSTRAINT [IF EXISTS] name Accepted, ignored: the constraint stays enforced
VALIDATE CONSTRAINT name Accepted, ignored
OWNER TO role Changes the owner (see Security)
SET SCHEMA s Moves the table to schema s
ENABLE \| DISABLE ROW LEVEL SECURITY, [NO] FORCE ROW LEVEL SECURITY Real, see Security
ALTER COLUMN col SET MASKED ... / MASK / UNMASK COLUMN Column masking, see Security
ENABLE \| DISABLE [ALWAYS\|REPLICA] TRIGGER \| RULE ... Accepted, ignored: triggers keep firing
SET LOGGED \| UNLOGGED, SET (params), SET TABLESPACE, SET WITHOUT ... Accepted, ignored
ATTACH PARTITION, DETACH PARTITION Accepted, ignored
MySQL forms: ADD INDEX/KEY, DROP INDEX, DROP PRIMARY KEY, DROP FOREIGN KEY, MODIFY, CHANGE, CONVERT TO CHARACTER SET Parsed in every dialect. The DROP forms are accepted and ignored

Coverage: feature-matrix alter-table-add-column (source: test-scripts/feature-matrix/features.py). Engine tests cover adding columns, foreign keys and checks, for example test_table_level_check_and_fk (source: src/query/engine.rs, tests).

Other CREATE, ALTER and DROP statements

Statement Effect
CREATE [OR REPLACE] VIEW v [(cols)] AS query, DROP VIEW Real views. ALTER VIEW ... RENAME TO and SET SCHEMA are real; other ALTER VIEW forms are accepted and ignored
CREATE MATERIALIZED VIEW mv AS query [WITH [NO] DATA], REFRESH MATERIALIZED VIEW [CONCURRENTLY] mv, DROP MATERIALIZED VIEW Real; the stored result changes only on REFRESH. CONCURRENTLY is ignored
CREATE TYPE name AS ENUM (...), AS (composite), AS RANGE (subtype = ...), DROP TYPE See Data types
ALTER TYPE ... ADD VALUE [IF NOT EXISTS] 'v' [BEFORE\|AFTER 'w'], RENAME TO, RENAME VALUE, RENAME ATTRIBUTE Real. OWNER TO and SET SCHEMA accepted, ignored
CREATE DOMAIN d AS type [DEFAULT ...] [NOT NULL] [CHECK (...)], ALTER DOMAIN d ADD CONSTRAINT ... CHECK (...), DROP DOMAIN Domain checks enforced on write
CREATE SEQUENCE, ALTER SEQUENCE, DROP SEQUENCE See Sequences
CREATE [OR REPLACE] FUNCTION, DROP FUNCTION See PL/pgSQL and functions
CREATE [OR REPLACE] TRIGGER, DROP TRIGGER See Triggers
CREATE CONSTRAINT TRIGGER Accepted, ignored
CREATE ROLE \| USER, ALTER ROLE \| USER, DROP ROLE \| USER See Security. ALTER ROLE ... SET param, RESET, IN DATABASE are accepted and ignored: there are no per-role setting defaults
CREATE POLICY name ON t [AS PERMISSIVE\|RESTRICTIVE] [FOR ALL\|SELECT\|INSERT\|UPDATE\|DELETE] [TO roles] [USING (e)] [WITH CHECK (e)], DROP POLICY Row-level security, see Security
CREATE PROCEDURE, CREATE OPERATOR, CREATE COLLATION, CREATE SERVER, CREATE PUBLICATION, CREATE SUBSCRIPTION, CREATE LANGUAGE, CREATE AGGREGATE Accepted, ignored. There is no CALL statement

(source: src/query/sql/parser.rs, parse_create, parse_create_type, parse_create_policy, parse_alter, parse_drop; src/plan/logical.rs, LogicalPlan)

Coverage: feature-matrix DDL-objects scenarios view, view-or-replace, matview-refresh, sequence-nextval, sequence-currval, function-sql, function-plpgsql, trigger-before-insert, extension-noop, schema-search-path; custom-types scenarios enum-create-order, enum-add-value, composite-field, range-int4-contains, range-overlap, range-lower-upper, domain-check-reject, domain-check-accept (source: test-scripts/feature-matrix/features.py). Parser tests include test_parse_create_materialized_view, test_parse_create_enum_type, test_parse_create_domain (source: src/query/sql/parser.rs, tests).

Schemas and search_path

CREATE SCHEMA [IF NOT EXISTS] name [AUTHORIZATION role], ALTER SCHEMA ... RENAME TO | OWNER TO, and DROP SCHEMA [IF EXISTS] name [CASCADE | RESTRICT] create real namespaces. A table in schema s is stored under the physical name s + U+001F + name. public is the default schema; pg_catalog, pg_temp and pg_temp_* are recognised as aliases. Unqualified names resolve through the session's search_path (default "$user", public). ALTER TABLE ... SET SCHEMA moves a table (source: src/query/schema_ns.rs, SCHEMA_SEP; src/query/engine.rs, handle_schema_ddl, guc_default).

Errors: schema already exists 42P06, schema does not exist or no schema selected 3F000, schema not empty on DROP without CASCADE 2BP01, reserved schema name 42939 (source: src/protocol/postgres/mod.rs, error_to_sqlstate). Coverage: feature-matrix schema-search-path, show-search-path; engine tests test_search_path_default_and_set_roundtrip, test_search_path_default_without_set (source: test-scripts/feature-matrix/features.py; src/query/engine.rs, tests).

GRANT and REVOKE

GRANT privileges ON object [, ...] TO grantee [, ...] [WITH GRANT OPTION] and GRANT role [, ...] TO role [, ...] [WITH ADMIN OPTION], with matching REVOKE ... FROM. Privileges: ALL [PRIVILEGES], SELECT [(cols)], INSERT [(cols)], UPDATE [(cols)], DELETE, TRUNCATE, REFERENCES [(cols)], TRIGGER, CONNECT, CREATE, TEMPORARY, USAGE, EXECUTE. Objects: [TABLE] name, ALL TABLES IN SCHEMA s, ALL SEQUENCES IN SCHEMA s, ALL FUNCTIONS | PROCEDURES | ROUTINES IN SCHEMA s, DATABASE, SCHEMA, SEQUENCE, FUNCTION | PROCEDURE | ROUTINE name [(args)], and DOMAIN, LANGUAGE, TABLESPACE (kept as GrantObject::Other) (source: src/query/sql/parser.rs, parse_grant, parse_privileges, parse_grant_object).

A GRANT that cannot be parsed is ignored with a warning and returns success; an unparseable REVOKE is an error (tests grant_and_revoke_on_tables_parse, unparseable_revoke_is_an_error). Function privileges are parsed but not enforced (source: src/query/sql/parser.rs, parse_grant_object, comment "Function privileges aren't enforced"). Enforcement of table, column and database privileges, ownership and roles is documented in Security.

Transaction control

Statement Notes
BEGIN [TRANSACTION \| WORK] [ISOLATION LEVEL ...] [READ ONLY \| READ WRITE] [[NOT] DEFERRABLE], START TRANSACTION ... Isolation READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE
SET TRANSACTION ISOLATION LEVEL ... Applies to the current transaction, or the next if none is open
COMMIT, END, ROLLBACK, ABORT [WORK \| TRANSACTION] accepted
SAVEPOINT s, ROLLBACK TO [SAVEPOINT] s, RELEASE [SAVEPOINT] s Unknown savepoint 3B001. ROLLBACK TO undoes later DDL (tests rollback_to_savepoint_undoes_later_create_table, rollback_to_savepoint_undoes_only_later_ddl)
SET CONSTRAINTS { ALL \| name, ... } { DEFERRED \| IMMEDIATE } Affects deferrable foreign keys only
LOCK [TABLE] ... Accepted, ignored: no table lock is taken

(source: src/query/sql/parser.rs, parse_begin; src/query/engine.rs, handle_set_command, handle_set_constraints)

Coverage: feature-matrix transactions category (13 scenarios: begin-commit, rollback, savepoint-rollback-to, savepoint-release, select-for-update, select-for-share, for-update-skip-locked, for-update-nowait, advisory-lock, advisory-try-lock, advisory-unlock, set-isolation-serializable, set-isolation-repeatable-read); SERIALIZABLE write skew is wire-verified separately (source: test-scripts/feature-matrix/features.py).

Not wired: LOCK TABLE takes no lock (source: src/query/sql/parser.rs, parse_statement).

Advisory locks

pg_advisory_lock, pg_advisory_xact_lock, pg_try_advisory_lock, pg_try_advisory_xact_lock, pg_advisory_unlock and pg_advisory_unlock_all are implemented, each with the single bigint key and the two-int key overloads. Session locks are released at session end, transaction locks at commit or rollback (source: src/query/engine.rs, try_handle_advisory_lock; tests test_advisory_lock_acquire_try_unlock_two_sessions, test_advisory_lock_two_int_overload, test_advisory_xact_lock_released_on_commit, test_advisory_lock_released_on_session_end). The shared variants (pg_advisory_lock_shared and so on) were not found. They are recognised only when the call is the whole statement (SELECT pg_advisory_lock(1)), not inside a larger query: Not verified: no test of an advisory call embedded in another expression was found.

Cursors

DECLARE name [BINARY] [ASENSITIVE | INSENSITIVE] [[NO] SCROLL] CURSOR [WITH | WITHOUT HOLD] FOR query runs the query and buffers the whole result at DECLARE time. FETCH and MOVE accept NEXT, PRIOR, FORWARD [n | ALL], BACKWARD [n | ALL], a bare count or ALL, followed by FROM | IN name. CLOSE name | ALL (source: src/query/sql/parser.rs, parse_declare_cursor; src/query/engine.rs, LogicalPlan::FetchCursor arm). FIRST, LAST, ABSOLUTE n and RELATIVE n are not accepted. Not verified: no cursor test was found in the feature matrix or diff corpus.

EXPLAIN

EXPLAIN [ANALYZE] statement and EXPLAIN (option [value], ...) statement. Options: FORMAT JSON or FORMAT TEXT, ANALYZE [TRUE | FALSE]; every other option (VERBOSE, COSTS, BUFFERS, TIMING, …) is skipped (source: src/query/sql/parser.rs, parse_explain).

The result is one QUERY PLAN text column. The plan names the access path the executor would really take (primary-key lookup, primary-key IN list, unique index, secondary index, sequential scan) and a row estimate from table statistics. Cost figures are not a cost model: total cost equals the estimated row count and startup cost is a constant. JSON output uses PostgreSQL's keys (Node Type, Plans, Startup Cost, Total Cost, Plan Rows, Plan Width). EXPLAIN ANALYZE runs the statement (including DML) and appends actual time=... rows=... loops=1 to the root line plus Planning Time: 0.1 ms (a fixed string) and the measured Execution Time (source: src/plan/explain.rs, module comment, cost_str_rows, append_analyze_suffix; src/query/engine.rs, LogicalPlan::Explain arm). Per-node actual figures are not produced. Coverage: feature-matrix explain, explain-analyze (source: test-scripts/feature-matrix/features.py).

DO blocks

DO [LANGUAGE plpgsql] $$ ... $$ runs the body through the PL/pgSQL interpreter. If the interpreter reports the body as unsupported or unparsable, the block is logged and returns success without running; it then tries the trigger-body lowering, else succeeds as a no-op with a warning (source: src/query/engine.rs, LogicalPlan::DoBlock arm). See PL/pgSQL.

Prepared statements

SQL-level PREPARE name [(types)] AS statement, EXECUTE name [(args)] and DEALLOCATE are handled by text substitution before parsing. Executing an unknown name gives 26000 (source: src/query/engine.rs, execute_unguarded, split_prepare, substitute_execute_args; src/protocol/postgres/mod.rs, error_to_sqlstate). Protocol-level prepared statements (Parse/Bind/Execute) belong to the wire, see PostgreSQL protocol.

Command tags

The PostgreSQL wire derives the command tag (INSERT 0 n, UPDATE n, SELECT n, CREATE TABLE, …) from the statement and the result; statements with RETURNING report the DML tag (source: src/protocol/postgres/mod.rs, statement_command_tag, select_path_command_tag).

Error codes

Engine errors are mapped to SQLSTATE by the PostgreSQL wire (source: src/protocol/postgres/mod.rs, PostgresHandler::error_to_sqlstate):

Condition SQLSTATE
Syntax error 42601
Table or relation not found (including nextval of a missing sequence) 42P01
Column not found 42703
Ambiguous column 42702
Index not found 42704
Relation, table or index already exists 42P07
Function or procedure already exists 42723
Other object already exists 42710
GROUP BY violation 42803
Other schema or semantic error 42000
Permission denied 42501
Schema exists / missing / not empty / bad name 42P06 / 3F000 / 2BP01 / 42939
Unique violation 23505
NOT NULL violation 23502
Foreign key violation 23503
CHECK violation 23514
Other constraint error 23000
Division by zero 22012
Numeric value out of range 22003
String too long for column 22001
Invalid text representation (type mismatch on input) 22P02
Invalid argument 22023
Square root of a negative number 2201F
pgvector data exception 22000
Scalar subquery returned more than one row 21000
Feature not supported 0A000
Serialization failure 40001
Deadlock 40P01
Lock timeout or lock not available (NOWAIT) 55P03
currval before nextval in the session 55000
In a failed transaction 25P02
Write in a read-only transaction 25006
Savepoint not found 3B001
Prepared statement not found 26000
Query cancelled by timeout 57014
Storage, WAL, SSTable, compaction or corruption error 58000
Anything else XX000

Constraint errors are classified by the text of the message (for example "unique" or "duplicate" gives 23505), not by a typed error (source: src/protocol/postgres/mod.rs, error_to_sqlstate). There is no 42883 (undefined function): an unknown function returns NULL, see Functions and operators.