select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

SQLSTATE / CLASS 42 · SYNTAX ERROR OR ACCESS RULE VIOLATION

invalid_prepared_statement_definition

SQLSTATE
42P14
Condition name
invalid_prepared_statement_definition
Class
Syntax Error or Access Rule Violation
Source macro
ERRCODE_INVALID_PSTATEMENT_DEFINITION
Evidence
Source path confirmed
Analysis & operational context

English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗

<h1>42P14 — Invalid prepared statement definition</h1>

At a glance

42P14 (invalid_prepared_statement_definition) A PREPARE command can fail while defining the prepared statement itself.

Meaning

The fixed 18.6 PrepareQuery path rejects a null or empty name for the SQL PREPARE command before the named prepared statement can be registered; the guard exists because the extended protocol has a separate unnamed statement slot. An empty name in a protocol Parse message is therefore not automatically 42P14, and an empty quoted SQL identifier can fail earlier in lexical or parse validation.

Diagnosis

Capture whether the client sent SQL PREPARE or an extended-protocol Parse, and preserve the exact statement name. Distinguish SQL PREPARE's empty-name guard from a legal unnamed protocol statement, 26000 (prepared statement does not exist), and later parameter/type errors; an empty quoted identifier may fail before this guard is reached.

Response

For SQL PREPARE, send a non-empty, consistently quoted statement name. For extended protocol, retain the unnamed statement slot when that is intentional instead of translating it into SQL PREPARE. If a framework generates names, inspect that naming layer and verify the same session is used for later EXECUTE and DEALLOCATE. An ERROR inside an explicit transaction still requires ROLLBACK or ROLLBACK TO a pre-error savepoint before the next command.

Messages

Representative source message: invalid statement name: must not be empty (ERROR; it has no placeholders).

Versions

The locked catalogue shows this condition by PostgreSQL 7.4; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

Source evidence

Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.

42P14 is the invalid_prepared_statement_definition condition in Class 42.

Method: Read fixed REL_18_6 errcodes.txt and locked facts.

Limits: Identity does not enumerate all source branches or client failures.

src.errcodes.42P14.18.6

PrepareQuery rejects a null or empty name for SQL PREPARE before a named statement is registered; its source comment identifies the separate extended-protocol unnamed statement slot. An empty name in a protocol Parse message is therefore not automatically 42P14.

Method: Read selected resolved REL_18_6 report groups and message roles.

Limits: Representative confirmed core paths only; not exhaustive historical or extension coverage.

src.call.42P14.d04baad66169863a1a388152 src.call.42P14.protocol-unnamed

Locked catalogue snapshots show this condition by PostgreSQL 7.4; source behavior here is fixed at PostgreSQL 18.6.

Method: Read locked catalogue facts and definition snapshot.

Limits: First observed release is a lower bound, not precise behavioral introduction.

src.errcodes.42P14.18.6

Message templates

ERROR · message.variant-1

Primary

invalid statement name: must not be empty

Placeholders remain dynamic source fields; no concrete runtime value is claimed.

Reproduction & repair cases

No reproduction case is attached to this condition.

Recorded runtime evidence

No runtime observation is attached to this entry.

Definition snapshot: english-manuals:a76057229240aff0d0e67580569… · English manual source