?
Dokumen ini menggunakan Manual laman web PHP Cina Lepaskan
PostgreSQL服務(wù)器發(fā)出的所有消息都賦予 了五個字符的錯誤代碼,這些代碼遵循 SQL 的"SQLSTATE" 代碼的習慣。需要知道發(fā)生了什么錯誤條件的應(yīng)用通常應(yīng)該測試錯誤代碼, 而不是查看文本錯誤信息。這些錯誤代碼輕易不會隨著PostgreSQL 的版本更新而修改,并且一般也不會隨著錯誤信息的本地化而發(fā)生修改。 請注意有些(但不是全部)PostgreSQL生成的錯誤代碼是 由 SQL 標準定義的;有些標準沒有定義的錯誤條件是發(fā)明的或者是從其它數(shù)據(jù)庫借來的。
根據(jù)標準,錯誤代碼的頭兩個字符表示錯誤類別, 而后三個字符表示在該類別內(nèi)特定的條件。因此, 那些不能識別特定錯誤代碼的應(yīng)用仍然可以從錯誤類別中推斷要做什么。
Table A-1里面列出了PostgreSQL 8.2.3 定義的所有錯誤代碼(有些實際上目前并沒有使用, 但是 SQL 標準定義了)。錯誤類別也列出在此。對于每個錯誤類別都有個 "標準"的錯誤代碼,它的最后三個字符是000。 這個代碼只用于那些落在該類別內(nèi),但是沒有賦予任何更準確的代碼的錯誤條件。
PL/pgSQL用于每個錯誤代碼的條件名和表中顯示的措辭相同, 只是用下劃線代替了空白。比如,代碼22012, DIVISION BY ZERO 的條件名是DIVISION_BY_ZERO。 條件名大小寫無關(guān)。(請注意PL/pgSQL并不識別警告,這一點和錯誤、條件名正相反;那些是 00, 01, 02 類別。)
Table A-1. PostgreSQL 錯誤代碼
錯誤代碼 | 含義 | 常量名 |
---|---|---|
Class 00 — 成功完成 | ||
00000 | 成功完成 | successful_completion |
Class 01 — 警告 | ||
01000 | 警告 | warning |
0100C | 返回了動態(tài)結(jié)果 | dynamic_result_sets_returned |
01008 | 警告,隱含補齊了零比特位 | implicit_zero_bit_padding |
01003 | 在集合函數(shù)里消除null | null_value_eliminated_in_set_function |
01007 | 沒有賦予權(quán)限 | privilege_not_granted |
01006 | 沒有撤銷權(quán)限 | privilege_not_revoked |
01004 | 字符串數(shù)據(jù)在右端截斷 | string_data_right_truncation |
01P01 | 廢棄的特性 | deprecated_feature |
Class 02 — 沒有數(shù)據(jù)(按照 SQL 標準的要求,這也是警告類) | ||
02000 | 沒有數(shù)據(jù) | no_data |
02001 | 返回了沒有附加動態(tài)結(jié)果集 | no_additional_dynamic_result_sets_returned |
Class 03 — SQL語句尚未結(jié)束 | ||
03000 | SQL語句尚未結(jié)束 | sql_statement_not_yet_complete |
Class 08 — 連接異常 | ||
08000 | 連接異常 | connection_exception |
08003 | 連接不存在 | connection_does_not_exist |
08006 | 連接失敗 | connection_failure |
08001 | SQL 客戶端不能建立 SQL 連接 | sqlclient_unable_to_establish_sqlconnection |
08004 | SQL 服務(wù)器拒絕建立 SQL 連接 | sqlserver_rejected_establishment_of_sqlconnection |
08007 | 未知的事務(wù)解析 | transaction_resolution_unknown |
08P01 | 違反協(xié)議 | protocol_violation |
Class 09 — Triggered Action Exception觸發(fā)器動作異常 | ||
09000 | 觸發(fā)器動作異常 | triggered_action_exception |
Class 0A — 不支持特性 | ||
0A000 | 不支持此特性 | feature_not_supported |
Class 0B — 非法事務(wù)初始化 | ||
0B000 | 非法事務(wù)初始化 | invalid_transaction_initiation |
Class 0F — 定位器異常 | ||
0F000 | 定位器異常 | locator_exception |
0F001 | 非法的定位器聲明 | invalid_locator_specification |
Class 0L — 非法賦權(quán)者 | ||
0L000 | 非法賦權(quán)者 | invalid_grantor |
0LP01 | 非法賦權(quán)操作 | invalid_grant_operation |
Class 0P — 非法角色聲明 | ||
0P000 | 非法角色聲明 | invalid_role_specification |
Class 20 — 未發(fā)現(xiàn)情況 | ||
20000 | 未發(fā)現(xiàn)情況 | case_not_found |
Class 21 — 勢違例 | ||
21000 | 勢違例 | cardinality_violation |
Class 22 — 數(shù)據(jù)異常 | ||
22000 | 數(shù)據(jù)異常 | data_exception |
2202E | 數(shù)組下標錯誤 | array_subscript_error |
22021 | 字符不在規(guī)定范圍內(nèi) | character_not_in_repertoire |
22008 | 日期時間字段溢出 | datetime_field_overflow |
22012 | 被零除 | division_by_zero |
22005 | 賦值中出錯 | error_in_assignment |
2200B | 逃逸字符沖突 | escape_character_conflict |
22022 | INDICATOR OVERFLOW指示器溢出 | indicator_overflow |
22015 | 內(nèi)部字段溢出 | interval_field_overflow |
2201E | 對數(shù)運算的非法參數(shù) | invalid_argument_for_logarithm |
22014 | NTILE函數(shù)的無效參數(shù) | invalid_argument_for_ntile_function |
22016 | N倍函數(shù)的無效參數(shù) | invalid_argument_for_nth_value_function |
2201F | 指數(shù)函數(shù)的無效參數(shù) | invalid_argument_for_power_function |
2201G | BUCKET函數(shù)的非法參數(shù) | invalid_argument_for_width_bucket_function |
22018 | 類型轉(zhuǎn)換時非法的字符值 | invalid_character_value_for_cast |
22007 | 非法日期時間格式 | invalid_datetime_format |
22019 | 非法的逃逸字符 | invalid_escape_character |
2200D | 非法的逃逸字節(jié) | invalid_escape_octet |
22025 | 非法逃逸序列 | invalid_escape_sequence |
22P06 | 非標準使用逃逸字符 | nonstandard_use_of_escape_character |
22010 | 非法指示器參數(shù)值 | invalid_indicator_parameter_value |
22023 | 非法參數(shù)值 | invalid_parameter_value |
2201B | 非法正則表達式 | invalid_regular_expression |
2201W | 無效的行數(shù)限制 | invalid_row_count_in_limit_clause |
2201X | 在結(jié)果抵消子句中無效的行數(shù) | invalid_row_count_in_result_offset_clause |
22009 | 非法時區(qū)顯示值 | invalid_time_zone_displacement_value |
2200C | 逃逸字符的非法使用 | invalid_use_of_escape_character |
2200G | 最相關(guān)類型不匹配 | most_specific_type_mismatch |
22004 | 不允許 NULL 值 | null_value_not_allowed |
22002 | NULL 值不能做指示器參數(shù) | null_value_no_indicator_parameter |
22003 | 數(shù)字值超出范圍 | numeric_value_out_of_range |
22026 | 字符串數(shù)據(jù)長度不匹配 | string_data_length_mismatch |
22001 | 字符串數(shù)據(jù)右邊被截斷 | string_data_right_truncation |
22011 | 抽取子字符串錯誤 | substring_error |
22027 | 截斷錯誤 | trim_error |
22024 | 未結(jié)束的 C 字符串 | unterminated_c_string |
2200F | 零長度的字符串 | zero_length_character_string |
22P01 | 浮點異常 | floating_point_exception |
22P02 | 非法文本表現(xiàn)形式 | invalid_text_representation |
22P03 | 非法二進制表現(xiàn)形式 | invalid_binary_representation |
22P04 | 錯誤的COPY文件格式 | bad_copy_file_format |
22P05 | 不可翻譯字符 | untranslatable_character |
2200L | 不是一個XML文檔 | not_an_xml_document |
2200M | 無效的XML文檔 | invalid_xml_document |
2200N | 無效的XML內(nèi)容 | invalid_xml_content |
2200S | 無效的XML評論 | invalid_xml_comment |
2200T | 無效的XML處理指令 | invalid_xml_processing_instruction |
Class 23 — 違反完整性約束 | ||
23000 | 違反完整性約束 | integrity_constraint_violation |
23001 | 約束限制 | restrict_violation |
23502 | NOT NULL VIOLATION違反非空 | not_null_violation |
23503 | 違反外鍵約束 | foreign_key_violation |
23505 | 違反唯一約束 | unique_violation |
23514 | 違反檢查 | check_violation |
23P01 | 違反排除 | exclusion_violation |
Class 24 — 非法游標狀態(tài) | ||
24000 | 非法游標狀態(tài) | invalid_cursor_state |
Class 25 — 非法事務(wù)狀態(tài) | ||
25000 | 非法事務(wù)狀態(tài) | invalid_transaction_state |
25001 | 活躍的SQL狀態(tài) | active_sql_transaction |
25002 | 分支事務(wù)已經(jīng)激活 | branch_transaction_already_active |
25008 | 持有的指針要求同樣的隔離級別 | held_cursor_requires_same_isolation_level |
25003 | 對分支事務(wù)的不恰當?shù)脑L問方式 | inappropriate_access_mode_for_branch_transaction |
25004 | 對分支事務(wù)的不恰當?shù)母綦x級別 | inappropriate_isolation_level_for_branch_transaction |
25005 | 分支事務(wù)沒有活躍的SQL事務(wù) | no_active_sql_transaction_for_branch_transaction |
25006 | 只讀的SQL事務(wù) | read_only_sql_transaction |
25007 | 不支持混和的模式和數(shù)據(jù)語句 | schema_and_data_statement_mixing_not_supported |
25P01 | 沒有活躍的SQL事務(wù) | no_active_sql_transaction |
25P02 | 在失敗的SQL事務(wù)中 | in_failed_sql_transaction |
Class 26 — 非法SQL語句名 | ||
26000 | 非法SQL語句名 | invalid_sql_statement_name |
Class 27 — 觸發(fā)數(shù)據(jù)更改違規(guī) | ||
27000 | 觸發(fā)數(shù)據(jù)更改違規(guī) | triggered_data_change_violation |
Class 28 — 非法授權(quán)聲明 | ||
28000 | 非法授權(quán)聲明 | invalid_authorization_specification |
28P01 | 非法密碼 | invalid_password |
Class 2B — 依然存在依賴的優(yōu)先級描述符 | ||
2B000 | 依然存在依賴的優(yōu)先級描述符 | dependent_privilege_descriptors_still_exist |
2BP01 | 依賴性對象仍然存在 | dependent_objects_still_exist |
Class 2D — 非法的事務(wù)終止 | ||
2D000 | 非法的事務(wù)終止 | invalid_transaction_termination |
Class 2F — SQL過程異常 | ||
2F000 | SQL過程異常 | sql_routine_exception |
2F005 | 執(zhí)行的函數(shù)沒有返回語句 | function_executed_no_return_statement |
2F002 | 不允許修改SQL數(shù)據(jù) | modifying_sql_data_not_permitted |
2F003 | 企圖使用禁止的SQL語句 | prohibited_sql_statement_attempted |
2F004 | 不允許讀取SQL數(shù)據(jù) | reading_sql_data_not_permitted |
Class 34 — 非法指針名 | ||
34000 | 非法指針名 | invalid_cursor_name |
Class 38 — 外部過程異常 | ||
38000 | 外部過程異常 | external_routine_exception |
38001 | 不允許包含的SQL | containing_sql_not_permitted |
38002 | 不允許修改SQL數(shù)據(jù) | modifying_sql_data_not_permitted |
38003 | 企圖使用禁止的SQL語句 | prohibited_sql_statement_attempted |
38004 | 不允許讀取SQL數(shù)據(jù) | reading_sql_data_not_permitted |
Class 39 — 外部過程調(diào)用異常 | ||
39000 | 外部過程調(diào)用異常 | external_routine_invocation_exception |
39001 | 返回了非法的SQL狀態(tài) | invalid_sqlstate_returned |
39004 | 不允許使用NULL | null_value_not_allowed |
39P01 | 違反觸發(fā)器協(xié)議 | trigger_protocol_violated |
39P02 | 違反 SRF 協(xié)議 | srf_protocol_violated |
Class 3B — 保存點異常 | ||
3B000 | 保存點異常 | savepoint_exception |
3B001 | 無效的保存點聲明 | invalid_savepoint_specification |
Class 3D — 非法目錄名 | ||
3D000 | 非法目錄名 | invalid_catalog_name |
Class 3F — 非法模式名 | ||
3F000 | 非法模式名 | invalid_schema_name |
Class 40 — 事務(wù)回滾 | ||
40000 | 事務(wù)回滾 | transaction_rollback |
40002 | 違反事務(wù)完整性約束 | transaction_integrity_constraint_violation |
40001 | 串行化失敗 | serialization_failure |
40003 | 不知道語句是否結(jié)束 | statement_completion_unknown |
40P01 | 偵測到死鎖 | deadlock_detected |
Class 42 — 語法錯誤或者違反訪問規(guī)則 | ||
42000 | 語法錯誤或者違反訪問規(guī)則 | syntax_error_or_access_rule_violation |
42601 | 語法錯誤 | syntax_error |
42501 | 權(quán)限不夠 | insufficient_privilege |
42846 | 無法進行類型轉(zhuǎn)換 | cannot_coerce |
42803 | 分組錯誤 | grouping_error |
42P20 | 開窗口錯誤 | windowing_error |
42P19 | 非法遞歸 | invalid_recursion |
42830 | 非法的外鍵 | invalid_foreign_key |
42602 | 非法名稱 | invalid_name |
42622 | 名稱過長 | name_too_long |
42939 | 保留名稱 | reserved_name |
42804 | 數(shù)據(jù)類型不匹配 | datatype_mismatch |
42P18 | 模糊數(shù)據(jù)類型 | indeterminate_datatype |
42809 | 錯誤的對象類型 | wrong_object_type |
42703 | 未定義的字段 | undefined_column |
42883 | 未定義的函數(shù) | undefined_function |
42P01 | 未定義的表 | undefined_table |
42P02 | 未定義的參數(shù) | undefined_parameter |
42704 | 未定義對象 | undefined_object |
42701 | 重復(fù)的字段 | duplicate_column |
42P03 | 重復(fù)的游標 | duplicate_cursor |
42P04 | 重復(fù)的數(shù)據(jù)庫 | duplicate_database |
42723 | 重復(fù)的函數(shù) | duplicate_function |
42P05 | 重復(fù)的預(yù)備語句 | duplicate_prepared_statement |
42P06 | 重復(fù)的模式 | duplicate_schema |
42P07 | 重復(fù)的表 | duplicate_table |
42712 | 重復(fù)的別名 | duplicate_alias |
42710 | 重復(fù)的對象 | duplicate_object |
42702 | 模糊的字段 | ambiguous_column |
42725 | 模糊的函數(shù) | ambiguous_function |
42P08 | 模糊的參數(shù) | ambiguous_parameter |
42P09 | 模糊的別名 | ambiguous_alias |
42P10 | 非法字段引用 | invalid_column_reference |
42611 | 非法字段定義 | invalid_column_definition |
42P11 | 非法游標定義 | invalid_cursor_definition |
42P12 | 非法數(shù)據(jù)庫定義 | invalid_database_definition |
42P13 | 非法函數(shù)定義 | invalid_function_definition |
42P14 | 非法預(yù)備語句定義 | invalid_prepared_statement_definition |
42P15 | 非法模式定義 | invalid_schema_definition |
42P16 | 非法表定義 | invalid_table_definition |
42P17 | 非法對象定義 | invalid_object_definition |
Class 44 — 違反 WITH CHECK 選項 | ||
44000 | 違反 WITH CHECK 選項 | with_check_option_violation |
Class 53 — 資源不夠 | ||
53000 | 資源不夠 | insufficient_resources |
53100 | 磁盤滿 | disk_full |
53200 | 內(nèi)存耗盡 | out_of_memory |
53300 | 太多連接 | too_many_connections |
Class 54 — 過多的程序限制 | ||
54000 | 過多的程序限制 | program_limit_exceeded |
54001 | 語句太復(fù)雜 | statement_too_complex |
54011 | 字段太多 | too_many_columns |
54023 | 參數(shù)太多 | too_many_arguments |
Class 55 — 對象不在預(yù)先要求的狀態(tài) | ||
55000 | 對象不在預(yù)先要求的狀態(tài) | object_not_in_prerequisite_state |
55006 | 對象在使用中 | object_in_use |
55P02 | 無法修改運行時參數(shù) | cant_change_runtime_param |
55P03 | 鎖不可獲取 | lock_not_available |
Class 57 — 操作者干涉 | ||
57000 | 操作者干涉 | operator_intervention |
57014 | 查詢被取消 | query_canceled |
57P01 | 管理員關(guān)機 | admin_shutdown |
57P02 | 崩潰關(guān)機 | crash_shutdown |
57P03 | 現(xiàn)在無法連接 | cannot_connect_now |
57P04 | 刪除數(shù)據(jù)庫 | database_dropped |
Class 58 — 系統(tǒng)錯誤(PostgreSQL 自己內(nèi)部的錯誤) | ||
58030 | IO錯誤 | io_error |
58P01 | 未定義的文件 | undefined_file |
58P02 | 備份文件(未定義文件) | duplicate_file |
Class F0 — 配置文件錯誤 | ||
F0000 | 配置文件錯誤 | config_file_error |
F0001 | 鎖文件存在 | lock_file_exists |
Class P0 — PL/pgSQL 錯誤 | ||
P0000 | PL/pgSQL 錯誤 | plpgsql_error |
P0001 | 上升異常 | raise_exception |
P0002 | 未找到數(shù)據(jù) | no_data_found |
P0003 | 行太多 | too_many_rows |
Class XX — 內(nèi)部錯誤 | ||
XX000 | 內(nèi)部錯誤 | internal_error |
XX001 | 數(shù)據(jù)損壞 | data_corrupted |
XX002 | 索引損壞 | index_corrupted |