百科 / 错误代码 / Class 42 语法错误或访问规则冲突
42939 reserved_name
保留名称
ERROR 源码确认 详解 未实测
- 条件名
reserved_name- 宏名称
ERRCODE_RESERVED_NAME- 启用版本
- 7.4
- 状态
- 活跃
版本覆盖
速览
42939(reserved_name)按对象类型拒绝保留名称。选定的 18.6 路径覆盖模式、表空间、创建角色和角色说明语法;必须根据报文中的对象类型判断具体规则。
含义
创建模式时,保留的 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。这些规则不表示这些单词在所有标识符位置都保留。
诊断
先读取主消息和 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 判断。
处理
选择允许的对象名称并检查迁移与所有权。若是角色说明语法错误,应在该位置改用允许的实际角色标识符;改 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 reserved,SESSION_USER、CURRENT_USER、CURRENT_ROLE使用%s cannot be used as a role name here。
报文模板
源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。
unacceptable schema name "%s"
The prefix "pg_" is reserved for system schemas.
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"
The prefix "pg_" is reserved for system tablespaces.
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
Role names starting with "pg_" are reserved.
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;这是条件目录下界,不是每个对象规则的共同引入版本。本页机制只做源码确认,未运行数据库。
来源
- 上游源码 src/backend/commands/user.c 第 352–356 行
- 上游源码 src/backend/commands/tablespace.c 第 281–285 行
- 上游源码 src/backend/commands/schemacmds.c 第 107–110 行
- 上游源码 src/backend/parser/gram.y 第 17460–17542 行
- 上游源码 src/backend/utils/errcodes.txt 第 349 行
- 核验材料 raw/calls/REL_18_6.jsonl
证据
断言
每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。
-
42939 is the reserved_name condition in Class 42.
-
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.
-
From the locked 7.4 lower bound through 18.6 and 19beta3; multiple branches do not imply one introduction point.
同类错误代码
Class 42 语法错误或访问规则冲突 下的其他成员。
42000syntax_error_or_access_rule_violation42501insufficient_privilege42601syntax_error42602invalid_name42611invalid_column_definition42622name_too_long42701duplicate_column42702ambiguous_column42703undefined_column42704undefined_object42710duplicate_object42712duplicate_alias42723duplicate_function42725ambiguous_function42803grouping_error42804datatype_mismatch42809wrong_object_type42830invalid_foreign_key42846cannot_coerce42883undefined_function428C9generated_always42P01undefined_table42P02undefined_parameter42P03duplicate_cursor42P04duplicate_database42P05duplicate_prepared_statement42P06duplicate_schema42P07duplicate_table42P08ambiguous_parameter42P09ambiguous_alias42P10invalid_column_reference42P11invalid_cursor_definition42P12invalid_database_definition42P13invalid_function_definition42P14invalid_prepared_statement_definition42P15invalid_schema_definition42P16invalid_table_definition42P17invalid_object_definition42P18indeterminate_datatype42P19invalid_recursion42P20windowing_error42P21collation_mismatch42P22indeterminate_collation