选择 打开 改范围 完整检索页

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

百科 / 错误代码 / Class 0L 无效授权者

0LP01 invalid_grant_operation

无效的授权操作

ERROR 已实测 参考 实测通过

类别
Class 0L 无效授权者
严重等级
ERROR
条件名
invalid_grant_operation
宏名称
ERRCODE_INVALID_GRANT_OPERATION
启用版本
7.4
状态
活跃

版本覆盖

速览

SQLSTATE 0LP01 是 Class 0L 中的 invalid_grant_operation0LP01 表示 GRANT 或 REVOKE 对对象或权限类型无效。选定的序列案例请求 INSERT,服务器通过动态报文组合出 invalid privilege type INSERT for sequence;随后授予 USAGE 成功。

含义

0LP01 表示 GRANT 或 REVOKE 对对象或权限类型无效。选定的序列案例请求 INSERT,服务器通过动态报文组合出 invalid privilege type INSERT for sequence;随后授予 USAGE 成功。

诊断

检查对象类型、权限矩阵、目标角色、所有权,以及语句是否属于列权限或默认权限形式。选定错误是 ERROR,但自动提交会话保持 IDLE;修复后的权限查询返回 true。

处理

按对象支持的权限重写语句并核对 ACL。序列应按意图选择 USAGESELECTUPDATE;不要扩大授权,也不要原样重试。

可复现案例

在一次性实例上执行过的场景。其中 1 个附有可执行 SQL,正文相应小节里给出。

invalid_grant_operation PG 10 / 18 有 SQL

前置条件

  • A runner-owned disposable target is provisioned.

触发

Grant an invalid sequence privilege, then grant USAGE to a disposable role.

断言

  • The selected server diagnostic has the expected SQLSTATE
  • The selected recovery/probe assertions pass
  • Runner-owned resources are cleaned up

处置

Follow the case-specific repair statements and verify the resulting state.

清理

Drop the case schema with an owner connection.

实测诊断

结构化证据保留原始报文模板或动态组装边界。对于本页,只有客户端异常而没有服务器诊断时,不能据此认定 0LP01

报文模板

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

主消息 · observed invalid privilege type INSERT for sequence

来源:src/backend/catalog/aclchk.c @ REL_18_6 · src/backend/catalog/aclchk.c @ REL_10_23

适用范围:The primary is dynamically assembled from the object and privilege; the example is an observed instantiation, not a static format string.

代表案例

此 SQL 块创建序列,尝试无效的 INSERT 权限,授予 USAGE,并检查临时角色的有效权限。

CREATE SEQUENCE grant_sequence;
GRANT INSERT ON SEQUENCE grant_sequence TO role;
GRANT USAGE ON SEQUENCE grant_sequence TO role;
SELECT has_sequence_privilege(role_literal, 'grant_sequence', 'USAGE');

18.6 运行记录 SQLSTATE 为 0LP01,主报文 invalid privilege type INSERT for sequence;断言的错误后状态为 IDLE,随后探针/修复成功。18.6 与 10.21 的断言和清理均通过。

可下载的案例与证据投影分别是 0LP01 案例 JSON作者证据。运行器清单为 verify/cases/0LP01/cases.json;发布前会将页面 SQL 与共享注册表比对。

版本

上面的生成事实表记录锁定的目录快照和最早观察到的定义。本页自然运行范围是 PostgreSQL 18.6 与 10.21,不能据此推断所有中间版本的行为。

来源

证据

断言

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

  • 0LP01 is the invalid_grant_operation condition in Class 0L.

    核实方式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

  • The fixed source paths associated with 0LP01 report the condition in the mechanism selected for this page.

    核实方式Trace the resolved source call records at the fixed release commits and compare their dynamic message fields.

    不覆盖Other calls can retain the same SQLSTATE with different context or text.

    来源src/backend/catalog/aclchk.c · src/backend/catalog/aclchk.c

  • The selected invalid_grant_operation case passed with the expected structured diagnostics, recovery assertions, and cleanup on PostgreSQL 18.6 and 10.21.

    核实方式Run the shared registry case on isolated runner-owned latest and PG10 targets; inspect the final summaries and raw results.

    不覆盖This covers the selected case and versions only; it does not generalize to every driver, proxy, or intermediate release.

    来源verify/cases/0LP01/snippets.json · verify/cases/0LP01/cases.json

  • The locked catalogue records 0LP01 in the listed snapshots; the runtime comparison here is limited to PostgreSQL 18.6 and 10.21.

    核实方式Read the generated facts block and locked manifest, then compare the selected target summaries.

    不覆盖Presence in a definition file is not an exact behavioral introduction; the two runtime targets do not prove all middle versions.

    来源src/backend/utils/errcodes.txt · raw/calls/REL_18_6.jsonl · raw/calls/REL_10_23.jsonl

运行记录

目标服务器版本结果覆盖案例
latest 18.6 (Homebrew) passed invalid_grant_operation
pg10 10.21 (Debian 10.21-1.pgdg90+1) passed invalid_grant_operation

同类错误代码

Class 0L 无效授权者 下的其他成员。