↑↓ 选择↵ 打开⌫ 切换范围完整搜索

PG.CENTER 连接 PostgreSQL 文档、百科与生态知识。由 Pigsty 维护。

Wiki / SQLSTATE

58P03 — file_name_too_long

文件访问因路径名过长失败,对应 ENAMETOOLONG。

英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。

当前阅读 PG 18·选择有来源记录的版本

aliases
未知
class name
System Error (errors external to PostgreSQL itself)
condition name
file_name_too_long
lang
en
sqlstate
58P03

版本定义 PG 18

58P03

速览 {#at-a-glance}

58P03 由 PostgreSQL 文件访问 errno 辅助函数在保存的 OS errno 为 ENAMETOOLONG 时选择。它不是固定的 file name too long 主消息;调用者提供带 %m 的消息,辅助函数提供 SQLSTATE。

含义 {#meaning}

errcode_for_file_access() 将 ENAMETOOLONG 映射为 ERRCODE_FILE_NAME_TOO_LONG。同一完整 switch 还把 ENOENT 映射为 58P01、EEXIST 映射为 58P02、ENOSPC 映射为 53100、EIO 映射为 58030,其他 errno 可能落到别的代码。辅助函数明确要求调用者的主消息保留 %m,所以 OS 文本和 locale(区域设置)是诊断的一部分。

18.6 固定后端调用者包括 base backup 的 could not access directory "%s": %m 和表空间的 could not set permissions on directory "%s": %m;两者先以 ERROR 发出,再由辅助函数选择代码。这说明实际操作上下文很重要:同一 SQLSTATE 可以来自不同文件操作,其他调用者的文件名过长也可能使用不同主消息模板。

消息 {#messages}

  • ERROR,base backup 代表主消息:could not access directory "%s": %m。
  • ERROR,表空间代表主消息:could not set permissions on directory "%s": %m。
  • %m 展开为保存的 OS 错误文本;若 errno 是 ENAMETOOLONG,errcode_for_file_access() 提供 SQLSTATE 58P03。

本次核验没有找到脱离调用者的固定 58P03 主消息。不要把 %m 换成臆造的英文句子,也不要仅凭条件名推断扩展报文。

诊断 {#diagnosis}

保留完整主消息/详细信息/上下文、操作和组件、完整路径、OS errno、文件系统限制、编码及 PostgreSQL 对象名映射。区分文件系统组件长度限制与 PostgreSQL 标识符限制,也要区分辅助函数的 ENAMETOOLONG 分支和 ENOENT、EEXIST、磁盘满、I/O 分支。固定源码确认的是辅助函数与代表调用者,不声称在特定主机自然复现。

处理 {#response}

使用组件和文件系统接受的路径/名称,或移动目标并保留持久映射。客户端 ERROR 若发生在显式事务中,继续执行前必须 ROLLBACK 或回到已有保存点;修正路径后重试受影响操作,不要继续发送无关语句。启动/后台调用可能没有客户端事务;后端已终止时使用新连接。上报时保留原始 OS 详细信息。

版本 {#versions}

锁定目录从 18.0 记录 58P03;固定辅助函数与调用者来自 PostgreSQL 18.6。本页仅源码复核,没有自然运行声明。

相关 {#related}

58P01、58P02、58030

来源 {#sources}

src/backend/utils/error/elog.c#L867-L942

src/backend/backup/basebackup_server.c#L119-L124

src/backend/commands/tablespace.c#L606-L618

结构化证据记录保存 errno 映射、代表主消息与源码/运行边界。

比较版本

SQLSTATE 证据与已记录的运行版本

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read locked definition snapshot.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "58P03 is file_name_too_long in SQLSTATE Class 58."
}
claims · resolved-paths
{
  "claim_id": "resolved-paths",
  "limits": "The helper establishes the code mapping; it does not fix one primary message for every caller or prove a natural host reproduction.",
  "method": "Read the complete errno switch and representative caller guards.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.0",
    "src.path.1",
    "src.path.2"
  ],
  "statement": "errcode_for_file_access maps ENAMETOOLONG to ERRCODE_FILE_NAME_TOO_LONG and representative backend callers retain %m while emitting ERROR."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use locked catalogue boundary.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 58P03 from 18.0; it does not prove the exact introduction rationale."
}
messages · message.0
{
  "limits": "",
  "message_id": "message.0",
  "path": "",
  "position": 0,
  "raw": {
    "code_selection": "errcode_for_file_access()",
    "id": "message.0",
    "primary_template": "could not access directory \"%s\": %m",
    "severity_source": "ERROR",
    "sources": [
      "src.path.1"
    ],
    "sqlstate": "58P03"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.1"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "could not access directory \" \":",
      "position": 0,
      "role": "",
      "template": "could not access directory \"%s\": %m"
    }
  ]
}
messages · message.1
{
  "limits": "",
  "message_id": "message.1",
  "path": "",
  "position": 1,
  "raw": {
    "code_selection": "errcode_for_file_access()",
    "id": "message.1",
    "primary_template": "could not set permissions on directory \"%s\": %m",
    "severity_source": "ERROR",
    "sources": [
      "src.path.2"
    ],
    "sqlstate": "58P03"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.2"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "could not set permissions on directory \" \":",
      "position": 0,
      "role": "",
      "template": "could not set permissions on directory \"%s\": %m"
    }
  ]
}
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#L448"
}
sources · src.path.0
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/error/elog.c",
  "position": 1,
  "sha256": "766d30a426ba1d9597657bd46fb890da3e37e4ae53a83d1245bf082ed9433c33",
  "source_id": "src.path.0",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/error/elog.c#L867"
}
sources · src.path.1
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/backup/basebackup_server.c",
  "position": 2,
  "sha256": "1447d7223926f903d27744605f9caec8a610d78a9f7a7864bb3afb6b3073ac19",
  "source_id": "src.path.1",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/backup/basebackup_server.c#L119"
}
sources · src.path.2
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/commands/tablespace.c",
  "position": 3,
  "sha256": "f0369bece6339d18cd7d4a29b5fa3010447c3b8ece235c64b0d4fbf5f96a5317",
  "source_id": "src.path.2",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablespace.c#L606"
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:e0ec3ffa05c398032d9d50ddbdd5191c83daa657cd37fbebd1ca5cb4e4802bf0

正文语言: zh-Hans · english-manuals:e0ec3ffa05c398032d9d50ddbdd5191c83daa657cd37fbebd1ca5cb4e4802bf0