42P14 — 无效预备语句定义
PREPARE 定义预备语句时失败。
英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。
当前阅读 PG 18·选择有来源记录的版本
- aliases
- 未知
- class name
- Syntax Error or Access Rule Violation
- condition name
- invalid_prepared_statement_definition
- lang
- en
- sqlstate
- 42P14
版本定义 PG 18
42P14 — 无效预备语句定义
速览 {#at-a-glance}
42P14(invalid_prepared_statement_definition)PREPARE 命令可能在定义预备语句时失败。
含义 {#meaning}
固定的 18.6 PrepareQuery 路径在注册命名预备语句前,拒绝 SQL PREPARE 的空名称或空指针;这是因为扩展协议有独立的 unnamed 语句槽。因此,协议 Parse 消息中的空名称不自动等于 42P14,空的 SQL 引用标识符也可能先在词法或解析阶段失败。
诊断 {#diagnosis}
准确记录客户端发送的是 SQL PREPARE 还是扩展协议 Parse,并保留语句名。区分 SQL PREPARE 的空名称检查、合法的协议 unnamed 语句、26000(预备语句不存在)以及后续参数/类型错误;空的引用标识符可能在到达此 guard 前就失败。
处理 {#response}
SQL PREPARE 应使用非空且引用方式一致的语句名。扩展协议若本来要使用 unnamed 语句槽,就保留该协议语义,不要改写成 SQL PREPARE。若名称由框架生成,检查命名层,并确认后续 EXECUTE 与 DEALLOCATE 使用同一会话。显式事务中的 ERROR 之后,下一条命令前仍需 ROLLBACK 或回滚到错误前的保存点。
消息 {#messages}
固定源码中的代表性消息为:invalid statement name: must not be empty(ERROR;没有占位符)。
版本 {#versions}
锁定目录显示该条件最早见于 PostgreSQL 7.4;行为说明固定在 PostgreSQL 18.6 源码,目录存在范围不等于每条消息或功能都从该版本开始。
相关 {#related}
来源 {#sources}
源码消息、行号和证据边界见 作者证据。
src/backend/commands/prepare.c:73-75(fixed source)src/backend/tcop/postgres.c:1433-1459(fixed source)
比较版本
SQLSTATE 证据与已记录的运行版本
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": ""
}来源引用
定义来源
center · PostgreSQL 18 · english-manuals:a8f4fbfb155573dd75bfa523997c1b125a0e138be9226e12e93aabe2e4415c42
正文语言: zh-Hans · english-manuals:a8f4fbfb155573dd75bfa523997c1b125a0e138be9226e12e93aabe2e4415c42