↑↓ 选择 ↵ 打开 ⌫ 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

百科 / SQL 状态码 / Class 0P 无效的角色指定

0P000 invalid_role_specification

角色规范无效

ERROR 源码确认 参考 未实测

类别
Class 0P 无效的角色指定
严重等级
ERROR
条件名
invalid_role_specification
宏名称
ERRCODE_INVALID_ROLE_SPECIFICATION
最早已知存在
7.4
状态
有效

手册收录:8.1、8.2、8.3、8.4、9.0、9.1、9.2、9.3、9.4、9.5、9.6、10、11、12、13、14、15、16、17、18、19、20。此处仅表示同版本手册收录,运行证据仍以原核验构建为准。

版本覆盖

版本条依据已采样构建显示;灰色版本可能尚未采样,悬停可查看。手册链接随版本选择,源码和运行证据保持原核验构建。

0P000 — 角色规范无效

速览 {#at-a-glance}

SQLSTATE 0P000 是 Class 0P 中的 invalid_role_specification。在 ENABLE_SSPI 下,固定的 Windows SSPI 路径在把 SAM 账户名转换为 UPN 时以服务器 LOG 分支使用它;它不是普通的“角色不存在”登录结果,也不是客户端 ErrorResponse。

含义 {#meaning}

0P000 是 invalid_role_specification。固定的 pg_SSPI_make_upn 路径构造 DOMAIN\user,调用 Windows TranslateName 得到 user@realm;转换失败、结果没有 @,或 realm/账户无法放入目标缓冲区时记录 0P000。这些是 ENABLE_SSPI 下的服务器 LOG 分支,不是客户端 ErrorResponse,也不是普通角色缺失结果。

诊断 {#diagnosis}

确认失败路径确实是 Windows SSPI,并结合服务器日志检查 SAM 账户/域名及配置的 realm 或 UPN 映射。TranslateName 失败(包括结果不含 @)记录 could not translate name;realm 过长记录 realm name too long;转换后的账户过长记录 translated account name too long。使用 trust 认证的临时实例无法忠实演示这一外部身份边界;启动 ErrorResponse 也可能是 28000 或 28P01。

处理 {#response}

修复 SSPI 账户/realm 映射或 Windows 名称转换配置后建立新连接。应把这些服务器日志诊断与启动认证响应、SQL 角色不存在和密码失败分开。

报文 {#messages}

固定 SSPI 源码以 LOG 和 SQLSTATE 0P000 记录以下主报文模板:could not translate name、realm name too long、translated account name too long。这些是服务器日志记录;只有客户端异常或没有匹配服务器日志的启动 ErrorResponse,都不能证明 0P000。

代表案例 {#case}

本页没有选定的自然 SQL 运行。结构化证据记录的是源码或定义边界;客户端 RAISE 不能代表服务器机制。

版本 {#versions}

上面的生成事实表记录锁定的目录快照和最早观察到的定义。本页没有选定的自然 SQL 运行;固定 REL_18_6/REL_10_23 的 SSPI 源码比较不能当作实测结果,也不能据此推断所有中间版本的行为。

相关 {#related}

来源 {#sources}

  • src.auth-name-translation.18.6 — src/backend/libpq/auth.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 94252cb1e2c49b0ddb15f6596d0abf8056c84493de07cc81439da4c5b07018f1 (source).
  • src.auth-name-translation.10.23 — src/backend/libpq/auth.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 15418faa6d6ee1b2a4ad1e50ebc9b34c2daf4799f7062df425e33dbf777ade61 (source).
  • src.auth-sspi-upn.10.23 — src/backend/libpq/auth.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 15418faa6d6ee1b2a4ad1e50ebc9b34c2daf4799f7062df425e33dbf777ade61 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed local call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.

来源

证据

断言

每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。

  • 0P000 is the invalid_role_specification condition in Class 0P.

    核实方式Read the fixed errcodes.txt definition and the locked catalogue metadata.

    不覆盖Directory identity does not identify every backend or client path.

    来源 来源:src/backend/utils/errcodes.txt @ REL_18_6

  • Under ENABLE_SSPI, the fixed pg_SSPI_make_upn path builds a DOMAIN\user SAM name, calls Windows TranslateName to obtain a user@realm UPN, and logs 0P000 when translation fails, the result has no @, or the realm or translated account exceeds its target buffer. These are server LOG branches, not client ErrorResponse fields.

    核实方式Read the complete fixed SSPI authentication and pg_SSPI_make_upn paths in REL_18_6 and REL_10_23, including each explicit LOG branch.

    不覆盖This is a bounded source claim under ENABLE_SSPI; the disposable trust target cannot faithfully exercise it, and it is not an observed natural SQLSTATE case.

    来源 来源:src/backend/libpq/auth.c @ REL_18_6 · 来源:src/backend/libpq/auth.c @ REL_10_23 · 来源:src/backend/libpq/auth.c @ REL_10_23

  • The locked catalogue records 0P000 in the listed snapshots; this page compares only the fixed REL_18_6 and REL_10_23 SSPI source paths and has no selected natural runtime.

    核实方式Read the generated facts block and fixed SSPI source records; no runtime result is used for this source-only page.

    不覆盖Presence in a definition file is not an exact behavioral introduction, and the fixed source paths do not prove every intermediate release or authentication configuration.

    来源 来源:src/backend/utils/errcodes.txt @ REL_18_6 · 来源:src/backend/libpq/auth.c @ REL_18_6 · 来源:src/backend/libpq/auth.c @ REL_10_23

报文模板

源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。

主消息 realm name too long

来源: 来源:src/backend/libpq/auth.c @ REL_10_23

主消息 translated account name too long

来源: 来源:src/backend/libpq/auth.c @ REL_10_23

可复现案例

在一次性实例上执行过的场景。

source_boundary PG 10 / 18

前置条件

  • A runner-owned disposable target is provisioned only if a source-boundary smoke run is requested.

触发

No artificial SQL trigger is executed; this record preserves the fixed source/definition boundary.

处置

Use the concrete source path or component-specific documentation when it applies.

清理

Drop the case schema with an owner connection.

同类 SQL 状态码

状态码 条件名 宏名称 严重等级 版本
Class 0P 无效的角色指定 Invalid Role Specification 1 个 ↗
0P000 invalid_role_specification ERRCODE_INVALID_ROLE_SPECIFICATION ERROR 7.4 起已知
角色规范无效,指定的角色不可用。 有效