百科 / 错误代码 / Class 0A 不支持的特性
0A000 feature_not_supported
不支持的功能
ERROR 已实测 详解 实测通过
- 条件名
feature_not_supported- 宏名称
ERRCODE_FEATURE_NOT_SUPPORTED- 启用版本
- 7.4
- 状态
- 活跃
版本覆盖
速览
SQLSTATE 0A000 是 Class 0A 中的 feature_not_supported。0A000 表示服务器识别了功能或选项,但当前上下文不支持。选定 hash 索引路径请求 id ASC,得到 access method "hash" does not support ASC/DESC options,去掉排序后同一索引成功。这是访问方法能力判断,不是 42501 权限不足或 42601 解析失败。
含义
选定的 ComputeIndexAttrs 路径拒绝 hash 访问方法的排序选项,尽管索引请求本身语法有效。关键区别是能力限制与语法错误:id ASC 能到达访问方法检查并产生确切 ERROR,而去掉排序后的同一键可以接受。
这是所选访问方法的属性,不是列类型或表内容的属性。命令解析器已经接受索引定义,随后 ComputeIndexAttrs 检查该访问方法能否满足排序要求;本路径中的 hash 索引不支持这个选项,而 btree 等访问方法可以有不同能力。其他 0A000 producer 可能拒绝不同功能,因此必须结合完整主报文和命令上下文判断。
诊断
记录完整主报文,确认访问方法、选项、命令上下文和版本。错误语句后自动提交会话保持 IDLE;通过 pg_index.indisvalid 确认修复索引有效。其他 0A000 路径可能有不同对象和恢复行为。
先核对对象名称再解释结果。案例中前面的表和索引都未限定 schema,依赖 search_path;最后 regclass 查询中的 feature_schema.hash_index 只是实际索引的 schema-qualified 占位值。确认这些名称指向刚创建的对象,再把访问方法和选项与其能力进行比较。权限错误(42501)或解析错误(42601)应走不同诊断分支。
处理
只移除或替换不支持的选项,或选择支持该选项的访问方法,并核对最终对象语义。不要把所有 0A000 都当成升级要求,也不要静默丢弃用户请求的功能。
选定自动提交案例中的 ERROR 后,可以在同一会话继续执行修正后的 CREATE INDEX。显式事务中应先用 ROLLBACK 或有意建立的保存点恢复本地事务,再执行无关 DDL;恢复后要用满足原始语义要求的访问方法和选项重建索引。不要假定替代索引仍然提供被拒绝定义所要求的排序保证。
可复现案例
在一次性实例上执行过的场景。其中 1 个附有可执行 SQL,正文相应小节里给出。
hash_index_feature PG 10 / 18 有 SQL
前置条件
- A runner-owned disposable target is provisioned.
触发
Use ASC with the hash access method, then create the same index without ordering.
断言
- 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.
实测诊断
固定的索引命令路径以 ERROR 发出主报文 access method "%s" does not support ASC/DESC options,其中访问方法名称是动态值。这是选定的 hash 索引变体;其他不支持的功能可能使用不同 0A000 报文和恢复边界。
选定分支中的动态值为 hash,服务器没有固定 DETAIL 或 HINT。运行在自动提交会话中观察到错误后状态为 IDLE;这不是所有 0A000 producer 的通用属性,也不能推广到同一命令位于显式事务中的情形。
报文模板
源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。
access method "%s" does not support ASC/DESC options
来源:src/backend/commands/indexcmds.c @ REL_18_6 · src/backend/commands/indexcmds.c @ REL_10_23
代表案例
此 SQL 块创建表,尝试不支持排序选项的 hash 索引,创建修复后的索引,并检查 pg_index.indisvalid。
最后 regclass 查询中的 feature_schema.hash_index 是占位写法,应替换为前面实际创建的、带 schema 的关系。前面三条语句使用未限定的 feature_table 和 hash_index,依赖当前 search_path;手工执行时应有意设置该路径,或把表和索引创建在验证查询所写的 schema 中并使用一致的限定名。
CREATE TABLE feature_table (id integer NOT NULL, payload text);
CREATE INDEX hash_index ON feature_table USING hash (id ASC);
CREATE INDEX hash_index ON feature_table USING hash (id);
SELECT indisvalid FROM pg_index WHERE indexrelid = 'feature_schema.hash_index'::regclass;
18.6 运行记录 SQLSTATE 为 0A000,主报文 access method "hash" does not support ASC/DESC options;断言的错误后状态为 IDLE,随后探针/修复成功。18.6 与 10.21 的断言和清理均通过。
可下载的案例与证据投影分别是 0A000 案例 JSON 和 作者证据。运行器清单为 verify/cases/0A000/cases.json;发布前会将页面 SQL 与共享注册表比对。
版本
上面的生成事实表记录锁定的目录快照和最早观察到的定义。本页自然运行范围是 PostgreSQL 18.6 与 10.21,不能据此推断所有中间版本的行为。
来源
- 上游源码 doc/src/sgml/xact.sgml
- 上游源码 src/backend/utils/errcodes.txt
- 上游源码 src/backend/commands/indexcmds.c 第 1403–1406 行
- 上游源码 src/backend/commands/indexcmds.c 第 2244–2247 行
- 核验材料 verify/cases/0A000/cases.json
- 核验材料 verify/cases/0A000/snippets.json
- 核验材料 raw/calls/REL_10_23.jsonl
- 核验材料 raw/calls/REL_18_6.jsonl
证据
断言
每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。
-
0A000 is the feature_not_supported condition in Class 0A.
-
The fixed source paths associated with 0A000 report the condition in the mechanism selected for this page.
-
The selected hash_index_feature case passed with the expected structured diagnostics, recovery assertions, and cleanup on PostgreSQL 18.6 and 10.21.
-
The selected unsupported hash-index option is an ERROR observed under autocommit, where the session remains IDLE; the same DDL failure inside an explicit transaction follows PostgreSQL's rollback or intentional-savepoint recovery boundary.
-
The locked catalogue records 0A000 in the listed snapshots; the runtime comparison here is limited to PostgreSQL 18.6 and 10.21.
运行记录
| 目标 | 服务器版本 | 结果 | 覆盖案例 |
|---|---|---|---|
| latest | 18.6 (Homebrew) | passed | hash_index_feature |
| pg10 | 10.21 (Debian 10.21-1.pgdg90+1) | passed | hash_index_feature |