バージョンごとのドキュメント一覧

付録A PostgreSQLエラーコード

<title><productname>PostgreSQL</productname> Error Codes</title>

All messages emitted by the <productname>PostgreSQL</productname> server are assigned five-character error codes that follow the SQL standard's conventions for <quote>SQLSTATE</quote> 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 <productname>PostgreSQL</productname> 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 <productname>PostgreSQL</productname> 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コードの記述方法に従った、5文字のエラーコードが割り当てられています。 どのようなエラー条件が発生したかを把握しなければならないアプリケーションは、通常テキスト形式のエラーメッセージを確認するのではなく、このエラーコードを検査すべきです。 このエラーコードは、PostgreSQLリリースの違いによって変更することはあまりありません。また、エラーメッセージの各国言語化による変更にも影響されません。 PostgreSQLで発行されるエラーコードのいくつか(全部ではありません)は、標準SQLで定義されていることに注意してください。 標準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. 標準に従い、エラーコードの最初の2文字はエラーのクラスを表し、残り3文字がそのクラス内の特定条件を表します。 したがって、特定のエラーコードを認識できないアプリケーションであっても、エラークラスから何をすべきか推定できることがあります。

<xref linkend="errcodes-table"/> lists all the error codes defined in <productname>PostgreSQL</productname> &version;. (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 <quote>standard</quote> error code having the last three characters <literal>000</literal>. 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 16.0で定義されたエラーコードを全て一覧で示しています (標準SQLでは定義されていますが、現在実際に使用されていないものもあります)。 エラークラスも示しています。 各エラークラスには、残りの3文字が000となる標準エラーコードが存在します。 あるクラスの範囲内で発生したが、より特定のコードが割り当てられていないエラー条件のためだけに、このコードが使用されます。

The symbol shown in the column <quote>Condition Name</quote> is the condition name to use in <application>PL/pgSQL</application>. Condition names can be written in either upper or lower case. (Note that <application>PL/pgSQL</application> does not recognize warning, as opposed to error, condition names; those are classes 00, 01, and 02.) 条件名列に示されているシンボルはPL/pgSQLで使用している条件名です。 条件名は大文字もしくは小文字でも記述されます。(PL/pgSQLは、エラーの場合と異なり、警告の場合にはその状態名を認識しません。これらはクラス00と01と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 <symbol>unique_violation</symbol> 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 <productname>PostgreSQL</productname> 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(整合性制約違反)のみですが、将来的には十中八九拡張されそうです。

表A.1 PostgreSQLエラーコード

<title><productname>PostgreSQL</productname> Error Codes</title>
エラーコード条件名
クラス 00 — 正常終了
00000successful_completion
クラス 01 — 警告
01000warning
0100Cdynamic_result_sets_returned
01008implicit_zero_bit_padding
01003null_value_eliminated_in_set_function
01007privilege_not_granted
01006privilege_not_revoked
01004string_data_right_truncation
01P01deprecated_feature
クラス 02 — データがない(標準SQLではこれは警告クラスでもある)
02000no_data
02001no_additional_dynamic_result_sets_returned
クラス 03 — SQL文の未完了
03000sql_statement_not_yet_complete
クラス 08 — 接続の例外
08000connection_exception
08003connection_does_not_exist
08006connection_failure
08001sqlclient_unable_to_establish_sqlconnection
08004sqlserver_rejected_establishment_of_sqlconnection
08007transaction_resolution_unknown
08P01protocol_violation
クラス 09 — トリガによるアクションの例外
09000triggered_action_exception
クラス 0A — サポートされない機能
0A000feature_not_supported
クラス 0B — 無効なトランザクションの開始
0B000invalid_transaction_initiation
クラス 0F — 位置付け子の例外
0F000locator_exception
0F001invalid_locator_specification
クラス 0L — 無効な権限付与
0L000invalid_grantor
0LP01invalid_grant_operation
クラス 0P — 無効なロールの指定
0P000invalid_role_specification
クラス 0Z — 診断の例外
0Z000diagnostics_exception
0Z002stacked_diagnostics_accessed_without_active_handler
クラス 20 — caseが存在しない
20000case_not_found
クラス 21 — 次数違反
21000cardinality_violation
クラス 22 — データ例外
22000data_exception
2202Earray_subscript_error
22021character_not_in_repertoire
22008datetime_field_overflow
22012division_by_zero
22005error_in_assignment
2200Bescape_character_conflict
22022indicator_overflow
22015interval_field_overflow
2201Einvalid_argument_for_logarithm
22014invalid_argument_for_ntile_function
22016invalid_argument_for_nth_value_function
2201Finvalid_argument_for_power_function
2201Ginvalid_argument_for_width_bucket_function
22018invalid_character_value_for_cast
22007invalid_datetime_format
22019invalid_escape_character
2200Dinvalid_escape_octet
22025invalid_escape_sequence
22P06nonstandard_use_of_escape_character
22010invalid_indicator_parameter_value
22023invalid_parameter_value
22013invalid_preceding_or_following_size
2201Binvalid_regular_expression
2201Winvalid_row_count_in_limit_clause
2201Xinvalid_row_count_in_result_offset_clause
2202Hinvalid_tablesample_argument
2202Ginvalid_tablesample_repeat
22009invalid_time_zone_displacement_value
2200Cinvalid_use_of_escape_character
2200Gmost_specific_type_mismatch
22004null_value_not_allowed
22002null_value_no_indicator_parameter
22003numeric_value_out_of_range
2200Hsequence_generator_limit_exceeded
22026string_data_length_mismatch
22001string_data_right_truncation
22011substring_error
22027trim_error
22024unterminated_c_string
2200Fzero_length_character_string
22P01floating_point_exception
22P02invalid_text_representation
22P03invalid_binary_representation
22P04bad_copy_file_format
22P05untranslatable_character
2200Lnot_an_xml_document
2200Minvalid_xml_document
2200Ninvalid_xml_content
2200Sinvalid_xml_comment
2200Tinvalid_xml_processing_instruction
22030duplicate_json_object_key_value
22031invalid_argument_for_sql_json_datetime_function
22032invalid_json_text
22033invalid_sql_json_subscript
22034more_than_one_sql_json_item
22035no_sql_json_item
22036non_numeric_sql_json_item
22037non_unique_keys_in_a_json_object
22038singleton_sql_json_item_required
22039sql_json_array_not_found
2203Asql_json_member_not_found
2203Bsql_json_number_not_found
2203Csql_json_object_not_found
2203Dtoo_many_json_array_elements
2203Etoo_many_json_object_members
2203Fsql_json_scalar_required
クラス 23 — 整合性制約違反
23000integrity_constraint_violation
23001restrict_violation
23502not_null_violation
23503foreign_key_violation
23505unique_violation
23514check_violation
23P01exclusion_violation
クラス 24 — 無効なカーソル状態
24000invalid_cursor_state
クラス 25 — 無効なトランザクション状態
25000invalid_transaction_state
25001active_sql_transaction
25002branch_transaction_already_active
25008held_cursor_requires_same_isolation_level
25003inappropriate_access_mode_for_branch_transaction
25004inappropriate_isolation_level_for_branch_transaction
25005no_active_sql_transaction_for_branch_transaction
25006read_only_sql_transaction
25007schema_and_data_statement_mixing_not_supported
25P01no_active_sql_transaction
25P02in_failed_sql_transaction
25P03idle_in_transaction_session_timeout
クラス 26 — 無効なSQL文の名前
26000invalid_sql_statement_name
クラス 27 — トリガによるデータ変更違反
27000triggered_data_change_violation
クラス 28 — 無効な認証指定
28000invalid_authorization_specification
28P01invalid_password
クラス 2B — 依存する権限記述子がまだ存在する
2B000dependent_privilege_descriptors_still_exist
2BP01dependent_objects_still_exist
クラス 2D — 無効なトランザクションの終了
2D000invalid_transaction_termination
クラス 2F — SQLルーチン例外
2F000sql_routine_exception
2F005function_executed_no_return_statement
2F002modifying_sql_data_not_permitted
2F003prohibited_sql_statement_attempted
2F004reading_sql_data_not_permitted
クラス 34 — 無効なカーソル名称
34000invalid_cursor_name
クラス 38 — 外部ルーチン例外
38000external_routine_exception
38001containing_sql_not_permitted
38002modifying_sql_data_not_permitted
38003prohibited_sql_statement_attempted
38004reading_sql_data_not_permitted
クラス 39 — 外部ルーチン呼び出し例外
39000external_routine_invocation_exception
39001invalid_sqlstate_returned
39004null_value_not_allowed
39P01trigger_protocol_violated
39P02srf_protocol_violated
39P03event_trigger_protocol_violated
クラス 3B — セーブポイント例外
3B000savepoint_exception
3B001invalid_savepoint_specification
クラス 3D — 無効なカタログ名称
3D000invalid_catalog_name
クラス 3F — 無効なスキーマ名称
3F000invalid_schema_name
クラス 40 — トランザクションロールバック
40000transaction_rollback
40002transaction_integrity_constraint_violation
40001serialization_failure
40003statement_completion_unknown
40P01deadlock_detected
クラス 42 — 構文エラーもしくはアクセス規則違反
42000syntax_error_or_access_rule_violation
42601syntax_error
42501insufficient_privilege
42846cannot_coerce
42803grouping_error
42P20windowing_error
42P19invalid_recursion
42830invalid_foreign_key
42602invalid_name
42622name_too_long
42939reserved_name
42804datatype_mismatch
42P18indeterminate_datatype
42P21collation_mismatch
42P22indeterminate_collation
42809wrong_object_type
428C9generated_always
42703undefined_column
42883undefined_function
42P01undefined_table
42P02undefined_parameter
42704undefined_object
42701duplicate_column
42P03duplicate_cursor
42P04duplicate_database
42723duplicate_function
42P05duplicate_prepared_statement
42P06duplicate_schema
42P07duplicate_table
42712duplicate_alias
42710duplicate_object
42702ambiguous_column
42725ambiguous_function
42P08ambiguous_parameter
42P09ambiguous_alias
42P10invalid_column_reference
42611invalid_column_definition
42P11invalid_cursor_definition
42P12invalid_database_definition
42P13invalid_function_definition
42P14invalid_prepared_statement_definition
42P15invalid_schema_definition
42P16invalid_table_definition
42P17invalid_object_definition
クラス 44 — WITH CHECK OPTION違反
44000with_check_option_violation
クラス 53 — リソース不足
53000insufficient_resources
53100disk_full
53200out_of_memory
53300too_many_connections
53400configuration_limit_exceeded
クラス 54 — プログラム制限超過
54000program_limit_exceeded
54001statement_too_complex
54011too_many_columns
54023too_many_arguments
クラス 55 — 必要条件を満たさないオブジェクト
55000object_not_in_prerequisite_state
55006object_in_use
55P02cant_change_runtime_param
55P03lock_not_available
55P04unsafe_new_enum_value_usage
クラス 57 — 操作の介入
57000operator_intervention
57014query_canceled
57P01admin_shutdown
57P02crash_shutdown
57P03cannot_connect_now
57P04database_dropped
57P05idle_session_timeout
クラス 58 — システムエラー(PostgreSQL自体の外部のエラー)
58000system_error
58030io_error
58P01undefined_file
58P02duplicate_file
クラス 72 — スナップショット失敗
72000snapshot_too_old
クラス F0 — 設定ファイルエラー
F0000config_file_error
F0001lock_file_exists
クラス HV — 外部データラッパーエラー (SQL/MED)
HV000fdw_error
HV005fdw_column_name_not_found
HV002fdw_dynamic_parameter_value_needed
HV010fdw_function_sequence_error
HV021fdw_inconsistent_descriptor_information
HV024fdw_invalid_attribute_value
HV007fdw_invalid_column_name
HV008fdw_invalid_column_number
HV004fdw_invalid_data_type
HV006fdw_invalid_data_type_descriptors
HV091fdw_invalid_descriptor_field_identifier
HV00Bfdw_invalid_handle
HV00Cfdw_invalid_option_index
HV00Dfdw_invalid_option_name
HV090fdw_invalid_string_length_or_buffer_length
HV00Afdw_invalid_string_format
HV009fdw_invalid_use_of_null_pointer
HV014fdw_too_many_handles
HV001fdw_out_of_memory
HV00Pfdw_no_schemas
HV00Jfdw_option_name_not_found
HV00Kfdw_reply_handle
HV00Qfdw_schema_not_found
HV00Rfdw_table_not_found
HV00Lfdw_unable_to_create_execution
HV00Mfdw_unable_to_create_reply
HV00Nfdw_unable_to_establish_connection
クラス P0 — PL/pgSQLエラー
P0000plpgsql_error
P0001raise_exception
P0002no_data_found
P0003too_many_rows
P0004assert_failure
クラス XX — 内部エラー
XX000internal_error
XX001data_corrupted
XX002index_corrupted