22P05 — untranslatable_character
字符在目标编码中没有对应表示。
英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。
当前阅读 PG 18·选择有来源记录的版本
- aliases
- 未知
- class name
- Data Exception
- condition name
- untranslatable_character
- lang
- en
- sqlstate
- 22P05
版本定义 PG 18
22P05
速览 {#at-a-glance}
PostgreSQL 能识别源字符,却无法在目标编码中表示它。固定辅助函数 以 ERROR 发出 character with byte sequence %s in encoding "%s" has no equivalent in encoding "%s",其中包含字节序列和两种编码名。
含义 {#meaning}
report_untranslatable_char(src_encoding, dest_encoding, ...) 计算源多字节字符长度,把问题字节格式化为 0x..,当目标转换表没有等价字符时抛出 22P05。也就是说源字符已经足够合法、可以识别,但目标表示无法承载它。它不同于坏源字节:固定转换循环可以调用 report_invalid_encoding,后者使用 22021。
报文 {#messages}
ERROR主消息:character with byte sequence %s in encoding "%s" has no equivalent in encoding "%s"- 固定调用没有 DETAIL 或 HINT。
诊断 {#diagnosis}
读取主消息中的字节序列、源编码、目标编码和转换方向。检查 client_encoding、服务器/数据库编码、导入或 COPY 文件编码及实际转换边界。不能仅因字符是非 ASCII 就认定是 22P05;坏源字节和普通类型输入失败走不同路径。
处理 {#response}
选择能够表示数据的目标编码,或修正生产端和转换边界,同时保留该字符。除非业务明确允许有损处理,不要静默替换或丢弃。引用路径是 ERROR:显式事务中重试前执行 ROLLBACK 或 ROLLBACK TO SAVEPOINT;自动提交模式下修正编码或输入后重新提交。该源码路径不表示 FATAL 或必须重置连接。
版本 {#versions}
锁定目录从 PostgreSQL 7.4 记录此条件。引用的报告辅助函数 和代表性转换分支来自 PostgreSQL 18.6 REL_18_6;本次没有运行编码转换案例。
相关 {#related}
来源 {#sources}
src/backend/utils/mb/mbutils.c#L1862-L1902
src/backend/utils/mb/conv.c#L674-L684
结构化证据记录保存精确主消息以及合法字符/坏字节边界。
比较版本
SQLSTATE 证据与已记录的运行版本
claims · identity
{
"claim_id": "identity",
"limits": "",
"method": "Read fixed definition.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "22P05 is untranslatable_character in SQLSTATE Class 22."
}claims · conversion-path
{
"claim_id": "conversion-path",
"limits": "",
"method": "Read the complete reporting function.",
"position": 1,
"runtime": [],
"sources": [
"src.path.report"
],
"statement": "report_untranslatable_char computes source multibyte character bytes and reports source and destination encoding names when conversion has no equivalent destination character."
}claims · invalid-source-boundary
{
"claim_id": "invalid-source-boundary",
"limits": "The cited loop is representative; other conversion procedures call the same reporting helper.",
"method": "Read the conversion failure and invalid-input branches.",
"position": 2,
"runtime": [],
"sources": [
"src.path.convert",
"src.path.report"
],
"statement": "The conversion loop calls report_untranslatable_char for a valid source character with no destination mapping, while malformed remaining UTF-8 bytes fall through to report_invalid_encoding and 22021."
}claims · history
{
"claim_id": "history",
"limits": "",
"method": "Use catalogue boundary.",
"position": 3,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "The locked catalogue records 22P05 from 7.4; that boundary does not prove exact implementation introduction."
}messages · message.convert
{
"limits": "",
"message_id": "message.convert",
"path": "",
"position": 0,
"raw": {
"id": "message.convert",
"primary_template": "character with byte sequence %s in encoding \"%s\" has no equivalent in encoding \"%s\"",
"severity_source": "ERROR",
"sources": [
"src.path.report"
],
"sqlstate": "22P05"
},
"severity": "ERROR",
"sources": [
"src.path.report"
],
"templates": [
{
"kind": "primary",
"literal": "character with byte sequence in encoding \" \" has no equivalent in encoding \" \"",
"position": 0,
"role": "",
"template": "character with byte sequence %s in encoding \"%s\" has no equivalent in encoding \"%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#L209"
}sources · src.path.report
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/mb/mbutils.c",
"position": 1,
"sha256": "2c034d792a3fbc402d673d6e08bd6a2198651bfd3c057176d4098f7e4a215dfb",
"source_id": "src.path.report",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/mb/mbutils.c#L1862"
}sources · src.path.convert
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/mb/conv.c",
"position": 2,
"sha256": "75d962d1178bbe5dd7781b6b65b1c1135a391ece21042b249876560103933e27",
"source_id": "src.path.convert",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/mb/conv.c#L674"
}来源引用
定义来源
center · PostgreSQL 18 · english-manuals:5fd4a112f74a8a25ae4b5ca37dd47bb09572036e2ef2afed347e9098330f937c
正文语言: zh-Hans · english-manuals:5fd4a112f74a8a25ae4b5ca37dd47bb09572036e2ef2afed347e9098330f937c