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

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

百科 / 错误代码 / Class 42 语法错误或访问规则冲突

42939 reserved_name

保留名称

ERROR 源码确认 详解 未实测

条件名
reserved_name
宏名称
ERRCODE_RESERVED_NAME
启用版本
7.4
状态
活跃

版本覆盖

速览

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

含义

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

诊断

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

处理

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

消息变体

选定路径均为 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 reservedSESSION_USERCURRENT_USERCURRENT_ROLE 使用 %s cannot be used as a role name here

报文模板

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

主消息 unacceptable schema name "%s"
DETAIL The prefix "pg_" is reserved for system schemas.
主消息 · errdetail The prefix "pg_" is reserved for system schemas.

来源:src/backend/commands/schemacmds.c(lines 107-110) @ REL_18_6

适用范围:Placeholders remain dynamic source fields; no concrete runtime value is claimed.

主消息 unacceptable tablespace name "%s"
DETAIL The prefix "pg_" is reserved for system tablespaces.
主消息 · errdetail The prefix "pg_" is reserved for system tablespaces.

来源:src/backend/commands/tablespace.c(lines 281-285) @ REL_18_6

适用范围:Placeholders remain dynamic source fields; no concrete runtime value is claimed.

主消息 role name "%s" is reserved
DETAIL Role names starting with "pg_" are reserved.
主消息 · errdetail Role names starting with "pg_" are reserved.

来源:src/backend/commands/user.c(lines 352-356) @ REL_18_6

适用范围:Placeholders remain dynamic source fields; no concrete runtime value is claimed.

主消息 role name "%s" is reserved

来源:src/backend/parser/gram.y(lines 17460-17542) @ REL_18_6

适用范围:The grammar supplies public or none as the dynamic role-name value; no concrete command is claimed.

主消息 %s cannot be used as a role name here

来源:src/backend/parser/gram.y(lines 17460-17542) @ REL_18_6

适用范围:The grammar supplies SESSION_USER, CURRENT_USER, or CURRENT_ROLE as the dynamic token; no concrete command is claimed.

版本

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

来源

证据

断言

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

同类错误代码

Class 42 语法错误或访问规则冲突 下的其他成员。