暂无图片
暂无图片
暂无图片
暂无图片
暂无图片
PostgreSQL.和openGauss错误代码整理.txt
148
22页
0次
2022-10-25
100墨值下载
# 一、 PostgreSQL 错误信息的设计
- All messages emitted by the PostgreSQL server are assigned five-character
error codes that follow the SQL standard's conventions for “SQLSTATE” codes.
Applications that need to know which error condition has occurred should usually
test the error code, rather than looking at the textual error message. The error
codes are less likely to change across PostgreSQL releases, and also are not
subject to change due to localization of error messages. Note that some, but not
all, of the error codes produced by PostgreSQL are defined by the SQL standard;
some additional error codes for conditions not defined by the standard have been
invented or borrowed from other databases.
> PostgreSQL 服务器发出的所有消息都分配有五个字符的错误代码,遵循 SQL 标准的“SQLSTATE”代码
约定。需要知道发生了哪种错误情况的应用程序通常应该测试错误代码,而不是查看文本错误消息。错误代码
不太可能在 PostgreSQL 版本之间更改,并且也不会由于错误消息的本地化而发生更改。请注意,
PostgreSQL 产生的一些但不是全部的错误代码是由 SQL 标准定义的;标准未定义的一些附加错误代码已
被发明或从其他数据库借用。
- According to the standard, the first two characters of an error code denote a
class of errors, while the last three characters indicate a specific condition
within that class. Thus, an application that does not recognize the specific
error code might still be able to infer what to do from the error class.
> 根据标准,错误代码的前两个字符表示一类错误,而后三个字符表示该类中的特定条件。因此,无法识别
特定错误代码的应用程序可能仍然能够从错误类中推断出要做什么
Table A. lists all the error codes defined in PostgreSQL 15.0. (Some are not
actually used at present, but are defined by the SQL standard.) The error
classes are also shown. For each error class there is a “standard” error code
having the last three characters 000. This code is used only for error
conditions that fall within the class but do not have any more-specific code
assigned.
> A.1 列出了 PostgreSQL 15.0 中定义的所有错误代码。 (有些目前没有实际使用,但由 SQL 标准
定义。)还显示了错误类。对于每个错误类别,都有一个最后三个字符为 000 的“标准”错误代码。此代码仅
用于属于该类别但没有分配任何更具体代码的错误条件。
- The symbol shown in the column “Condition Name” is the condition name to use
in PL/pgSQL. Condition names can be written in either upper or lower case. (Note
that PL/pgSQL does not recognize warning, as opposed to error, condition names;
those are classes 00, 01, and 02.)
> “条件名称”列中显示的符号是在 PL/pgSQL 中使用的条件名称。条件名称可以大写或小写。 (请注意,
PL/pgSQL 不识别警告,而不是错误,条件名称;它们是类 0001 02。)
- For some types of errors, the server reports the name of a database object (a
table, table column, data type, or constraint) associated with the error; for
example, the name of the unique constraint that caused a unique_violation error.
Such names are supplied in separate fields of the error report message so that
applications need not try to extract them from the possibly-localized human-
readable text of the message. As of PostgreSQL 9.3, complete coverage for this
feature exists only for errors in SQLSTATE class 23 (integrity constraint
violation), but this is likely to be expanded in future.
> 对于某些类型的错误,服务器会报告与错误相关的数据库对象(表、表列、数据类型或约束)的名称;例
如,导致 unique_violation 错误的唯一约束的名称。此类名称在错误报告消息的单独字段中提供,因此
应用程序无需尝试从消息的可能本地化的人类可读文本中提取它们。从 PostgreSQL 9.3 开始,此功能的
完全覆盖仅存在于 SQLSTATE 23 中的错误(违反完整性约束),但将来可能会扩展。
# 二、 openGauss 错误信息设计
- 根据 X/Open SQL Access Group SQL CAE 规范(1992)所进行的定义,SQLERROR 返回
SQLSTATE 值。SQLSTATE 值是包含五个字符的字符串,由 2 个字符的 SQL 错误类和 3 个字符的子类构成。
五个字符包含数值或者大写字母, 代表各种错误或者警告条件的代码。成功的状态是由 00000 标识的。
SQLSTATE 代码大多数情况下都是定义在 SQL 标准里的。
- openGauss 也遵循 SQL 标准返回错误码的 SQLSTATE 值,详细说明请参见
# 三、 PostgreSQL and openGauss error code
| 错误码 SQLSTATE | condition name
| 错误码含义 | 共有 | PG 独有 | OG 独有 |
|-------------------------------------------------------------------------------
------------------------|------------------------------------------------------|
------------------------------------|:-------:|:---------------:|:--------------
:|
| Class 00 — Successful Completion/00 - 成功完成 |
| | ✅ | |
|
| 00000
| successful_completion | 成功完成 |
✅ | | |
| Class 01 — Warning/01 - 警告 |
| | ✅ | |
|
| 1000
| warning | 警告 | &
#x2705; | | |
| 0100C
| dynamic_result_sets_returned | 返回了动态结果集
| ✅ | | |
| 1008
| implicit_zero_bit_padding | 警告,隐含补齐了零比特位
| ✅ | | |
| 1003
| null_value_eliminated_in_set_function | 在集合函数里消除了 NULL
| ✅ | | |
| 1007
| privilege_not_granted | 没有赋予权限
| ✅ | | |
| 1006
| privilege_not_revoked | 没有撤销权限
| ✅ | | |
| 1004
| string_data_right_truncation | 字符串数据在右端截断
| ✅ | | |
| 01P01
| deprecated_feature | 废弃的特性
| ✅ | | |
| Class 02 — No Data (this is also a warning class per the SQL standard)/02 -
没有数据(按照 SQL 标准的要求,这也是警告类) |
| | ✅ | |
|
| 2000
| no_data | 没有数据 |
✅ | | |
| 2001
| no_additional_dynamic_result_sets_returned | 返回了无附加动态结果集
| ✅ | | |
| Class 03 — SQL Statement Not Yet Complete/03 - SQL 语句尚未结束
| |
of 22
100墨值下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

关注
最新上传
暂无内容,敬请期待...
下载排行榜
Top250 周榜 月榜