42P14 — Invalid prepared statement definition
42P14 (invalid_prepared_statement_definition) A PREPARE command can fail while defining the prepared statement itself.
English manual coverage begins with PostgreSQL 8.1. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- aliases
- Unknown
- class name
- Syntax Error or Access Rule Violation
- condition name
- invalid_prepared_statement_definition
- lang
- en
- sqlstate
- 42P14
Definition PG 18
42P14 — Invalid prepared statement definition
At a glance {#at-a-glance}
42P14 (invalid_prepared_statement_definition) A PREPARE command can fail while defining the prepared statement itself.
Meaning {#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 {#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 {#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 {#messages}
Representative source message: invalid statement name: must not be empty (ERROR; it has no placeholders).
Versions {#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.
Related {#related}
Sources {#sources}
Source messages, line anchors, and evidence limits are recorded in authored evidence.
src/backend/commands/prepare.c:73-75(fixed source)src/backend/tcop/postgres.c:1433-1459(fixed source)
Compare versions
SQLSTATE evidence and recorded runtime versions
claims · identity.class-and-condition
{
"claim_id": "identity.class-and-condition",
"limits": "Identity does not enumerate all source branches or client failures.",
"method": "Read fixed REL_18_6 errcodes.txt and locked facts.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.42P14.18.6"
],
"statement": "42P14 is the invalid_prepared_statement_definition condition in Class 42."
}claims · mechanism.selected-source-path
{
"claim_id": "mechanism.selected-source-path",
"limits": "Representative confirmed core paths only; not exhaustive historical or extension coverage.",
"method": "Read selected resolved REL_18_6 report groups and message roles.",
"position": 1,
"runtime": [],
"sources": [
"src.call.42P14.d04baad66169863a1a388152",
"src.call.42P14.protocol-unnamed"
],
"statement": "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."
}claims · versions.catalogue-boundary
{
"claim_id": "versions.catalogue-boundary",
"limits": "First observed release is a lower bound, not precise behavioral introduction.",
"method": "Read locked catalogue facts and definition snapshot.",
"position": 2,
"runtime": [],
"sources": [
"src.errcodes.42P14.18.6"
],
"statement": "Locked catalogue snapshots show this condition by PostgreSQL 7.4; source behavior here is fixed at PostgreSQL 18.6."
}messages · message.variant-1
{
"limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
"message_id": "message.variant-1",
"path": "",
"position": 0,
"raw": {
"detail_templates": [],
"hint_templates": [],
"id": "message.variant-1",
"limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
"primary_template": "invalid statement name: must not be empty",
"roles": [
{
"role": "errmsg",
"template": "invalid statement name: must not be empty"
}
],
"severity_source": "ERROR",
"sources": [
"src.call.42P14.d04baad66169863a1a388152"
],
"sqlstate": "42P14"
},
"severity": "ERROR",
"sources": [
"src.call.42P14.d04baad66169863a1a388152"
],
"templates": [
{
"kind": "primary",
"literal": "invalid statement name: must not be empty",
"position": 0,
"role": "",
"template": "invalid statement name: must not be empty"
}
]
}sources · src.errcodes.42P14.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "line 395",
"path": "src/backend/utils/errcodes.txt",
"position": 0,
"sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
"source_id": "src.errcodes.42P14.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L395"
}sources · src.call.42P14.d04baad66169863a1a388152
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "lines 73-75",
"path": "src/backend/commands/prepare.c",
"position": 1,
"sha256": "e37fbd5f7618e5554561d9293d8c3af7cf3190c62c5c6bbceb3fe8b97be17956",
"source_id": "src.call.42P14.d04baad66169863a1a388152",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/prepare.c#L73-L75"
}sources · src.call.42P14.protocol-unnamed
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "lines 1433-1459",
"path": "src/backend/tcop/postgres.c",
"position": 2,
"sha256": "9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061",
"source_id": "src.call.42P14.protocol-unnamed",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/tcop/postgres.c#L1433-L1459"
}sources · src.calls.REL_18_6.42P14
{
"commit": "",
"docs_url": "",
"kind": "local_artifact",
"location": "",
"path": "raw/calls/REL_18_6.jsonl",
"position": 3,
"sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
"source_id": "src.calls.REL_18_6.42P14",
"tag": "",
"url": ""
}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · english-manuals:a8f4fbfb155573dd75bfa523997c1b125a0e138be9226e12e93aabe2e4415c42
Text language: en · english-manuals:a8f4fbfb155573dd75bfa523997c1b125a0e138be9226e12e93aabe2e4415c42