42622 — 名称过长(name_too_long)
标识符或 name 值超出长度上限。
英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。
当前阅读 PG 18·选择有来源记录的版本
- aliases
- 未知
- class name
- Syntax Error or Access Rule Violation
- condition name
- name_too_long
- lang
- en
- sqlstate
- 42622
版本定义 PG 18
42622 — 名称过长
速览 {#at-a-glance}
SQLSTATE 42622 是 Class 42 中的 name_too_long。42622 表示名称过长。固定源码路径包括超长 SQL 标识符的扫描器 NOTICE 和二进制 name 接收 ERROR;普通文本输入也可能直接截断而不产生这两种诊断。
含义 {#meaning}
42622 表示名称过长,并有不止一个 producer。二进制 name 接收函数 namerecv 通过 pq_getmsgtext 读取外部文本,把字节数与 NAMEDATALEN 比较,并在复制值前以 ERROR 发出 identifier too long 和长度 DETAIL。解析器的 truncate_identifier 路径不同:它把超长 SQL 标识符截到多字节边界,然后由扫描器以 warn = true 调用时发出带 SQLSTATE 42622 的 NOTICE,说明标识符将被截断。普通文本输入走独立的 namein,可能静默截断,不会进入 namerecv。
诊断 {#diagnosis}
先区分输入边界和 severity。二进制类型接收失败有 identifier too long 主报文和长度 DETAIL;SQL 标识符可能产生包含原名与截断名的 NOTICE;text cast 到 name 则可能静默截断。二进制输入要记录 format code 和 type OID,扫描器输入则记录准确 SQL 标识符和服务器 NOTICE。本批有意没有选定自然 runtime:选定版本的 text cast 会截断,不能把它当成任一源码分支的证据。固定 guard 不表示每个超长值或标识符都属于同一已观察路径。
处理 {#response}
在相应输入边界执行长度校验,把较长应用值存为 text 或其他合适类型。如果二进制客户端确实发送了超长 name 值,应在该边界修复编码器或应用 schema;如果问题是扫描器 NOTICE,就缩短或重命名 SQL 标识符并检查目录中的最终名称。不要用 RAISE 伪造此码,不要把静默文本截断当作证据,也不要把一种 severity/path 改报成另一种。
报文 {#messages}
固定扫描器分支以明确的 NOTICE 和 SQLSTATE 42622 发出主报文。REL_18_6 的原始主报文模板是 identifier "%s" will be truncated to "%.*s";REL_10_23 是 identifier "%s" will be truncated to "%s"。固定 namerecv 分支以明确的 ERROR 发出主报文 identifier too long 和 DETAIL Identifier must be less than %d characters.;%d 在该源码路径中是 NAMEDATALEN。两者都只在本页确认源码边界,文本输入路径可能静默。只有客户端异常或 NOTICE 而没有服务器 SQLSTATE 及对应扫描器/二进制上下文时,不能识别某个 42622 路径。
代表案例 {#case}
本页没有选定的自然 SQL 运行;这里只记录固定源码边界,不使用伪造触发器。
版本 {#versions}
本页没有选定的自然 SQL 运行;固定的 REL_18_6/REL_10_23 源码边界不能证明所有中间版本的行为。
相关 {#related}
来源 {#sources}
src.errcodes.18.6— fixederrcodes.txtdefinition at commit724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-2566e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba(source).src.name-recv-too-long.18.6—src/backend/utils/adt/name.catREL_18_6commit724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-2564c4b4dc71f55ba73dbc24dd94b3385986fdb3179702b3d100cbad7ab00db7762(source).src.name-recv-too-long.10.23—src/backend/utils/adt/name.catREL_10_23commit02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-2567c7da791e528aafdbf26930cd4bd34386806818c19d2ee4b78bbe138b93f4a84(source).src.identifier-truncate.18.6/src.identifier-truncate.10.23— fixed parsertruncate_identifierNOTICE 分支;blob SHA-25699cc6839927c19a9f85a1e5fbc8e848b376a7073477a04a0bbfe106ecdb2273f/3c59a33f3cb5eaa0c3932859eb15e927f459a5feb5f40ca96fef5ef74495d67c(18.6 source, 10.23 source).src.calls.REL_18_6/src.calls.REL_10_23— fixed call scans, SHA-2569ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf/00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
比较版本
SQLSTATE 证据与已记录的运行版本
cases · identifier_too_long_boundary
{
"assertions": [],
"case_id": "identifier_too_long_boundary",
"cleanup": "No persistent objects; close the runner connection.",
"has_snippet": false,
"position": 0,
"preconditions": [
"The fixed REL_18_6 and REL_10_23 source paths are available."
],
"repair": "Use a protocol path that validates the name value before retrying, or keep long user text outside the name type.",
"trigger": "No ordinary SQL cast is claimed: fixed source shows 42622 in binary name receive, while text casts truncate identifiers before that path.",
"versions": [
"10",
"18"
]
}claims · identity.class-and-condition
{
"claim_id": "identity.class-and-condition",
"limits": "Directory identity does not identify every backend path.",
"method": "Read fixed errcodes.txt and the locked catalogue metadata.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "42622 is the name_too_long condition in Class 42."
}claims · mechanism.backend-path
{
"claim_id": "mechanism.backend-path",
"limits": "Other calls can use the same SQLSTATE with different context or dynamic fields.",
"method": "Trace the resolved REL_18_6 and REL_10_23 source call records at the locked commits.",
"position": 1,
"runtime": [],
"sources": [
"src.name-recv-too-long.18.6",
"src.name-recv-too-long.10.23",
"src.identifier-truncate.18.6",
"src.identifier-truncate.10.23"
],
"statement": "The fixed source calls for 42622 include the mechanism and message boundary selected for this page."
}claims · mechanism.identifier-truncation-notice
{
"claim_id": "mechanism.identifier-truncation-notice",
"limits": "No natural runtime is selected for either branch in this batch; ordinary namein text input may be silent.",
"method": "Read truncate_identifier and its scanner call guard in fixed scansup.c/scan.l call context.",
"position": 2,
"runtime": [],
"sources": [
"src.identifier-truncate.18.6",
"src.identifier-truncate.10.23",
"src.name-recv-too-long.18.6",
"src.name-recv-too-long.10.23"
],
"statement": "The parser truncates an overlong SQL identifier and can emit a 42622 NOTICE when the scanner requests warning, while binary namerecv emits the separate 42622 ERROR path."
}claims · versions.catalogue-boundary
{
"claim_id": "versions.catalogue-boundary",
"limits": "Definition presence is not an exact behavioral introduction.",
"method": "Read generated facts and selected summaries.",
"position": 3,
"runtime": [],
"sources": [
"src.errcodes.18.6",
"src.calls.REL_18_6",
"src.calls.REL_10_23"
],
"statement": "The locked catalogue records 42622; runtime scope is limited to the selected targets."
}messages · message.name-recv
{
"limits": "Only the binary name receive path is source-confirmed here.",
"message_id": "message.name-recv",
"path": "",
"position": 0,
"raw": {
"detail_template": "Identifier must be less than %d characters.",
"id": "message.name-recv",
"limits": "Only the binary name receive path is source-confirmed here.",
"primary_template": "identifier too long",
"severity_source": "explicit ERROR",
"sources": [
"src.name-recv-too-long.18.6",
"src.name-recv-too-long.10.23"
],
"sqlstate": "42622"
},
"severity": "explicit ERROR",
"sources": [
"src.name-recv-too-long.18.6",
"src.name-recv-too-long.10.23"
],
"templates": [
{
"kind": "primary",
"literal": "identifier too long",
"position": 0,
"role": "",
"template": "identifier too long"
},
{
"kind": "detail",
"literal": "Identifier must be less than characters.",
"position": 1,
"role": "",
"template": "Identifier must be less than %d characters."
}
]
}messages · message.identifier-truncate-notice
{
"limits": "Scanner identifier path only; 18.6 and 10.23 use different formatting for the clipped second value.",
"message_id": "message.identifier-truncate-notice",
"path": "",
"position": 1,
"raw": {
"id": "message.identifier-truncate-notice",
"limits": "Scanner identifier path only; 18.6 and 10.23 use different formatting for the clipped second value.",
"primary_variants": [
{
"source": "src.identifier-truncate.18.6",
"target": "REL_18_6",
"template": "identifier \"%s\" will be truncated to \"%.*s\""
},
{
"source": "src.identifier-truncate.10.23",
"target": "REL_10_23",
"template": "identifier \"%s\" will be truncated to \"%s\""
}
],
"severity_source": "explicit NOTICE",
"sources": [
"src.identifier-truncate.18.6",
"src.identifier-truncate.10.23"
],
"sqlstate": "42622"
},
"severity": "explicit NOTICE",
"sources": [
"src.identifier-truncate.18.6",
"src.identifier-truncate.10.23"
],
"templates": [
{
"kind": "primary",
"literal": "identifier \" \" will be truncated to \"%.*s\"",
"position": 0,
"role": "REL_18_6",
"template": "identifier \"%s\" will be truncated to \"%.*s\""
},
{
"kind": "primary",
"literal": "identifier \" \" will be truncated to \" \"",
"position": 1,
"role": "REL_10_23",
"template": "identifier \"%s\" will be truncated to \"%s\""
}
]
}sources · src.errcodes.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/errcodes.txt",
"position": 0,
"sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
"source_id": "src.errcodes.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt"
}sources · src.calls.REL_18_6
{
"commit": "",
"docs_url": "",
"kind": "local_artifact",
"location": "",
"path": "raw/calls/REL_18_6.jsonl",
"position": 1,
"sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
"source_id": "src.calls.REL_18_6",
"tag": "",
"url": ""
}sources · src.calls.REL_10_23
{
"commit": "",
"docs_url": "",
"kind": "local_artifact",
"location": "",
"path": "raw/calls/REL_10_23.jsonl",
"position": 2,
"sha256": "00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c",
"source_id": "src.calls.REL_10_23",
"tag": "",
"url": ""
}sources · src.name-recv-too-long.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/name.c",
"position": 3,
"sha256": "4c4b4dc71f55ba73dbc24dd94b3385986fdb3179702b3d100cbad7ab00db7762",
"source_id": "src.name-recv-too-long.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/name.c#L91-L95"
}sources · src.name-recv-too-long.10.23
{
"commit": "02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/name.c",
"position": 4,
"sha256": "7c7da791e528aafdbf26930cd4bd34386806818c19d2ee4b78bbe138b93f4a84",
"source_id": "src.name-recv-too-long.10.23",
"tag": "REL_10_23",
"url": "https://github.com/postgres/postgres/blob/02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4/src/backend/utils/adt/name.c#L89-L93"
}sources · src.identifier-truncate.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/parser/scansup.c",
"position": 5,
"sha256": "99cc6839927c19a9f85a1e5fbc8e848b376a7073477a04a0bbfe106ecdb2273f",
"source_id": "src.identifier-truncate.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/parser/scansup.c#L91-L102"
}sources · src.identifier-truncate.10.23
{
"commit": "02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/parser/scansup.c",
"position": 6,
"sha256": "3c59a33f3cb5eaa0c3932859eb15e927f459a5feb5f40ca96fef5ef74495d67c",
"source_id": "src.identifier-truncate.10.23",
"tag": "REL_10_23",
"url": "https://github.com/postgres/postgres/blob/02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4/src/backend/parser/scansup.c#L187-L208"
}sources · manifest.42622
{
"commit": "",
"docs_url": "",
"kind": "local_artifact",
"location": "",
"path": "verify/cases/42622/cases.json",
"position": 7,
"sha256": "798c2ea09dacbb975c6ba84458e71f2f20fe4aeb7d790193f16425bce09d6abf",
"source_id": "manifest.42622",
"tag": "",
"url": ""
}来源引用
定义来源
center · PostgreSQL 18 · english-manuals:661ff6a1944ccdf36f48095a18eaa138aa2c9f70efe6a74c191b9e1b105a60c1
正文语言: zh-Hans · english-manuals:661ff6a1944ccdf36f48095a18eaa138aa2c9f70efe6a74c191b9e1b105a60c1