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

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

Wiki / SQLSTATE

42939 — 保留名称

对象名使用了保留名称,如模式或表空间。

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

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

aliases
未知
class name
Syntax Error or Access Rule Violation
condition name
reserved_name
lang
en
sqlstate
42939

版本定义 PG 18

42939 — 保留名称

速览 {#at-a-glance}

42939(reserved_name)按对象类型拒绝保留名称。选定的 18.6 路径覆盖模式、表空间、创建角色和角色说明语法;必须根据报文中的对象类型判断具体规则。

含义 {#meaning}

创建模式时,保留的 pg_ 前缀会触发 unacceptable schema name "%s" 及系统模式 DETAIL;创建表空间有对应的系统表空间报文。CREATE ROLE 对 pg_ 前缀报告 role name "%s" is reserved。此外,语法中的 RoleId 在角色名位置拒绝 public、none、SESSION_USER、CURRENT_USER 和 CURRENT_ROLE:public、none 使用保留角色名主消息,后三个当前/会话标记使用 %s cannot be used as a role name here。这些规则不表示这些单词在所有标识符位置都保留。

诊断 {#diagnosis}

先读取主消息和 DETAIL。unacceptable schema name 指向模式前缀检查,unacceptable tablespace name 指向表空间检查,role name ... is reserved 可能是 pg_ 角色或语法中的 public/none,%s cannot be used as a role name here 则明确是角色说明标记。语法错误应检查角色名所在的命令位置,而不是先查 pg_namespace 或 pg_authid;不能只凭 SQLSTATE 判断。

处理 {#response}

选择允许的对象名称并检查迁移与所有权。若是角色说明语法错误,应在该位置改用允许的实际角色标识符;改 search_path 不能替代修正命令。不要删除系统对象或重复同名重试。对象级 ERROR 若发生在显式事务中,应先回滚到保存点或回滚事务再重试。

消息变体 {#messages}

选定路径均为 ERROR,具体主消息/DETAIL 如下:

  • 模式:unacceptable schema name "%s",DETAIL 为 The prefix "pg_" is reserved for system schemas.
  • 表空间:unacceptable tablespace name "%s",DETAIL 为 The prefix "pg_" is reserved for system tablespaces.
  • pg_ 角色:role name "%s" is reserved,DETAIL 为 Role names starting with "pg_" are reserved.
  • 角色语法:public/none 使用 role name "%s" is reserved,SESSION_USER、CURRENT_USER、CURRENT_ROLE 使用 %s cannot be used as a role name here。

版本 {#versions}

目录锁定范围从 7.4 下界到 18.6、19beta3;这是条件目录下界,不是每个对象规则的共同引入版本。本页机制只做源码确认,未运行数据库。

相关 {#related}

来源 {#sources}

  • src.errcodes.42939.18.6 — src/backend/utils/errcodes.txt line 349,固定于 724edf9bde9d356724ad384a2e196edc3c9f80f7;SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba(源码)。

  • src.call.42939.baa3c4599e167695f281cfe8 — src/backend/commands/schemacmds.c lines 107-110,固定于 724edf9bde9d356724ad384a2e196edc3c9f80f7;SHA-256 5fd5f43dce5f36f06ed390014c06f244564072227d25a22735f594d2170626b1(源码)。

  • src.call.42939.aed179efd45a7ca409d59fd6 — src/backend/commands/tablespace.c lines 281-285,固定于 724edf9bde9d356724ad384a2e196edc3c9f80f7;SHA-256 f0369bece6339d18cd7d4a29b5fa3010447c3b8ece235c64b0d4fbf5f96a5317(源码)。

  • src.call.42939.419595a34cae2a69b2e21624 — src/backend/commands/user.c lines 352-356,固定于 724edf9bde9d356724ad384a2e196edc3c9f80f7;SHA-256 aa8769a2577fff287301d6c82169262cca328515ae940d5a2be4b3e8c21617ed(源码)。

  • src.call.42939.role-grammar — src/backend/parser/gram.y lines 17460-17542,固定于 724edf9bde9d356724ad384a2e196edc3c9f80f7;SHA-256 7e548b673a1e03eb3a56c5eb9ad92d8e11095fac76e14cb258ca851f58274724(源码)。

  • src.calls.REL_18_6.42939 — 固定本地核心调用扫描;SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf。

  • 作者证据 — 记录源码断言、消息角色和运行边界。

比较版本

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.42939.18.6"
  ],
  "statement": "42939 is the reserved_name 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 complete resolved REL_18_6 report groups and message roles.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.call.42939.baa3c4599e167695f281cfe8",
    "src.call.42939.aed179efd45a7ca409d59fd6",
    "src.call.42939.419595a34cae2a69b2e21624",
    "src.call.42939.role-grammar"
  ],
  "statement": "Schema and tablespace paths reject reserved `pg_` names with object-specific DETAIL. CREATE ROLE reports the reserved `pg_` role path. RoleId grammar rejects `public`, `none`, SESSION_USER, CURRENT_USER, and CURRENT_ROLE in role-name positions, with a reserved-role-name primary for public/none and a `%s cannot be used as a role name here` primary for the current/session tokens."
}
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 snapshots.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.errcodes.42939.18.6"
  ],
  "statement": "From the locked 7.4 lower bound through 18.6 and 19beta3; multiple branches do not imply one introduction point."
}
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": [
      "The prefix \"pg_\" is reserved for system schemas."
    ],
    "hint_templates": [],
    "id": "message.variant-1",
    "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
    "primary_template": "unacceptable schema name \"%s\"",
    "roles": [
      {
        "role": "errmsg",
        "template": "unacceptable schema name \"%s\""
      },
      {
        "role": "errdetail",
        "template": "The prefix \"pg_\" is reserved for system schemas."
      }
    ],
    "severity_source": "explicit ERROR",
    "sources": [
      "src.call.42939.baa3c4599e167695f281cfe8"
    ],
    "sqlstate": "42939"
  },
  "severity": "explicit ERROR",
  "sources": [
    "src.call.42939.baa3c4599e167695f281cfe8"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "unacceptable schema name \" \"",
      "position": 0,
      "role": "",
      "template": "unacceptable schema name \"%s\""
    },
    {
      "kind": "detail",
      "literal": "The prefix \"pg_\" is reserved for system schemas.",
      "position": 1,
      "role": "",
      "template": "The prefix \"pg_\" is reserved for system schemas."
    },
    {
      "kind": "primary",
      "literal": "The prefix \"pg_\" is reserved for system schemas.",
      "position": 2,
      "role": "errdetail",
      "template": "The prefix \"pg_\" is reserved for system schemas."
    }
  ]
}
messages · message.variant-2
{
  "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
  "message_id": "message.variant-2",
  "path": "",
  "position": 1,
  "raw": {
    "detail_templates": [
      "The prefix \"pg_\" is reserved for system tablespaces."
    ],
    "hint_templates": [],
    "id": "message.variant-2",
    "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
    "primary_template": "unacceptable tablespace name \"%s\"",
    "roles": [
      {
        "role": "errmsg",
        "template": "unacceptable tablespace name \"%s\""
      },
      {
        "role": "errdetail",
        "template": "The prefix \"pg_\" is reserved for system tablespaces."
      }
    ],
    "severity_source": "explicit ERROR",
    "sources": [
      "src.call.42939.aed179efd45a7ca409d59fd6"
    ],
    "sqlstate": "42939"
  },
  "severity": "explicit ERROR",
  "sources": [
    "src.call.42939.aed179efd45a7ca409d59fd6"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "unacceptable tablespace name \" \"",
      "position": 0,
      "role": "",
      "template": "unacceptable tablespace name \"%s\""
    },
    {
      "kind": "detail",
      "literal": "The prefix \"pg_\" is reserved for system tablespaces.",
      "position": 1,
      "role": "",
      "template": "The prefix \"pg_\" is reserved for system tablespaces."
    },
    {
      "kind": "primary",
      "literal": "The prefix \"pg_\" is reserved for system tablespaces.",
      "position": 2,
      "role": "errdetail",
      "template": "The prefix \"pg_\" is reserved for system tablespaces."
    }
  ]
}
messages · message.variant-3
{
  "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
  "message_id": "message.variant-3",
  "path": "",
  "position": 2,
  "raw": {
    "detail_templates": [
      "Role names starting with \"pg_\" are reserved."
    ],
    "hint_templates": [],
    "id": "message.variant-3",
    "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
    "primary_template": "role name \"%s\" is reserved",
    "roles": [
      {
        "role": "errmsg",
        "template": "role name \"%s\" is reserved"
      },
      {
        "role": "errdetail",
        "template": "Role names starting with \"pg_\" are reserved."
      }
    ],
    "severity_source": "explicit ERROR",
    "sources": [
      "src.call.42939.419595a34cae2a69b2e21624"
    ],
    "sqlstate": "42939"
  },
  "severity": "explicit ERROR",
  "sources": [
    "src.call.42939.419595a34cae2a69b2e21624"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "role name \" \" is reserved",
      "position": 0,
      "role": "",
      "template": "role name \"%s\" is reserved"
    },
    {
      "kind": "detail",
      "literal": "Role names starting with \"pg_\" are reserved.",
      "position": 1,
      "role": "",
      "template": "Role names starting with \"pg_\" are reserved."
    },
    {
      "kind": "primary",
      "literal": "Role names starting with \"pg_\" are reserved.",
      "position": 2,
      "role": "errdetail",
      "template": "Role names starting with \"pg_\" are reserved."
    }
  ]
}
messages · message.variant-4
{
  "limits": "The grammar supplies public or none as the dynamic role-name value; no concrete command is claimed.",
  "message_id": "message.variant-4",
  "path": "",
  "position": 3,
  "raw": {
    "detail_templates": [],
    "hint_templates": [],
    "id": "message.variant-4",
    "limits": "The grammar supplies public or none as the dynamic role-name value; no concrete command is claimed.",
    "primary_template": "role name \"%s\" is reserved",
    "roles": [
      {
        "role": "errmsg",
        "template": "role name \"%s\" is reserved"
      }
    ],
    "severity_source": "explicit ERROR",
    "sources": [
      "src.call.42939.role-grammar"
    ],
    "sqlstate": "42939"
  },
  "severity": "explicit ERROR",
  "sources": [
    "src.call.42939.role-grammar"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "role name \" \" is reserved",
      "position": 0,
      "role": "",
      "template": "role name \"%s\" is reserved"
    }
  ]
}
messages · message.variant-5
{
  "limits": "The grammar supplies SESSION_USER, CURRENT_USER, or CURRENT_ROLE as the dynamic token; no concrete command is claimed.",
  "message_id": "message.variant-5",
  "path": "",
  "position": 4,
  "raw": {
    "detail_templates": [],
    "hint_templates": [],
    "id": "message.variant-5",
    "limits": "The grammar supplies SESSION_USER, CURRENT_USER, or CURRENT_ROLE as the dynamic token; no concrete command is claimed.",
    "primary_template": "%s cannot be used as a role name here",
    "roles": [
      {
        "role": "errmsg",
        "template": "%s cannot be used as a role name here"
      }
    ],
    "severity_source": "explicit ERROR",
    "sources": [
      "src.call.42939.role-grammar"
    ],
    "sqlstate": "42939"
  },
  "severity": "explicit ERROR",
  "sources": [
    "src.call.42939.role-grammar"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "cannot be used as a role name here",
      "position": 0,
      "role": "",
      "template": "%s cannot be used as a role name here"
    }
  ]
}
sources · src.errcodes.42939.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "line 349",
  "path": "src/backend/utils/errcodes.txt",
  "position": 0,
  "sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
  "source_id": "src.errcodes.42939.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L349"
}
sources · src.call.42939.baa3c4599e167695f281cfe8
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "lines 107-110",
  "path": "src/backend/commands/schemacmds.c",
  "position": 1,
  "sha256": "5fd5f43dce5f36f06ed390014c06f244564072227d25a22735f594d2170626b1",
  "source_id": "src.call.42939.baa3c4599e167695f281cfe8",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/schemacmds.c#L107-L110"
}
sources · src.call.42939.aed179efd45a7ca409d59fd6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "lines 281-285",
  "path": "src/backend/commands/tablespace.c",
  "position": 2,
  "sha256": "f0369bece6339d18cd7d4a29b5fa3010447c3b8ece235c64b0d4fbf5f96a5317",
  "source_id": "src.call.42939.aed179efd45a7ca409d59fd6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablespace.c#L281-L285"
}
sources · src.call.42939.419595a34cae2a69b2e21624
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "lines 352-356",
  "path": "src/backend/commands/user.c",
  "position": 3,
  "sha256": "aa8769a2577fff287301d6c82169262cca328515ae940d5a2be4b3e8c21617ed",
  "source_id": "src.call.42939.419595a34cae2a69b2e21624",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/user.c#L352-L356"
}
sources · src.call.42939.role-grammar
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "lines 17460-17542",
  "path": "src/backend/parser/gram.y",
  "position": 4,
  "sha256": "7e548b673a1e03eb3a56c5eb9ad92d8e11095fac76e14cb258ca851f58274724",
  "source_id": "src.call.42939.role-grammar",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/parser/gram.y#L17460-L17542"
}
sources · src.calls.REL_18_6.42939
{
  "commit": "",
  "docs_url": "",
  "kind": "local_artifact",
  "location": "",
  "path": "raw/calls/REL_18_6.jsonl",
  "position": 5,
  "sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
  "source_id": "src.calls.REL_18_6.42939",
  "tag": "",
  "url": ""
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:0d70e673ee2234ce4c154ca262942f9c3fdbd1619a911f417ab54856c605bbc5

正文语言: zh-Hans · english-manuals:0d70e673ee2234ce4c154ca262942f9c3fdbd1619a911f417ab54856c605bbc5