Skip to content

This is the multi-page printable view of this section. .

Return to the regular view of this page.

PostgreSQL SQLSTATE Atlas

Find a PostgreSQL SQLSTATE, understand the failure stage, and find diagnosis and recovery guidance.

Start with the five-character code from a driver exception or server log. The catalogue keeps the SQLSTATE uppercase as its stable identity; URLs use lowercase where a letter is present. Search covers condition names, macros, translated names, and verified message templates.

Browse the atlas

Entry point Use it for
All codes The complete deduplicated SQLSTATE directory
Classes Shared meaning and members of a class
Common codes A curated incident-oriented starting list
Topics Constraint, authentication, transaction, timeout, and resource paths
Versions Presence and evidence-backed changes by PostgreSQL release
Guides Reading diagnostics, transaction recovery, retry, and client handling

Evidence contract

Each accepted entry separates directory identity, implementation paths, documented behavior, and local runtime observations. A source-only fact is labelled as such; a runtime claim names its case and run result. Preview releases are kept in their own version view and do not inflate the formal release count.

The directory contains all 263 frozen SQLSTATE identities as paired English and Chinese pages. Coverage reports distinguish full explanations, source-backed references, editorial review, and selected runtime outcomes; a source-backed reference does not claim a runtime diagnosis without a retained case result.

Coverage

See coverage for the version matrix and methodology for collection boundaries, evidence states, and translation rules.

1 - All SQLSTATE codes

The complete SQLSTATE directory, generated from frozen PostgreSQL release sources.

Browse the complete SQLSTATE catalogue by class, version and content depth. Each code links to reviewed English and Chinese explanations. See the coverage page for current content and runtime coverage.

Read the methodology page for the identity and evidence contract.

Code Class Condition Status Known present by Formal versions Preview versions Depth
00000 00 successful_completion active 7.4 all 16 formal all 1 preview reference
01000 01 warning active 7.4 all 16 formal all 1 preview reference
01003 01 null_value_eliminated_in_set_function active 7.4 all 16 formal all 1 preview reference
01004 01 string_data_right_truncation active 7.4 all 16 formal all 1 preview reference
01006 01 privilege_not_revoked active 8.0.0 all 16 formal all 1 preview reference
01007 01 privilege_not_granted active 8.0.0 all 16 formal all 1 preview reference
01008 01 implicit_zero_bit_padding active 7.4 all 16 formal all 1 preview reference
0100C 01 dynamic_result_sets_returned active 7.4 all 16 formal all 1 preview reference
01P01 01 deprecated_feature active 8.0.0 all 16 formal all 1 preview reference
02000 02 no_data active 7.4 all 16 formal all 1 preview reference
02001 02 no_additional_dynamic_result_sets_returned active 7.4 all 16 formal all 1 preview reference
03000 03 sql_statement_not_yet_complete active 7.4 all 16 formal all 1 preview reference
08000 08 connection_exception active 7.4 all 16 formal all 1 preview reference
08001 08 sqlclient_unable_to_establish_sqlconnection active 7.4 all 16 formal all 1 preview full
08003 08 connection_does_not_exist active 7.4 all 16 formal all 1 preview full
08004 08 sqlserver_rejected_establishment_of_sqlconnection active 7.4 all 16 formal all 1 preview reference
08006 08 connection_failure active 7.4 all 16 formal all 1 preview full
08007 08 transaction_resolution_unknown active 7.4 all 16 formal all 1 preview reference
08P01 08 protocol_violation active 7.4 all 16 formal all 1 preview full
09000 09 triggered_action_exception active 7.4 all 16 formal all 1 preview reference
0A000 0A feature_not_supported active 7.4 all 16 formal all 1 preview full
0B000 0B invalid_transaction_initiation active 7.4 all 16 formal all 1 preview reference
0F000 0F locator_exception active 7.4 all 16 formal all 1 preview reference
0F001 0F invalid_locator_specification active 7.4 all 16 formal all 1 preview reference
0L000 0L invalid_grantor active 7.4 all 16 formal all 1 preview reference
0LP01 0L invalid_grant_operation active 7.4 all 16 formal all 1 preview reference
0P000 0P invalid_role_specification active 7.4 all 16 formal all 1 preview reference
0Z000 0Z diagnostics_exception active 9.2.0 9.2.24 → 18.6 (14) all 1 preview reference
0Z002 0Z stacked_diagnostics_accessed_without_active_handler active 9.2.0 9.2.24 → 18.6 (14) all 1 preview reference
10608 10 invalid_argument_for_xquery active 18.0 18.6 all 1 preview reference
20000 20 case_not_found active 8.4.0 all 16 formal all 1 preview reference
21000 21 cardinality_violation active 7.4 all 16 formal all 1 preview full
22000 22 data_exception active 7.4 all 16 formal all 1 preview reference
22001 22 string_data_right_truncation active 7.4 all 16 formal all 1 preview full
22002 22 null_value_no_indicator_parameter active 7.4 all 16 formal all 1 preview reference
22003 22 numeric_value_out_of_range active 7.4 all 16 formal all 1 preview full
22004 22 null_value_not_allowed active 7.4 all 16 formal all 1 preview full
22005 22 error_in_assignment active 7.4 all 16 formal all 1 preview reference
22007 22 invalid_datetime_format active 7.4 all 16 formal all 1 preview full
22008 22 datetime_field_overflow active 7.4 all 16 formal all 1 preview reference
22009 22 invalid_time_zone_displacement_value active 7.4 all 16 formal all 1 preview reference
2200B 22 escape_character_conflict active 7.4 all 16 formal all 1 preview reference
2200C 22 invalid_use_of_escape_character active 7.4 all 16 formal all 1 preview reference
2200D 22 invalid_escape_octet active 7.4 all 16 formal all 1 preview reference
2200F 22 zero_length_character_string active 7.4 all 16 formal all 1 preview reference
2200G 22 most_specific_type_mismatch active 7.4 all 16 formal all 1 preview reference
2200H 22 sequence_generator_limit_exceeded active 10.0 10.23 → 18.6 (9) all 1 preview reference
2200L 22 not_an_xml_document active 8.3.0 all 16 formal all 1 preview reference
2200M 22 invalid_xml_document active 8.3.0 all 16 formal all 1 preview reference
2200N 22 invalid_xml_content active 8.3.0 all 16 formal all 1 preview reference
2200S 22 invalid_xml_comment active 8.3.0 all 16 formal all 1 preview reference
2200T 22 invalid_xml_processing_instruction active 8.3.0 all 16 formal all 1 preview reference
22010 22 invalid_indicator_parameter_value active 7.4 all 16 formal all 1 preview reference
22011 22 substring_error active 7.4 all 16 formal all 1 preview reference
22012 22 division_by_zero active 7.4 all 16 formal all 1 preview full
22013 22 invalid_preceding_or_following_size active 11.0 11.22 → 18.6 (8) all 1 preview reference
22014 22 invalid_argument_for_ntile_function active 8.4.0 all 16 formal all 1 preview reference
22015 22 interval_field_overflow active 7.4 all 16 formal all 1 preview reference
22016 22 invalid_argument_for_nth_value_function active 8.4.0 all 16 formal all 1 preview reference
22018 22 invalid_character_value_for_cast active 7.4 all 16 formal all 1 preview reference
22019 22 invalid_escape_character active 7.4 all 16 formal all 1 preview reference
2201B 22 invalid_regular_expression active 7.4 all 16 formal all 1 preview reference
2201E 22 invalid_argument_for_logarithm active 8.0.0 all 16 formal all 1 preview reference
2201F 22 invalid_argument_for_power_function active 8.0.0 all 16 formal all 1 preview reference
2201G 22 invalid_argument_for_width_bucket_function active 8.0.0 all 16 formal all 1 preview reference
2201W 22 invalid_row_count_in_limit_clause active 8.4.0 all 16 formal all 1 preview reference
2201X 22 invalid_row_count_in_result_offset_clause active 8.4.0 all 16 formal all 1 preview reference
22021 22 character_not_in_repertoire active 7.4 all 16 formal all 1 preview reference
22022 22 indicator_overflow active 7.4 all 16 formal all 1 preview reference
22023 22 invalid_parameter_value active 7.4 all 16 formal all 1 preview full
22024 22 unterminated_c_string active 7.4 all 16 formal all 1 preview reference
22025 22 invalid_escape_sequence active 7.4 all 16 formal all 1 preview reference
22026 22 string_data_length_mismatch active 7.4 all 16 formal all 1 preview reference
22027 22 trim_error active 7.4 all 16 formal all 1 preview reference
2202E 22 array_subscript_error active 7.4 all 16 formal all 1 preview full
2202G 22 invalid_tablesample_repeat active 9.5.0 9.5.25 → 18.6 (11) all 1 preview reference
2202H 22 invalid_tablesample_argument active 9.5.0 9.5.25 → 18.6 (11) all 1 preview reference
22030 22 duplicate_json_object_key_value active 12.0 12.22 → 18.6 (7) all 1 preview reference
22031 22 invalid_argument_for_sql_json_datetime_function active 13.0 13.23 → 18.6 (6) all 1 preview reference
22032 22 invalid_json_text active 12.0 12.22 → 18.6 (7) all 1 preview reference
22033 22 invalid_sql_json_subscript active 12.0 12.22 → 18.6 (7) all 1 preview reference
22034 22 more_than_one_sql_json_item active 12.0 12.22 → 18.6 (7) all 1 preview reference
22035 22 no_sql_json_item active 12.0 12.22 → 18.6 (7) all 1 preview reference
22036 22 non_numeric_sql_json_item active 12.0 12.22 → 18.6 (7) all 1 preview reference
22037 22 non_unique_keys_in_a_json_object active 12.0 12.22 → 18.6 (7) all 1 preview reference
22038 22 singleton_sql_json_item_required active 12.0 12.22 → 18.6 (7) all 1 preview reference
22039 22 sql_json_array_not_found active 12.0 12.22 → 18.6 (7) all 1 preview reference
2203A 22 sql_json_member_not_found active 12.0 12.22 → 18.6 (7) all 1 preview reference
2203B 22 sql_json_number_not_found active 12.0 12.22 → 18.6 (7) all 1 preview reference
2203C 22 sql_json_object_not_found active 12.0 12.22 → 18.6 (7) all 1 preview reference
2203D 22 too_many_json_array_elements active 12.0 12.22 → 18.6 (7) all 1 preview reference
2203E 22 too_many_json_object_members active 12.0 12.22 → 18.6 (7) all 1 preview reference
2203F 22 sql_json_scalar_required active 12.0 12.22 → 18.6 (7) all 1 preview reference
2203G 22 sql_json_item_cannot_be_cast_to_target_type active 15.0 15.19 → 18.6 (4) all 1 preview reference
22P01 22 floating_point_exception active 7.4 all 16 formal all 1 preview reference
22P02 22 invalid_text_representation active 7.4 all 16 formal all 1 preview full
22P03 22 invalid_binary_representation active 7.4 all 16 formal all 1 preview reference
22P04 22 bad_copy_file_format active 7.4 all 16 formal all 1 preview reference
22P05 22 untranslatable_character active 7.4 all 16 formal all 1 preview reference
22P06 22 nonstandard_use_of_escape_character active 8.1.0 all 16 formal all 1 preview reference
23000 23 integrity_constraint_violation active 7.4 all 16 formal all 1 preview reference
23001 23 restrict_violation active 7.4 all 16 formal all 1 preview full
23502 23 not_null_violation active 7.4 all 16 formal all 1 preview full
23503 23 foreign_key_violation active 7.4 all 16 formal all 1 preview full
23505 23 unique_violation active 7.4 all 16 formal all 1 preview full
23514 23 check_violation active 7.4 all 16 formal all 1 preview full
23P01 23 exclusion_violation active 9.0.0 all 16 formal all 1 preview full
24000 24 invalid_cursor_state active 7.4 all 16 formal all 1 preview reference
25000 25 invalid_transaction_state active 7.4 all 16 formal all 1 preview reference
25001 25 active_sql_transaction active 7.4 all 16 formal all 1 preview full
25002 25 branch_transaction_already_active active 7.4 all 16 formal all 1 preview reference
25003 25 inappropriate_access_mode_for_branch_transaction active 7.4 all 16 formal all 1 preview reference
25004 25 inappropriate_isolation_level_for_branch_transaction active 7.4 all 16 formal all 1 preview reference
25005 25 no_active_sql_transaction_for_branch_transaction active 7.4 all 16 formal all 1 preview reference
25006 25 read_only_sql_transaction active 7.4 all 16 formal all 1 preview full
25007 25 schema_and_data_statement_mixing_not_supported active 7.4 all 16 formal all 1 preview reference
25008 25 held_cursor_requires_same_isolation_level active 7.4 all 16 formal all 1 preview reference
25P01 25 no_active_sql_transaction active 7.4 all 16 formal all 1 preview reference
25P02 25 in_failed_sql_transaction active 7.4 all 16 formal all 1 preview full
25P03 25 idle_in_transaction_session_timeout active 9.6.0 9.6.24 → 18.6 (10) all 1 preview full
25P04 25 transaction_timeout active 17.0 17.11 → 18.6 (2) all 1 preview full
26000 26 invalid_sql_statement_name active 7.4 all 16 formal all 1 preview full
27000 27 triggered_data_change_violation active 7.4 all 16 formal all 1 preview reference
28000 28 invalid_authorization_specification active 7.4 all 16 formal all 1 preview full
28P01 28 invalid_password active 9.0.0 all 16 formal all 1 preview full
2B000 2B dependent_privilege_descriptors_still_exist active 7.4 all 16 formal all 1 preview reference
2BP01 2B dependent_objects_still_exist active 7.4 all 16 formal all 1 preview full
2D000 2D invalid_transaction_termination active 7.4 all 16 formal all 1 preview reference
2F000 2F sql_routine_exception active 7.4 all 16 formal all 1 preview reference
2F002 2F modifying_sql_data_not_permitted active 7.4 all 16 formal all 1 preview reference
2F003 2F prohibited_sql_statement_attempted active 7.4 all 16 formal all 1 preview reference
2F004 2F reading_sql_data_not_permitted active 7.4 all 16 formal all 1 preview reference
2F005 2F function_executed_no_return_statement active 7.4 all 16 formal all 1 preview reference
34000 34 invalid_cursor_name active 7.4 all 16 formal all 1 preview full
38000 38 external_routine_exception active 7.4 all 16 formal all 1 preview reference
38001 38 containing_sql_not_permitted active 7.4 all 16 formal all 1 preview reference
38002 38 modifying_sql_data_not_permitted active 7.4 all 16 formal all 1 preview reference
38003 38 prohibited_sql_statement_attempted active 7.4 all 16 formal all 1 preview reference
38004 38 reading_sql_data_not_permitted active 7.4 all 16 formal all 1 preview reference
39000 39 external_routine_invocation_exception active 7.4 all 16 formal all 1 preview reference
39001 39 invalid_sqlstate_returned active 7.4 all 16 formal all 1 preview reference
39004 39 null_value_not_allowed active 7.4 all 16 formal all 1 preview reference
39P01 39 trigger_protocol_violated active 7.4 all 16 formal all 1 preview reference
39P02 39 srf_protocol_violated active 7.4 all 16 formal all 1 preview reference
39P03 39 event_trigger_protocol_violated active 9.5.0 9.5.25 → 18.6 (11) all 1 preview reference
3B000 3B savepoint_exception active 8.0.0 all 16 formal all 1 preview reference
3B001 3B invalid_savepoint_specification active 8.0.0 all 16 formal all 1 preview reference
3D000 3D invalid_catalog_name active 7.4 all 16 formal all 1 preview full
3F000 3F invalid_schema_name active 7.4 all 16 formal all 1 preview full
40000 40 transaction_rollback active 7.4 all 16 formal all 1 preview reference
40001 40 serialization_failure active 7.4 all 16 formal all 1 preview full
40002 40 transaction_integrity_constraint_violation active 7.4 all 16 formal all 1 preview reference
40003 40 statement_completion_unknown active 7.4 all 16 formal all 1 preview reference
40P01 40 deadlock_detected active 7.4 all 16 formal all 1 preview full
42000 42 syntax_error_or_access_rule_violation active 7.4 all 16 formal all 1 preview reference
42501 42 insufficient_privilege active 7.4 all 16 formal all 1 preview full
42601 42 syntax_error active 7.4 all 16 formal all 1 preview full
42602 42 invalid_name active 7.4 all 16 formal all 1 preview reference
42611 42 invalid_column_definition active 7.4 all 16 formal all 1 preview reference
42622 42 name_too_long active 7.4 all 16 formal all 1 preview reference
42701 42 duplicate_column active 7.4 all 16 formal all 1 preview full
42702 42 ambiguous_column active 7.4 all 16 formal all 1 preview full
42703 42 undefined_column active 7.4 all 16 formal all 1 preview full
42704 42 undefined_object active 7.4 all 16 formal all 1 preview full
42710 42 duplicate_object active 7.4 all 16 formal all 1 preview full
42712 42 duplicate_alias active 7.4 all 16 formal all 1 preview reference
42723 42 duplicate_function active 7.4 all 16 formal all 1 preview reference
42725 42 ambiguous_function active 7.4 all 16 formal all 1 preview reference
42803 42 grouping_error active 7.4 all 16 formal all 1 preview full
42804 42 datatype_mismatch active 7.4 all 16 formal all 1 preview full
42809 42 wrong_object_type active 7.4 all 16 formal all 1 preview reference
42830 42 invalid_foreign_key active 7.4 all 16 formal all 1 preview reference
42846 42 cannot_coerce active 7.4 all 16 formal all 1 preview reference
42883 42 undefined_function active 7.4 all 16 formal all 1 preview full
428C9 42 generated_always active 10.0 10.23 → 18.6 (9) all 1 preview full
42939 42 reserved_name active 7.4 all 16 formal all 1 preview full
42P01 42 undefined_table active 7.4 all 16 formal all 1 preview full
42P02 42 undefined_parameter active 7.4 all 16 formal all 1 preview full
42P03 42 duplicate_cursor active 7.4 all 16 formal all 1 preview full
42P04 42 duplicate_database active 7.4 all 16 formal all 1 preview full
42P05 42 duplicate_prepared_statement active 7.4 all 16 formal all 1 preview full
42P06 42 duplicate_schema active 7.4 all 16 formal all 1 preview full
42P07 42 duplicate_table active 7.4 all 16 formal all 1 preview full
42P08 42 ambiguous_parameter active 7.4 all 16 formal all 1 preview full
42P09 42 ambiguous_alias active 7.4 all 16 formal all 1 preview full
42P10 42 invalid_column_reference active 7.4 all 16 formal all 1 preview reference
42P11 42 invalid_cursor_definition active 7.4 all 16 formal all 1 preview reference
42P12 42 invalid_database_definition active 7.4 all 16 formal all 1 preview reference
42P13 42 invalid_function_definition active 7.4 all 16 formal all 1 preview reference
42P14 42 invalid_prepared_statement_definition active 7.4 all 16 formal all 1 preview reference
42P15 42 invalid_schema_definition active 7.4 all 16 formal all 1 preview reference
42P16 42 invalid_table_definition active 7.4 all 16 formal all 1 preview reference
42P17 42 invalid_object_definition active 7.4 all 16 formal all 1 preview reference
42P18 42 indeterminate_datatype active 7.4 all 16 formal all 1 preview full
42P19 42 invalid_recursion active 8.4.0 all 16 formal all 1 preview reference
42P20 42 windowing_error active 8.4.0 all 16 formal all 1 preview reference
42P21 42 collation_mismatch active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
42P22 42 indeterminate_collation active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
44000 44 with_check_option_violation active 7.4 all 16 formal all 1 preview full
53000 53 insufficient_resources active 7.4 all 16 formal all 1 preview reference
53100 53 disk_full active 7.4 all 16 formal all 1 preview full
53200 53 out_of_memory active 7.4 all 16 formal all 1 preview full
53300 53 too_many_connections active 7.4 all 16 formal all 1 preview full
53400 53 configuration_limit_exceeded active 9.2.0 9.2.24 → 18.6 (14) all 1 preview full
54000 54 program_limit_exceeded active 7.4 all 16 formal all 1 preview full
54001 54 statement_too_complex active 7.4 all 16 formal all 1 preview full
54011 54 too_many_columns active 7.4 all 16 formal all 1 preview full
54023 54 too_many_arguments active 7.4 all 16 formal all 1 preview full
55000 55 object_not_in_prerequisite_state active 7.4 all 16 formal all 1 preview full
55006 55 object_in_use active 7.4 all 16 formal all 1 preview full
55P02 55 cant_change_runtime_param active 7.4 all 16 formal all 1 preview reference
55P03 55 lock_not_available active 8.0.0 all 16 formal all 1 preview full
55P04 55 unsafe_new_enum_value_usage active 12.0 12.22 → 18.6 (7) all 1 preview reference
57000 57 operator_intervention active 7.4 all 16 formal all 1 preview reference
57014 57 query_canceled active 7.4 all 16 formal all 1 preview full
57P01 57 admin_shutdown active 7.4 all 16 formal all 1 preview full
57P02 57 crash_shutdown active 7.4 all 16 formal all 1 preview reference
57P03 57 cannot_connect_now active 7.4 all 16 formal all 1 preview full
57P04 57 database_dropped active 9.0.4 all 16 formal all 1 preview reference
57P05 57 idle_session_timeout active 14.0 14.24 → 18.6 (5) all 1 preview full
58000 58 system_error active 9.2.0 9.2.24 → 18.6 (14) all 1 preview reference
58030 58 io_error active 7.4 all 16 formal all 1 preview full
58P01 58 undefined_file active 7.4 all 16 formal all 1 preview full
58P02 58 duplicate_file active 7.4 all 16 formal all 1 preview reference
58P03 58 file_name_too_long active 18.0 18.6 all 1 preview full
72000 72 snapshot_too_old removed 9.6.0 9.6.24 → 16.15 (8) full
F0000 F0 config_file_error active 7.4 all 16 formal all 1 preview full
F0001 F0 lock_file_exists active 7.4 all 16 formal all 1 preview full
HV000 HV fdw_error active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV001 HV fdw_out_of_memory active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV002 HV fdw_dynamic_parameter_value_needed active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV004 HV fdw_invalid_data_type active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV005 HV fdw_column_name_not_found active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV006 HV fdw_invalid_data_type_descriptors active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV007 HV fdw_invalid_column_name active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV008 HV fdw_invalid_column_number active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV009 HV fdw_invalid_use_of_null_pointer active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV00A HV fdw_invalid_string_format active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV00B HV fdw_invalid_handle active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV00C HV fdw_invalid_option_index active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV00D HV fdw_invalid_option_name active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV00J HV fdw_option_name_not_found active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV00K HV fdw_reply_handle active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV00L HV fdw_unable_to_create_execution active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV00M HV fdw_unable_to_create_reply active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV00N HV fdw_unable_to_establish_connection active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV00P HV fdw_no_schemas active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV00Q HV fdw_schema_not_found active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV00R HV fdw_table_not_found active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV010 HV fdw_function_sequence_error active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV014 HV fdw_too_many_handles active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV021 HV fdw_inconsistent_descriptor_information active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV024 HV fdw_invalid_attribute_value active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV090 HV fdw_invalid_string_length_or_buffer_length active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
HV091 HV fdw_invalid_descriptor_field_identifier active 9.1.0 9.1.24 → 18.6 (15) all 1 preview reference
P0000 P0 plpgsql_error active 8.0.0 all 16 formal all 1 preview reference
P0001 P0 raise_exception active 8.0.0 all 16 formal all 1 preview full
P0002 P0 no_data_found active 8.2.0 all 16 formal all 1 preview reference
P0003 P0 too_many_rows active 8.2.0 all 16 formal all 1 preview reference
P0004 P0 assert_failure active 9.5.0 9.5.25 → 18.6 (11) all 1 preview full
XX000 XX internal_error active 7.4 all 16 formal all 1 preview reference
XX001 XX data_corrupted active 7.4 all 16 formal all 1 preview full
XX002 XX index_corrupted active 7.4 all 16 formal all 1 preview full

2 - SQLSTATE classes

Browse PostgreSQL conditions by the first two characters of SQLSTATE.

The class index groups codes by the first two SQLSTATE characters. A class describes a broad condition family; it does not prove that every member has the same severity, transaction aftermath, or retry behavior.

The generated member list links to one canonical page per code. A member’s class is directory identity; mechanism and recovery remain on the code page.

Class Name Members
00 Successful Completion 00000
01 Warning 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01
02 No Data (this is also a warning class per the SQL standard) 02000, 02001
03 SQL Statement Not Yet Complete 03000
08 Connection Exception 08000, 08001, 08003, 08004, 08006, 08007, 08P01
09 Triggered Action Exception 09000
0A Feature Not Supported 0A000
0B Invalid Transaction Initiation 0B000
0F Locator Exception 0F000, 0F001
0L Invalid Grantor 0L000, 0LP01
0P Invalid Role Specification 0P000
0Z Diagnostics Exception 0Z000, 0Z002
10 XQuery Error 10608
20 Case Not Found 20000
21 Cardinality Violation 21000
22 Data Exception 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200H, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22013, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 2202G, 2202H, 22030, 22031, 22032, 22033, 22034, 22035, 22036, 22037, 22038, 22039, 2203A, 2203B, 2203C, 2203D, 2203E, 2203F, 2203G, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06
23 Integrity Constraint Violation 23000, 23001, 23502, 23503, 23505, 23514, 23P01
24 Invalid Cursor State 24000
25 Invalid Transaction State 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 25P03, 25P04
26 Invalid SQL Statement Name 26000
27 Triggered Data Change Violation 27000
28 Invalid Authorization Specification 28000, 28P01
2B Dependent Privilege Descriptors Still Exist 2B000, 2BP01
2D Invalid Transaction Termination 2D000
2F SQL Routine Exception 2F000, 2F002, 2F003, 2F004, 2F005
34 Invalid Cursor Name 34000
38 External Routine Exception 38000, 38001, 38002, 38003, 38004
39 External Routine Invocation Exception 39000, 39001, 39004, 39P01, 39P02, 39P03
3B Savepoint Exception 3B000, 3B001
3D Invalid Catalog Name 3D000
3F Invalid Schema Name 3F000
40 Transaction Rollback 40000, 40001, 40002, 40003, 40P01
42 Syntax Error or Access Rule Violation 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 428C9, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22
44 WITH CHECK OPTION Violation 44000
53 Insufficient Resources 53000, 53100, 53200, 53300, 53400
54 Program Limit Exceeded 54000, 54001, 54011, 54023
55 Object Not In Prerequisite State 55000, 55006, 55P02, 55P03, 55P04
57 Operator Intervention 57000, 57014, 57P01, 57P02, 57P03, 57P04, 57P05
58 System Error (errors external to PostgreSQL itself) 58000, 58030, 58P01, 58P02, 58P03
72 Snapshot Failure 72000
F0 Configuration File Error F0000, F0001
HV Foreign Data Wrapper Error (SQL/MED) HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091
P0 PL/pgSQL Error P0000, P0001, P0002, P0003, P0004
XX Internal Error XX000, XX001, XX002

3 - Common codes

A curated list of SQLSTATE values useful during incident triage.

This is an editorial entry point for frequent diagnosis paths. It is not a measured ranking of production frequency; each row states the practical question the entry helps answer and preserves its review state.

Code Condition Why start here
23505 unique_violation Duplicate keys, constraints, and idempotent writes.
23503 foreign_key_violation Foreign-key repair and dependency order.
23502 not_null_violation Missing required values and input validation.
23514 check_violation CHECK constraints and invariant failures.
23P01 exclusion_violation Exclusion constraints and range conflicts.
40P01 deadlock_detected Deadlock diagnosis, rollback, and lock ordering.
40001 serialization_failure Serializable retry and fresh transaction snapshots.
25P02 in_failed_sql_transaction The failed transaction state that follows an error.
42P01 undefined_table Missing relations and search-path diagnosis.
42601 syntax_error Syntax errors before a statement can execute.
42501 insufficient_privilege Privilege checks and authorization failures.
28P01 invalid_password Password authentication and connection setup.
57014 query_canceled Cancellation, statement_timeout, and safe follow-up.
53300 too_many_connections Connection limits and admission failures.
2202E array_subscript_error Array dimensions, concatenation, and type rules.
01000 warning Warning dispatch and non-error diagnostics.
P0001 raise_exception Application-defined PL/pgSQL exceptions.
XX000 internal_error Internal-error safety boundaries and escalation.

4 - Topics

Start from an operational problem and find its SQLSTATE paths.

Topic indexes cover constraint conflicts, authentication and authorization, transaction retry, locks and timeouts, object resolution, and resource or system failures. Topics point to code pages; they do not create a second identity for a condition.

Topic Codes
Constraints and conflicts 23505, 23503, 23502, 23514, 23P01, 23000, 23001
Authentication and privileges 28P01, 28000, 42501
Transactions, locks, and retry 40P01, 40001, 25P02, 25006, 57014
Syntax and object resolution 42601, 42P01, 42P02, 42701, 42703, 42883
Resources and connectivity 53300, 53000, 53100, 53200, 57P01, 57P03, 58000
Data and type boundaries 2202E, 22003, 22007, 22P02

5 - PostgreSQL versions

Compare SQLSTATE definitions and documented changes across releases.

The generated table distinguishes formal PostgreSQL releases from the latest preview snapshot. Presence means the definition was found in the locked source; it does not by itself prove a runtime path or an exact introduction release.

Version Channel Codes Evidence
9.0.23 formal 199 locked source
9.1.24 formal 228 locked source
9.2.24 formal 232 locked source
9.3.25 formal 232 locked source
9.4.26 formal 232 locked source
9.5.25 formal 236 locked source
9.6.24 formal 238 locked source
10.23 formal 240 locked source
11.22 formal 241 locked source
12.22 formal 257 locked source
13.23 formal 258 locked source
14.24 formal 259 locked source
15.19 formal 260 locked source
16.15 formal 260 locked source
17.11 formal 260 locked source
18.6 formal 262 locked source
19beta3 preview 262 locked source

6 - Guides

Shared methods for reading PostgreSQL diagnostics, recovering transaction state, and choosing client boundaries.

Read the wire diagnostic

Start with the protocol message type. PostgreSQL sends an ErrorResponse for an error and a NoticeResponse for a notice; both carry identified fields terminated by a zero byte. The C field is the non-localized SQLSTATE, M is the primary message, and D/H are optional detail and hint. S can be localized; V is the non-localized severity when supplied. Schema (s), table (t), column (c), constraint (n), position (P), context (W), source file (F), line (L), and routine (R) are conditional fields: preserve them when present and do not infer missing fields. See the PostgreSQL 18 error and notice fields and message formats.

A directory class is only a classifier. Read the actual protocol severity and message type before deciding whether a command failed. A WARNING or NOTICE may arrive as a notice while the command completes; ERROR arrives as an error and normally changes explicit transaction state. A successful CommandComplete has a command tag and no ErrorResponse SQLSTATE. Keep the server version and operation beside the fields because one SQLSTATE can have several source paths.

Recover the right transaction boundary

Autocommit gives each statement its own transaction boundary. After a statement error, an otherwise usable connection can execute a later statement. In an explicit transaction, an unhandled ERROR leaves the transaction failed; PostgreSQL then rejects ordinary commands with 25P02 until rollback. 25P02 is a follow-on observation, not the first error. Use the ROLLBACK and SAVEPOINT references for the boundary you actually established.

If an already-existing savepoint surrounds one optional unit, use ROLLBACK TO SAVEPOINT name, then continue in the outer transaction or release the savepoint. Work before that savepoint remains. Without such a savepoint, ROLLBACK ends the failed transaction and a retry starts a new one. The accepted 25P02 case shows root 23505, subsequent 25P02, and recovery; 23505 evidence records the narrower savepoint boundary.

A PL/pgSQL EXCEPTION block is another narrow boundary. Changes made inside the block are rolled back before its handler runs, while earlier outer work remains. In the handler, SQLSTATE and SQLERRM identify the current exception; GET STACKED DIAGNOSTICS can retrieve RETURNED_SQLSTATE, message, detail, hint, context, and object fields. See error trapping, stacked diagnostics, and RAISE. Keep the handler around the smallest operation that can be classified safely; WHEN OTHERS should not discard the original fields.

Retry a complete unit only when its outcome is known

Retry is a business decision, not a property of a SQLSTATE class. For a transient serialization or deadlock error, retry the whole transaction from a fresh snapshot when the operation is safe. Do not replay only the last statement if earlier reads, writes, locks, notifications, or external calls formed one business unit. A transaction may have committed while the client timed out or lost its connection before receiving the result; completion can then be uncertain. Use an idempotency key, durable business key, or status query before repeating externally visible work.

For authorization failures, missing objects, and invalid data, first inspect and repair the permission, object, or input; then decide whether a corrected operation is safe to run. A warning that already completed the command should not trigger automatic replay. Preserve the first diagnostic and transaction state; log a later 25P02 as a consequence. Backoff and attempt limits control load, but cannot make a non-idempotent operation safe. A clear server-side timeout or cancellation is a failed operation; a lost connection before the client knows the outcome is a separate uncertain-completion case.

Correlate application and server logs

Record SQLSTATE, non-localized severity, primary message, detail, hint, object names, position/context, server version, backend PID when available, and client transaction state before formatting a human message. Add an application request or idempotency key and timestamp so the operation can be found in server logs. PID, session identifiers, and query ID are correlation aids, not replacements for protocol fields.

CSV and JSON server logs are structured but do not have the same shape as an ErrorResponse. PostgreSQL 18 documents csvlog columns including severity, SQLSTATE, message, detail, hint, context, query, source location, application name, backend type, and query ID. jsonlog is JSON and may omit null-valued fields; consumers should ignore future fields. Configure log_destination and logging_collector using the logging reference, then correlate by PID/session/request rather than assuming a CSV column or JSON key equals a protocol field.

PL/pgSQL and custom conditions

RAISE can report DEBUG, LOG, INFO, NOTICE, WARNING, or EXCEPTION; EXCEPTION normally aborts the current transaction. It can select a condition name or five-character SQLSTATE and set MESSAGE, DETAIL, HINT, SCHEMA, TABLE, COLUMN, DATATYPE, or CONSTRAINT with USING. PostgreSQL permits any five-character code made of digits and upper-case ASCII letters except 00000, including custom codes. A code ending in three zeroes is a category and can only be trapped by that category. See RAISE syntax.

A named handler matches its condition and documented aliases; a class handler is broader. WHEN OTHERS catches every error condition except QUERY_CANCELED and ASSERT_FAILURE; notice-level messages are not exceptions. A custom code raised by PL/pgSQL proves that deliberate report only, not natural emission by core, contrib, FDW, ECPG, or a driver.

What clients expose

The table pins each row to an inspected release or primary documentation. It does not claim that all six clients were runtime-tested here.

Client Inspected release/source Exposed diagnostic Boundary
libpq PostgreSQL 18.6, commit 724edf9b PQresultErrorField reads fields from an error or warning PGresult; PQstatus describes connection state. A failed startup may have no PGresult; result-field access is not a universal startup-error API. Keep connection text and server logs separate.
psycopg 3.3.5, tag peeled to commit ea542c95 Error exposes sqlstate, diag, pgconn, and pgresult; the same source builds named SQLSTATE exception classes. Connection errors may have sqlstate=None; query errors can carry result diagnostics.
PostgreSQL JDBC pgjdbc REL42.7.8, commit 9a5492d9 PSQLException.java maps ServerErrorMessage.getSQLState() to JDBC getSQLState() and retains the server message. Client and transport exceptions are also wrapped; type and server-message presence matter.
pgx/pgconn pgx v5.7.6, commit a2fca037 errors.go defines PgError.SQLState() for server errors. Connection, context, and parse errors are other Go error types or wrappers; use errors.As.
node-postgres / pg-protocol node-postgres pg@8.16.3, commit 8f8e7315 messages.ts and parser.ts parse E/N fields into database and notice messages. code, severity, detail, hint, and object fields are server diagnostics; socket errors are separate JavaScript errors.
Npgsql Npgsql v10.0.0, commit a1802184 PostgresException.cs exposes SqlState; the diagnostics guide distinguishes notices and exception types. NpgsqlException can wrap network/client failures; notices arrive through the Notice event, not as command errors.

Named exception classes, constants, and wrappers are convenience mappings. Cross-client evidence remains the protocol SQLSTATE and fields; a client-side message or null SQLSTATE does not overwrite a confirmed server-log code. Existing psycopg 3.3.5/libpq 18.6 startup records with driver-null and server 28P01/53300 demonstrate this boundary for that stack only.

7 - Coverage

Version, language, content-depth, and evidence coverage for the atlas.

Coverage is reported separately for formal release definitions, preview snapshots, paired English and Chinese pages, editorial depth, source confirmation, and runtime cases. A generated page count is not a substitute for useful reference content.

  • Formal definition snapshots: 16 displayed, 351 in the complete formal history; formal SQLSTATE union: 263.
  • Preview definition snapshots: 1; preview union: 262, including 0 preview-only values.
  • Bilingual page pairs: 263; complete English-to-Chinese revision bindings: 263.
  • Content depth: full 82, reference 181, stub 0; editorial review: reviewed 263, pending 0.
  • Selected runtime observations (unique code, summary, case): 181; passed 165, not applicable 16, failed 0, not run 0.
  • Source usage (codes with at least one status; categories may overlap): definition only 222, source path confirmed 193, observed runtime 66, explicit unknown 183; unknown scopes are record counts: history 128, natural runtime 173, emitting path 12, other 8. History or natural-runtime uncertainty is not counted as an unknown emitting path. 6 aliases across 6 codes.
  • Runtime observations are deduplicated by code, summary, and case_id; target record applicability (passed/not applicable) remains separate from each boundary assertion outcome.
Target Passed Not applicable Failed Not run
latest (18.6; server_version_num=180006) 82 6 0 0
pg10 (10.21; server_version_num=100021) 79 9 0 0
pg14 (14.24; server_version_num=140024) 1 0 0 0
pg15 (15.19; server_version_num=150019) 1 0 0 0
pg16 (16.15; server_version_num=160015) 1 0 0 0
pg17 (17.11; server_version_num=170011) 1 1 0 0

8 - Methodology

Scope, source locking, evidence states, and translation maintenance for the SQLSTATE atlas.

Scope and frozen inputs

The atlas starts from PostgreSQL release definitions and separates directory identity, source implementation, official documentation, and local runtime observation. The locked manifest contains 351 formal tags, one PostgreSQL 19 Beta 3 preview, 19 definition blobs, a 263-code union, and 44 classes. The public display is a smaller matrix of 16 formal major snapshots (9.0–18) plus the preview; it is not the complete tag history. PostgreSQL 18.6 is fixed at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7, with definitions in src/backend/utils/errcodes.txt; PostgreSQL 19 Beta 3 is a separate preview at 3638289fb57bdabec00deda98ee9624a35f5d66a.

Formal history has an 18.4→18.6 tag gap. Pre-9 collection covers 191 tags from 7.0 through 8.4.22: 7.4–8.4 have definition files, while 7.0–7.3 have candidate-path probes. Missing old paths are source gaps, not proof of absence. known_present_by is a presence boundary; exact introduction or removal is recorded only when adjacent source evidence proves both sides.

Evidence states

Each claim names the source path and fixed release, tag, or commit that supports it. definition_only establishes catalogue identity and history, not a reporting path. source_path_confirmed identifies a concrete call or implementation context. observed_runtime requires a real run record, applicable passed assertions, and the actual SQLSTATE; source scans and skipped cases cannot promote themselves to runtime coverage. unknown records an unresolved scope, not absolute absence.

Lexical source candidates are read in C context before adoption. The private call scan is bounded research input, not reader-facing proof. Core, contrib, extension, custom-function, ECPG, driver, and remote-server paths remain distinct. An ECPG program or client can reuse a PostgreSQL-defined code, and an FDW or driver can forward a remote code, without proving that server core reports that code in the same operation. Conversely, a core source path does not prove every wrapper or client exposes every field.

Official PO text can confirm a fixed commit, message domain, and placeholder boundary, but not Chinese runtime output. Locale, driver behavior, server version, and message delivery must be observed separately. Internal messages and dynamic fields retain their source conditions; translated or formatted strings are never stable protocol keys.

Runtime and recovery boundaries

Runtime observations use isolated versioned targets and preserve enough environment and structured result to identify the asserted case and version. A passed observation covers that case and version only. not_run, not_applicable, source-only, and driver-null-SQLSTATE cases remain explicit. Startup authentication/resource failures are outside a SQL transaction; a server log can carry SQLSTATE even when a startup exception has no driver SQLSTATE. In an explicit transaction, a root error and later 25P02 are separate observations; a savepoint handler, PL/pgSQL exception block, and whole-transaction retry have different scopes.

A deliberate PL/pgSQL custom code can demonstrate protocol delivery and handler matching, but is not evidence that core, contrib, FDW, ECPG, or a driver naturally reports the same code. Such observations are labeled as deliberate behavior rather than natural subsystem behavior.

Translation and maintenance

English is the source page. Each Chinese pair preserves anchors, SQLSTATE identity, facts, citations, diagnostic fields, and recovery boundaries in natural Chinese. Chinese front matter stores the English page’s deterministic UTF-8 SHA-256 over normalized {title, description, body}; changing English title, description, or prose makes the pair stale until translated and refreshed. Generated fact blocks are delimited and may be refreshed from data/errcodes; author prose and evidence are maintained separately.

A useful maintenance change updates fixed source citations, evidence state, and both language pages together. It does not infer a runtime mechanism from a renamed condition, old PO entry, generic API signature, or client wrapper. Published catalogue and evidence views are presentation layers over accepted records; they are not evidence creation.

Primary records

The public version matrix, catalogue, evidence index, and runtime case index expose accepted projections. Maintainers use reports/CATALOGUE.md, reports/SOURCE-SCAN.md, reports/RUNTIME-BOUNDARIES.md, and reports/RUNTIME.md for the underlying records; these report paths are repository locations, not public page links. The manifest lock is sources/manifest.lock.json (SHA-256 1727a275f336988ff96b4f9990a4ca253080f73fc5d316e7def165c8cf3708a8); the pre-9 lock is sources/pre9-manifest.lock.json (SHA-256 77bedf102d109972e91ff1b61841d78a38da7c7c049e428782392761a4ce7cd6).

9 - 00000 — successful_completion

PostgreSQL SQLSTATE 00000 represents successful completion and is not a normal error condition.

00000 — successful_completion

At a glance

00000 is the successful-completion SQLSTATE. PostgreSQL’s error machinery selects it by default for messages below WARNING when no more specific code is set; a successful command does not need an error message.

Field Value
SQLSTATE 00000
Condition successful_completion
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SUCCESSFUL_COMPLETION
Aliases

Meaning

The default SQLSTATE is selected by errstart from the message level; elog.c sets ERRCODE_SUCCESSFUL_COMPLETION for levels below WARNING. This is a source-level default in the error machinery, not an application error mechanism or a promise that a normal command carries an ErrorResponse.

Messages and diagnostics

Command completion is normally represented by a successful result and command tag; it does not carry an ErrorResponse SQLSTATE. In the fixed elog path, 00000 is initialized only when no more-specific code is supplied and the message level is below WARNING. Preserve a diagnostic’s actual protocol message type and severity alongside the code: 00000 is not an ERROR default and does not turn a successful result into an ErrorResponse.

Diagnosis

Check the client result status and command tag first. If a client reports 00000 alongside a failed status or an ErrorResponse, inspect the producer and client API’s status handling rather than treating it as normal successful completion or searching for an assumed error detail.

Response

Handle a successful command result as completion. For a NoticeResponse carrying 00000, retain the notice separately from the command result; investigate client status handling only when those signals conflict. Do not retry a successful command merely because this code is present.

Versions

The locked catalogue has 00000 from 9.0.23 through 18.6 and 19 Beta 3, with known_present_by 7.4. The fixed 18.6 elog.c path shows the default assignment for levels below WARNING; it is not a runtime test of every client protocol.

01000 is the warning class; 02000 is no-data, a different condition; P0002 is PL/pgSQL no_data_found.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • elog.c — fixed path, SHA-256 766d30a426ba1d9597657bd46fb890da3e37e4ae53a83d1245bf082ed9433c33.
  • Structured evidence — fixed sources, message groups, and runtime boundary.

10 - 01000 — warning

PostgreSQL uses SQLSTATE 01000 for the generic warning condition. Separate directory classification from the actual WARNING or NOTICE severity, then diagnose the emitting subsystem.

At a glance

01000 is the generic warning condition in Class 01, Warning. It is a directory classification, not a description of one particular subsystem or message. PostgreSQL’s source directory explicitly says not to use this class for failure conditions.

The five-character code must be read together with the protocol severity and the complete diagnostic. In an ErrorResponse or NoticeResponse, S is the possibly localized severity and V is the nonlocalized severity. A message can therefore arrive as WARNING, NOTICE, INFO, or another notice level while its SQLSTATE is still 01000 when the emitting code supplied that code explicitly.

For the common default path, PostgreSQL maps ereport(WARNING, ...) to 01000, levels at or above ERROR to XX000, and lower levels to 00000. An explicit errcode() can override that default. This is why the directory’s W marker is useful, but it does not by itself prove that the wire message was an actual WARNING.

The representative generic_warning_boundary probe passed on PostgreSQL 18.6 and 10.21. It uses PL/pgSQL RAISE WARNING to verify the default 01000 dispatch, receives an actual WARNING notice, and keeps the autocommit connection usable. It does not exercise the asynchronous NOTIFY, hstore, XID, or MultiXact warning paths.

Field Value
SQLSTATE 01000
Condition warning
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_WARNING
Aliases

The locked catalogue has a pre-9.0 presence observation at PostgreSQL 7.4 and records 01000 in every listed formal snapshot from 9.0.23 through 18.6 plus the 19 Beta 3 preview. The pre-9.0 source scan covers 7.4 through 8.4.22; candidate source gaps remain for 7.0 through 7.3. This is a known presence boundary, not an exact introduction version.

Meaning and trigger paths

The locked 18.6 definition is 01000 W ERRCODE_WARNING warning under Class 01. The default severity mapping is in elog.c: an ERROR or higher level starts with ERRCODE_INTERNAL_ERROR, a WARNING level starts with ERRCODE_WARNING, and lower levels start with ERRCODE_SUCCESSFUL_COMPLETION. The later error construction can replace that initial code.

Several real paths use the generic warning code:

  • The asynchronous notification queue reports NOTIFY queue is %.0f%% full. When an old listener transaction is identified, it adds a detail naming the PID and a hint to end that transaction. This is a queue pressure warning, not an array, privilege, or constraint failure.
  • Transaction ID and MultiXact wraparound protection reports that a database must be vacuumed within a remaining number of transactions or MultiXact IDs. Its hints point to a database-wide VACUUM and to old prepared transactions or stale replication slots.
  • The SPI cleanup path explicitly supplies ERRCODE_WARNING for a non-empty SPI stack and points to missing SPI_finish calls. Here the code is explicit even though the severity is also WARNING.

These source-confirmed examples show why the message, detail, hint, source context, and operation are more actionable than 01000 alone. Other Class 01 conditions, such as 01003 or 0100C, have their own SQLSTATEs and should not be collapsed into this generic code.

Messages and diagnostics

The executable representative is the registry entry generic_warning_boundary:

DO $$ BEGIN RAISE WARNING 'calibration warning'; END $$;
SELECT 1;

Both PostgreSQL 18.6 and 10.21 delivered the warning through the notice channel with SQLSTATE 01000, severity WARNING, and primary message calibration warning. The follow-up SELECT 1 succeeded and the connection was IDLE. This is a real RAISE WARNING dispatch check; it is not runtime evidence for the separate NOTIFY queue, hstore compatibility, transaction-ID, or MultiXact paths listed above.

Diagnosis

Capture C/sqlstate, S, V, M, D, and H from the driver or protocol, together with the statement, database, backend PID, and timestamp. In a client library with a notice handler, record notices as well as exceptions: a warning-level NoticeResponse can be delivered without raising a statement exception. Keep the original localized message and the nonlocalized severity when available.

Check SHOW client_min_messages and SHOW log_min_messages when a message is missing from the client or server log. Those settings control delivery and logging thresholds; they do not change the underlying cause. For a repeated warning, search logs by SQLSTATE and the stable message template, then inspect the named subsystem:

  • NOTIFY queue ... full calls for long-lived listener transactions and the PID in DETAIL.
  • XID or MultiXact vacuum warnings call for transaction age, prepared transactions, and replication slots before wraparound protection becomes an actual failure.
  • A non-empty SPI stack points toward extension or server-side SPI lifecycle handling.

Do not infer a transaction abort, a broken connection, or data corruption from 01000 alone. The representative warning left its session usable, but a later statement may fail for an independent reason, and a function or client operation may impose its own control flow.

Response

Treat the message’s subsystem and hint as the repair target. End or repair the transaction that is holding a notification queue or old transaction horizon; perform the indicated database-wide maintenance after checking replication slots and prepared transactions; or fix the extension’s SPI ownership. Preserve the original diagnostic while investigating.

An actual WARNING or lower-level notice does not by itself put an explicit transaction into the aborted state, and it normally leaves the connection able to continue. Verify the next command and transaction status instead of assuming either outcome from the code. If a subsequent ERROR occurs, handle that error’s SQLSTATE and recover with ROLLBACK or a suitable savepoint according to that error’s contract.

Raising client_min_messages or log_min_messages can reduce noise, but it does not repair the queue, transaction horizon, or SPI lifecycle. Use suppression only after the underlying signal has been understood.

Versions

The catalogue records 01000 in the locked 7.4–8.4.22 pre-9.0 formal sources and in all formal catalogue snapshots from 9.0.23 through 18.6, plus 19 Beta 3. The same-tag REL8_1_4 errcodes.sgml table already lists the older 1000 spelling with condition name warning, so this condition-name observation is confirmed by 8.1.4. Candidate source gaps remain for 7.0–7.3, so the 7.4 observation is a presence boundary rather than an exact introduction version. The 18.6 source snapshot is fixed at commit 724edf9bde9d356724ad384a2e196edc3c9f80f7.

The protocol severity fields and the client_min_messages/log_min_messages controls are documented for PostgreSQL 18. The representative source paths above are 18.6 observations; their presence does not claim that every message template is unchanged in every older release.

00000successful_completion is the default low-level completion code. 01003null_value_eliminated_in_set_function and 0100Cdynamic_result_sets_returned are more specific Class 01 conditions. XX000internal_error is the default code for an ERROR without an explicit code; it is not interchangeable with a warning. 25P02in_failed_sql_transaction describes a later command rejected because an earlier error aborted the transaction, not a consequence that should be assigned to every 01000 message.

Sources

The structured evidence for this page is recorded in the public evidence JSON. The source and documentation records use fixed PostgreSQL commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; runtime records retain the exact snippet registry and run IDs for the passed probe.

11 - 01003 — null_value_eliminated_in_set_function

PostgreSQL SQLSTATE 01003 names a warning for null values eliminated by a set function; the fixed core scan provides no emitting path.

01003 — null_value_eliminated_in_set_function

At a glance

01003 is a warning-category condition whose name describes null elimination in a set function. No resolved 18.6 core/contrib report group was found, so no PostgreSQL aggregate, message, or client severity path is confirmed here.

Field Value
SQLSTATE 01003
Condition null_value_eliminated_in_set_function
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION
Aliases

Meaning

The definition names null elimination in a set function, but the fixed source scan does not locate a PostgreSQL emitter. The producer may be a server extension, client, or another implementation.

Messages and diagnostics

No resolved 18.6 message variant was found. Preserve the original warning text, statement, aggregate or set-function context, and the server/client source that emitted it.

Diagnosis

Identify the producer before changing the query: the SQLSTATE alone does not establish which aggregate or driver behavior occurred. Check whether the producer reported a warning, notice, or only a diagnostic code, and distinguish null elimination from a query returning no rows.

Response

If the identified implementation documents a setting or expression change, apply that targeted change and verify the result. Do not suppress or retry every warning generically.

Versions

01003 is present from the locked 9.0.23 snapshot through 18.6 and 19 Beta 3, with known_present_by 7.4. This establishes definition presence, not a confirmed current server emitter.

01004 is string truncation warning; 02000 is no-data; 00000 is successful completion.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • Structured evidence — fixed sources, message groups, and runtime boundary.

12 - 01004 — string_data_right_truncation

PostgreSQL SQLSTATE 01004 names a warning-category string truncation condition; the fixed core scan provides no emitting path.

01004 — string_data_right_truncation

At a glance

01004 names right truncation reported as a warning condition. No resolved 18.6 core/contrib report group was found, so this page does not assign a particular cast, encoding path, client, or message.

Field Value
SQLSTATE 01004
Condition string_data_right_truncation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_WARNING_STRING_DATA_RIGHT_TRUNCATION
Aliases

Meaning

The definition names right truncation as a warning condition. Without a resolved call group, the accepted truncation behavior, data preservation, and producer remain unknown.

Messages and diagnostics

No resolved 18.6 message variant was found. Preserve the exact value/column context, declared and received lengths when available, encoding, producer version, and complete diagnostics.

Diagnosis

Locate the source that emitted the code and compare its length and encoding rules with the value being transferred. Distinguish a warning that preserves a truncated value from an error that rejects the statement; the SQLSTATE alone does not decide that behavior.

Response

Use the producer’s supported length or encoding adjustment and verify whether data was intentionally truncated. Do not silently retry the same input when information may already have been lost.

Versions

01004 is present from the locked 9.0.23 snapshot through 18.6 and 19 Beta 3, with known_present_by 7.4. The available evidence establishes catalogue presence, not a current core emission path.

01003 concerns null elimination; 01008 concerns zero-bit padding; 22001 is a separate error-category string truncation condition.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • Structured evidence — fixed sources, message groups, and runtime boundary.

13 - 01006 — privilege_not_revoked

PostgreSQL SQLSTATE 01006 is emitted as a WARNING when a REVOKE operation removes none or not all of the requested privileges.

01006 — privilege_not_revoked

At a glance

01006 has confirmed PostgreSQL 18.6 WARNING paths in src/backend/catalog/aclchk.c for REVOKE. It reports a partial or empty privilege change; the command can complete while sending the warning.

Field Value
SQLSTATE 01006
Condition privilege_not_revoked
Status active
Known present by 8.0.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_WARNING_PRIVILEGE_NOT_REVOKED
Aliases

Meaning

The confirmed 18.6 implementation is the ACL command path for REVOKE. It distinguishes no privilege revoked from not all privileges revoked and uses column-specific and object-specific templates.

Messages and diagnostics

The fixed 18.6 paths use these primary templates: no privileges could be revoked for column "%s" of relation "%s", no privileges could be revoked for "%s", not all privileges could be revoked for column "%s" of relation "%s", and not all privileges could be revoked for "%s". They have no detail or hint in the resolved groups.

Diagnosis

Record whether the target was a column or an object and the resolved relation/object name. In the fixed aclchk.c function, this_privileges is the requested set intersected with the effective grantor’s available grant options. The REVOKE warning is none when that mask is zero, and partial when !all_privs and the mask differs from the request; this warning branch does not inspect the grantee’s old ACL. Inspect the effective grantor, grant options, requested privileges, and then the resulting ACL separately. A WARNING is distinct from an ERROR that aborts the command.

Response

Treat the command result and warning separately. If the intended access change was not achieved, correct the target role/object or requested privilege and verify the resulting ACL; repeating REVOKE without changing the mismatch may produce the same warning.

Versions

01006 is present from the locked 9.0.23 snapshot through 18.6 and 19 Beta 3, with known_present_by 8.0.0. The fixed 18.6 warning paths are in aclchk.c; this is not a claim that every historical version used identical wording.

01007 is the corresponding privilege-not-granted warning; 42501 is an error-category privilege failure; 01000 is the warning class.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • aclchk.c — fixed path, SHA-256 9700258318959b47c42edb423418fb511dd3a008023e732f601eecf4c80868f8.
  • Structured evidence — fixed sources, message groups, and runtime boundary.

14 - 01007 — privilege_not_granted

PostgreSQL SQLSTATE 01007 is emitted as a WARNING when a GRANT operation grants none or not all of the requested privileges.

01007 — privilege_not_granted

At a glance

01007 has confirmed PostgreSQL 18.6 WARNING paths in src/backend/catalog/aclchk.c for GRANT. It reports an empty or partial grant and does not by itself mean the GRANT statement failed as an error.

Field Value
SQLSTATE 01007
Condition privilege_not_granted
Status active
Known present by 8.0.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_WARNING_PRIVILEGE_NOT_GRANTED
Aliases

Meaning

The confirmed 18.6 implementation is the ACL command path for GRANT. It distinguishes no privilege granted from not all privileges granted and uses column-specific and object-specific templates.

Messages and diagnostics

The fixed 18.6 paths use no privileges were granted for column "%s" of relation "%s", no privileges were granted for "%s", not all privileges were granted for column "%s" of relation "%s", and not all privileges were granted for "%s". The resolved groups have no detail or hint.

Diagnosis

Record whether the target was a column or object and the exact relation/object name. In the fixed aclchk.c function, this_privileges is the requested set intersected with the effective grantor’s available grant options. The GRANT warning is none when that mask is zero, and partial when !all_privs and the mask differs from the request; this warning branch does not inspect the grantee’s old ACL. Inspect the effective grantor, grant options, requested privileges, and then the resulting ACL separately. Distinguish the partial WARNING from an error-category permission failure.

Response

Check the resulting ACL and correct the role, target, privilege, or grant option identified by the operation. Reissuing unchanged GRANT is useful only after the privilege mismatch has been understood.

Versions

01007 is present from the locked 9.0.23 snapshot through 18.6 and 19 Beta 3, with known_present_by 8.0.0. The fixed 18.6 paths establish current source wording and severity, not identical historical text.

01006 is the privilege-not-revoked warning; 42501 is a permission error; 01000 is the warning class.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • aclchk.c — fixed path, SHA-256 9700258318959b47c42edb423418fb511dd3a008023e732f601eecf4c80868f8.
  • Structured evidence — fixed sources, message groups, and runtime boundary.

15 - 01008 — implicit_zero_bit_padding

PostgreSQL SQLSTATE 01008 names a warning for implicit zero-bit padding; the fixed core scan provides no emitting path.

01008 — implicit_zero_bit_padding

At a glance

01008 names a warning-category condition for implicit zero-bit padding. No resolved 18.6 core/contrib report group was found, so no specific bit-string conversion or message is confirmed.

Field Value
SQLSTATE 01008
Condition implicit_zero_bit_padding
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_WARNING_IMPLICIT_ZERO_BIT_PADDING
Aliases

Meaning

The definition names implicit zero-bit padding as a warning condition. The fixed source scan does not locate the conversion or interface that would produce it.

Messages and diagnostics

No resolved 18.6 message variant was found. Preserve the producer, source and destination bit-string types, declared lengths, and complete diagnostic.

Diagnosis

Locate the actual type-conversion or driver path and compare its padding rule with the declared bit length. Do not infer padding from an ordinary string truncation or from a query that returns no rows.

Response

Use the producer’s explicit bit length or conversion form when padding is unintended, and verify the resulting value. Do not treat a warning code as proof that a statement was rolled back.

Versions

01008 is present from the locked 9.0.23 snapshot through 18.6 and 19 Beta 3, with known_present_by 7.4. The available evidence establishes definition presence only.

01004 concerns string truncation; 01003 concerns null elimination; 22021 is an encoding error category.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • Structured evidence — fixed sources, message groups, and runtime boundary.

16 - 0100C — dynamic_result_sets_returned

PostgreSQL SQLSTATE 0100C names a warning for dynamic result sets returned; the fixed core scan provides no emitting path.

0100C — dynamic_result_sets_returned

At a glance

0100C names a warning-category dynamic-result-set condition. No resolved 18.6 core/contrib report group was found, so no server-side producer, result-set count, or message is confirmed.

Field Value
SQLSTATE 0100C
Condition dynamic_result_sets_returned
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_WARNING_DYNAMIC_RESULT_SETS_RETURNED
Aliases

Meaning

The definition names dynamic result sets returned as a warning condition. The fixed source scan does not identify the producer or the result-set protocol.

Messages and diagnostics

No resolved 18.6 message variant was found. Preserve the producing routine or interface, result-set count/order, client API, and complete warning or notice diagnostics.

Diagnosis

Identify whether the producer is a procedural or client interface that supports dynamic result sets. Do not treat multiple command results from an ordinary SQL batch as this condition without source or protocol evidence.

Response

Consume or declare the result sets according to the identified interface contract, or adjust that contract deliberately. A generic transaction retry does not address result-set handling.

Versions

0100C is present from the locked 9.0.23 snapshot through 18.6 and 19 Beta 3, with known_present_by 7.4. This is catalogue evidence, not a confirmed 18.6 core emission path.

02001 names no additional dynamic result sets; 01000 is the warning class; 00000 is successful completion.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • Structured evidence — fixed sources, message groups, and runtime boundary.

17 - 01P01 — deprecated_feature

PostgreSQL SQLSTATE 01P01 is a WARNING used to announce a deprecated feature; PostgreSQL 18.6 has a fixed MD5-password path.

01P01 — deprecated_feature

At a glance

PostgreSQL 18.6 emits 01P01 at WARNING severity when a password-setting operation produces or preserves an MD5 verifier. This is a deprecation notice attached to a command that can still proceed, not a generic failure code for every old feature.

Field Value
SQLSTATE 01P01
Condition deprecated_feature
Status active
Known present by 8.0.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_WARNING_DEPRECATED_FEATURE
Aliases

Meaning

The confirmed 18.6 implementation is the password-setting path in src/backend/libpq/crypt.c; it warns when the resulting verifier is MD5. The trigger is the final stored verifier form, such as plaintext input under password_encryption = 'md5' or an already md5... verifier supplied as input; it is not the pg_hba.conf authentication method, and an existing SCRAM verifier is not by itself this warning.

Messages and diagnostics

The fixed path reports setting an MD5-encrypted password; detail: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.; hint: Refer to the PostgreSQL documentation for details about migrating to another password type.

Diagnosis

Inspect the password-setting session’s SHOW password_encryption, whether the input is plaintext or an existing md5... verifier, and the final role verifier when permissions allow. Keep the complete warning because the detail and hint state the affected method and migration direction. Do not use the pg_hba.conf authentication method as the trigger, and do not infer that an existing SCRAM verifier caused this warning.

Response

Migrate the affected role to SCRAM by following the official Password Authentication guidance; for plaintext input, set password_encryption to scram-sha-256 before resetting the password, then verify client compatibility. Do not reuse an old MD5 verifier as the migration step. The warning itself does not call for retrying the password-setting command unchanged.

Versions

01P01 is present from the locked 9.0.23 snapshot through 18.6 and 19 Beta 3, with known_present_by 8.0.0. The fixed MD5 path and wording are confirmed for 18.6; other deprecated features or older wording require their own source evidence.

01000 is the warning class; 28P01 is an invalid-password error; 00000 is successful completion.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • crypt.c — fixed path, SHA-256 d0c7579210827dbaec466f1c064a3d1ea2f7f7bfbf8b40b2e79fb4769cb406a9.
  • Structured evidence — fixed sources, message groups, and runtime boundary.

18 - 02000 — no_data

PostgreSQL SQLSTATE 02000 is a no-data condition; PostgreSQL 18.6 has DEBUG diagnostics in amcheck, not a rule that every zero-row SELECT raises it.

02000 — no_data

At a glance

02000 has confirmed 18.6 DEBUG1/DEBUG2 paths in contrib/amcheck/verify_nbtree.c for internal index-check conditions. The three groups detailed below are each DEBUG1; they are not the same as a normal query returning zero rows and are not a generic client error.

Field Value
SQLSTATE 02000
Condition no_data
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NO_DATA
Aliases

Meaning

The confirmed 18.6 implementation is in contrib/amcheck/verify_nbtree.c, where index consistency diagnostics use ERRCODE_NO_DATA at DEBUG1 or DEBUG2. This is an internal diagnostic use, not ordinary SELECT no-row semantics. The authored evidence expands three representative groups; other source paths are outside that selected message set.

Messages and diagnostics

The selected fixed groups are:

  • DEBUG1, internal errmsg_internal: harmless fast root mismatch in index "%s", with internal detail Fast root block %u (level %u) differs from true root block %u (level %u). The source labels this condition harmless.
  • DEBUG1, internal errmsg_internal: block %u of index "%s" concurrently deleted. This branch has no detail or hint in the resolved group.
  • DEBUG1, ordinary errmsg/errdetail/errhint: index uniqueness can not be checked for index tid=(%u,%u) in index "%s", with detail It doesn't have visible heap tids and key is equal to the tid=(%u,%u)%s (points to heap tid=(%u,%u)). and hint VACUUM the table and repeat the check. The VACUUM hint belongs to this group only.

Diagnosis

If this code comes from amcheck, identify the check, index, block/TID context and server log severity. Treat a fast-root mismatch as the source labels it: a harmless diagnostic requiring context, not automatic corruption repair. For a concurrently deleted block, correlate the concurrent operation or snapshot and rerun only after the relevant activity has settled. For the uniqueness-uncheckable group, inspect the named index and follow its specific VACUUM hint before repeating the check. For application no-row handling, inspect the command result or procedural condition actually returned; PL/pgSQL NO_DATA_FOUND is P0002, not a blanket synonym for 02000.

Response

Apply the branch-specific guidance: do not turn the harmless fast-root diagnostic into an automatic repair; investigate concurrent state for a concurrent deletion; and use VACUUM before repeating the check only when the uniqueness-uncheckable group supplies that hint. Do not require maintenance for every DEBUG finding, and do not add a no-row exception or retry to ordinary SELECT code solely because the SQLSTATE class is 02.

Versions

02000 is present from the locked 9.0.23 snapshot through 18.6 and 19 Beta 3, with known_present_by 7.4. The fixed 18.6 evidence covers the amcheck DEBUG paths; other producers need separate source evidence.

P0002 is PL/pgSQL no_data_found; 02001 concerns additional dynamic result sets; 00000 is successful completion.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • verify_nbtree.c — fixed path, SHA-256 a59ae7540a990e5a70e8eb9cedbcad7c62e3e86b1ad426142c8931ee188b752d.
  • Structured evidence — fixed sources, message groups, and runtime boundary.

19 - 02001 — no_additional_dynamic_result_sets_returned

PostgreSQL SQLSTATE 02001 names a no-additional-dynamic-result-sets condition; the fixed core scan provides no emitting path.

02001 — no_additional_dynamic_result_sets_returned

At a glance

02001 is a no-data-category condition about additional dynamic result sets, not about an ordinary query returning no rows. No resolved 18.6 core/contrib report group was found.

Field Value
SQLSTATE 02001
Condition no_additional_dynamic_result_sets_returned
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED
Aliases

Meaning

The definition names exhaustion of additional dynamic result sets, but the fixed source scan does not identify an implementation path.

Messages and diagnostics

No resolved 18.6 message variant was found. Preserve the producing routine/interface, result-set position, client API, and complete diagnostics.

Diagnosis

Locate the dynamic-result-set contract that produced the code and determine whether the caller requested another result set. Do not substitute ordinary row-count checks or PL/pgSQL NO_DATA_FOUND handling.

Response

Handle the end of the result-set sequence according to the identified interface, or correct the caller’s expected count. An unchanged transaction retry does not create another result set.

Versions

02001 is present from the locked 9.0.23 snapshot through 18.6 and 19 Beta 3, with known_present_by 7.4. This is definition evidence only for the fixed 18.6 scan.

0100C concerns dynamic result sets returned; P0002 is PL/pgSQL no-data-found; 02000 is the general no-data condition.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • Structured evidence — fixed sources, message groups, and runtime boundary.

20 - 03000 — sql_statement_not_yet_complete

PostgreSQL SQLSTATE 03000 names an incomplete SQL-statement condition; the fixed core scan provides no resolved emitter.

03000 — sql_statement_not_yet_complete

At a glance

03000 is an error-category condition whose name indicates that the SQL statement is not yet complete. No resolved 18.6 core/contrib report group was found, so this page does not assign a parser, protocol, or client source.

Field Value
SQLSTATE 03000
Condition sql_statement_not_yet_complete
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SQL_STATEMENT_NOT_YET_COMPLETE
Aliases

Meaning

The definition names an incomplete SQL statement. The fixed source scan does not identify whether a parser, protocol layer, or client library emits it.

Messages and diagnostics

No resolved 18.6 message variant was found. Preserve the exact statement boundary, client API or parser, server/driver version, and complete diagnostic.

Diagnosis

Identify whether the code came from a statement-framing or protocol layer, then check how that layer decides that more input is required. Do not infer it from any syntax error, a multi-statement batch, or a client-side timeout without the actual SQLSTATE source.

Response

Complete the statement according to the identified parser or protocol contract, or correct the client framing that sent an incomplete unit. Repeating the same incomplete input cannot make it complete.

Versions

03000 is present from the locked 9.0.23 snapshot through 18.6 and 19 Beta 3, with known_present_by 7.4. The available 18.6 evidence confirms the definition but no resolved emitting path.

42601 is a syntax error; 08P01 concerns protocol violation; 00000 is successful completion.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • Structured evidence — fixed sources, message groups, and runtime boundary.

21 - 08000 — connection_exception

PostgreSQL SQLSTATE 08000: connection_exception, source-backed diagnosis and recovery guidance.

08000

At a glance

SQLSTATE 08000 is connection_exception in Class 08. Connection exception is a broad connection-management condition. In the fixed PostgreSQL paths it is used by postgres_fdw when an abort-cleanup failure makes a foreign-server connection unusable; a refused client socket is not enough to claim this code.

Field Value
SQLSTATE 08000
Condition connection_exception
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_CONNECTION_EXCEPTION
Aliases

Meaning

Connection exception is a broad connection-management condition. In the fixed PostgreSQL paths it is used by postgres_fdw when an abort-cleanup failure makes a foreign-server connection unusable; a refused client socket is not enough to claim this code.

Diagnosis

Inspect the server log and the foreign server name, backend PID, transaction outcome, and FDW cleanup path. Compare the message with 08001 (a connection could not be established) and 08006 (an established connection failed). A client library can expose a different exception or no SQLSTATE.

Response

Repair the foreign connection or its cleanup condition, finish the failed transaction according to the exact path, and retry the complete safe unit only after the remote outcome is known. Do not relabel a generic network exception as 08000.

Messages

The fixed postgres_fdw branch emits ERROR with primary connection to server "%s" cannot be used due to abort cleanup failure; the foreign server name is dynamic. This source-backed variant is narrower than a generic client socket refusal.

Representative case

This page has no selected natural SQL run. The structured evidence records a source or definition boundary; a client-side RAISE would not represent a backend mechanism.

Versions

The generated facts table records the locked catalogue snapshots and earliest observed definition. This page has no selected natural SQL run; its fixed REL_18_6/REL_10_23 source boundary must not be read as an observed runtime result or as a claim about every intermediate release.

Sources

  • src.fdw-connection.18.6contrib/postgres_fdw/connection.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 67fc002657f2c7df6d93cbf99c933cbc103907d1857ed77aedbb85099ea4dda0 (source).
  • src.fdw-connection.10.23contrib/postgres_fdw/connection.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 8a8b053e4ef599d95d0709744aa1dd5bb20047af9dc29b3f42cfba5785e525c5 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed local call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.

22 - 08001 — sqlclient_unable_to_establish_sqlconnection

PostgreSQL SQLSTATE 08001: sqlclient_unable_to_establish_sqlconnection, source-backed diagnosis and recovery guidance.

08001

At a glance

SQLSTATE 08001 is sqlclient_unable_to_establish_sqlconnection in Class 08. 08001 is the server-side SQLSTATE for a client connection that could not be established. In the selected dblink_connect path the ERROR primary is could not establish connection and the refused-port reason is dynamic DETAIL; this differs from 08003 (an absent dblink handle) and startup failures such as 28000, 28P01, and 3D000.

Field Value
SQLSTATE 08001
Condition sqlclient_unable_to_establish_sqlconnection
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION
Aliases

Meaning

The server-side dblink_connect branch emits this code after libpq cannot open the requested remote endpoint. Its fixed diagnostic is an ERROR with primary could not establish connection; the endpoint and operating-system reason are dynamic DETAIL text. The condition concerns establishing a named remote handle, so it is different from an absent handle (08003) and from startup rejection before a session exists (28000 or 3D000).

The source does not format the DETAIL itself: dblink.c passes the libpq error string through errdetail_internal("%s", msg). That distinction matters when comparing versions or clients. The 18.6 refusal observed below includes the host, port, and Connection refused text, while the 10.21 refusal uses a different libpq wording; neither wording is a fixed 08001 template.

Diagnosis

Record the target host, port, authentication parameters, and complete DETAIL. The selected 18.6/10.21 runs leave the local autocommit session IDLE after the refused attempt; a real dblink handle then connects to the runner-owned target, runs remote SELECT 1, and is explicitly disconnected. That proves local recovery and handle cleanup, not completion of any remote business transaction.

Read the failure stage before retrying. A refused TCP endpoint, DNS or TLS failure, and authentication rejection can all be returned by libpq through this dblink branch, so inspect the dynamic DETAIL rather than classifying from the code alone. If the call runs inside an explicit local transaction, the ERROR can leave that transaction unusable until ROLLBACK (or ROLLBACK TO SAVEPOINT); the autocommit IDLE result in the selected case does not imply that an explicit transaction is still usable. The dblink handle belongs to the backend that created it, so check and repair it on that same session or pool member.

Response

Correct the endpoint or connection parameters, open a new handle, and verify a harmless remote probe before sending business work. If the failed request could have crossed a remote boundary, reconcile it before retrying; 08001 alone does not justify replaying a non-idempotent operation.

In autocommit, retrying the connection attempt after correcting the endpoint is a new statement and the owner session can remain usable. In an explicit transaction, first recover the local transaction, then establish and probe a fresh handle; a savepoint is useful only when the surrounding work is deliberately designed to continue. If the remote operation may have reached the target before the local error was reported, reconcile its result before replaying it.

Observed diagnostics

The fixed dblink_connect branch emits ERROR with primary could not establish connection and passes a dynamic libpq string as DETAIL (errdetail_internal("%s", msg)). In the selected 18.6 run that value was connection to server at "127.0.0.1", port 1 failed: Connection refused followed by libpq’s hint; in the selected 10.21 run it began could not connect to server: Connection refused. Those are run-specific values, not a fixed SQLSTATE message template. Other producers may choose different text; a client-side exception without the server diagnostic is not evidence for this SQLSTATE.

The severity is fixed at ERROR for this dblink path. The selected local session stayed IDLE because the case used autocommit; do not transfer that status to a surrounding explicit transaction or to a remote transaction whose outcome was not observed.

Representative case

The SQL block creates dblink, attempts a refused runner-local port, then probes the owner session.

runner_host, runner_port, runner_db, and runner_user are runner placeholders, not literal values for a manual copy. Replace them with a reachable target and a login role that may connect to it; installing/using dblink and the remote login require the corresponding privileges. Keep the statements on the same owner backend and use the case’s autocommit boundary if you want the selected recovery observation. The trigger is a server-side dblink attempt; it does not execute work on a remote transaction.

CREATE EXTENSION IF NOT EXISTS dblink;
SELECT dblink_connect('missing_remote', 'host=127.0.0.1 port=1 dbname=postgres connect_timeout=1');
SELECT dblink_connect('working_remote', 'host=runner_host port=runner_port dbname=runner_db user=runner_user connect_timeout=5');
SELECT * FROM dblink('working_remote', 'SELECT 1') AS result(value integer);
SELECT dblink_disconnect('working_remote');
SELECT 1;

The selected 18.6 run reports SQLSTATE 08001, primary could not establish connection, and leaves the owner session IDLE after the failed operation. The controlled repair opened the named handle with OK, returned remote 1, and disconnected it with OK; the final owner probe returned 1 and IDLE. The 10.21 selected run passed the same assertions.

The downloadable case and evidence projections are 08001 case JSON and authored evidence. The runner manifest is verify/cases/08001/cases.json; the page SQL is checked against its shared registry before publication.

Versions

The generated facts table records the locked catalogue snapshots and earliest observed definition. The selected natural runtime scope is PostgreSQL 18.6 and 10.21; this does not infer behavior for every intermediate release.

Sources

  • src.dblink-connect.18.6contrib/dblink/dblink.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 e4cfaec3a0a1e5d23fded584725e0f6cf7a17321ad99e5fe046e8b7f97416f15 (source).
  • src.dblink-connect.10.23contrib/dblink/dblink.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 2d542cc722ba361bd59990aaed7fe7c0f8e147155df5e5fcd56ee03b4dd27c61 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed local call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.

23 - 08003 — connection_does_not_exist

PostgreSQL SQLSTATE 08003: connection_does_not_exist, source-backed diagnosis and recovery guidance.

08003

At a glance

SQLSTATE 08003 is connection_does_not_exist in Class 08. 08003 identifies a missing named connection handle in the current dblink backend session. It is a handle-lifecycle error, not evidence that the remote server is down (08001) or that an established socket failed (08006). The selected path first disconnects missing_remote, then proves a real handle can be opened, queried, and disconnected.

Field Value
SQLSTATE 08003
Condition connection_does_not_exist
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_CONNECTION_DOES_NOT_EXIST
Aliases

Meaning

This condition comes from the dblink handle lookup, before any remote SQL is run: the current backend has no named connection matching the request. The primary is assembled as connection "%s" not available, so the name identifies the local handle lifecycle, not remote reachability. A missing handle is therefore distinct from 08001 establishment failure and 08006 loss of an established connection.

The lookup is local to one PostgreSQL backend. A pool may give two clients the same application-level connection name while their dblink handle maps are different; creating working_remote on one backend does not repair missing_remote on another. The fixed branch has no DETAIL or HINT, so the quoted handle name and the session that issued the call are the first facts to preserve.

Diagnosis

Check the exact dblink name and the session or pool connection that owns it. The primary is dynamically assembled as connection "missing_remote" not available; in the selected autocommit run the failed lookup stays IDLE, and the repaired handle returns remote 1 before dblink_disconnect returns OK.

Separate a lookup failure from a lost socket. If the name was never opened on this backend, inspect the handle-creation path and pool checkout; if it was opened and a later remote call fails, collect that call’s diagnostics before deciding whether to disconnect and recreate it. In an explicit local transaction, this dblink ERROR follows the normal transaction-abort boundary and requires rollback or a deliberately established savepoint before unrelated statements. The selected IDLE result is specifically the autocommit case.

Response

Create the named handle on the same session that will use it, or make an absent-handle disconnect explicitly idempotent. After a real remote operation, reconcile its result before closing or recreating a handle; do not reconnect every pool member merely because one session forgot a dblink name.

For autocommit, opening, probing, and disconnecting on the same backend is a complete lifecycle. For an explicit transaction, recover the local transaction first, then recreate the handle on that same backend; a successful new handle does not tell you whether an earlier remote operation committed. Keep handle names and ownership visible in pool diagnostics so a reconnect does not silently move work to another session.

Observed diagnostics

The fixed handle-lookup branch emits ERROR with primary connection "%s" not available; the requested handle name is dynamic and there is no fixed DETAIL or HINT. A client exception without this server diagnostic does not establish 08003.

The selected primary connection "missing_remote" not available is therefore a concrete name lookup, not a server reachability test. The fixed ERROR severity can leave an explicit transaction in INERROR; it left the selected autocommit owner IDLE because no surrounding transaction was open.

Representative case

The SQL block asks dblink to disconnect a handle that was never opened, then probes the same session.

The runner_host, runner_port, runner_db, and runner_user values are runner placeholders. Replace them with a target and login role for which the owner has dblink and remote-connection privileges. The handle is session-local: run the missing lookup, open/probe, and disconnect on the same backend; the selected case uses autocommit.

CREATE EXTENSION IF NOT EXISTS dblink;
SELECT dblink_disconnect('missing_remote');
SELECT dblink_connect('working_remote', 'host=runner_host port=runner_port dbname=runner_db user=runner_user connect_timeout=5');
SELECT * FROM dblink('working_remote', 'SELECT 1') AS result(value integer);
SELECT dblink_disconnect('working_remote');
SELECT 1;

The selected 18.6 run reports SQLSTATE 08003, primary connection "missing_remote" not available, and leaves the owner session IDLE after the failed operation. The controlled repair opened the named handle with OK, returned remote 1, and disconnected it with OK; the final owner probe returned 1 and IDLE. The 10.21 selected run passed the same assertions.

The downloadable case and evidence projections are 08003 case JSON and authored evidence. The runner manifest is verify/cases/08003/cases.json; the page SQL is checked against its shared registry before publication.

Versions

The generated facts table records the locked catalogue snapshots and earliest observed definition. The selected natural runtime scope is PostgreSQL 18.6 and 10.21; this does not infer behavior for every intermediate release.

Sources

  • src.dblink-not-available.18.6contrib/dblink/dblink.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 e4cfaec3a0a1e5d23fded584725e0f6cf7a17321ad99e5fe046e8b7f97416f15 (source).
  • src.dblink-not-available.10.23contrib/dblink/dblink.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 2d542cc722ba361bd59990aaed7fe7c0f8e147155df5e5fcd56ee03b4dd27c61 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed local call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.

24 - 08004 — sqlserver_rejected_establishment_of_sqlconnection

PostgreSQL SQLSTATE 08004: sqlserver_rejected_establishment_of_sqlconnection, source-backed diagnosis and recovery guidance.

08004

At a glance

SQLSTATE 08004 is sqlserver_rejected_establishment_of_sqlconnection in Class 08. 08004 is the SQL-standard name for a server-rejected connection establishment. The fixed PostgreSQL 18.6 and 10.23 core-call scans contain no resolved PostgreSQL ereport path for this code.

Field Value
SQLSTATE 08004
Condition sqlserver_rejected_establishment_of_sqlconnection
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION
Aliases

Meaning

08004 is the SQL-standard name for a server-rejected connection establishment. The fixed PostgreSQL 18.6 and 10.23 core-call scans contain no resolved PostgreSQL ereport path for this code.

Diagnosis

Use the server ErrorResponse and authentication logs to identify the concrete condition. PostgreSQL paths in this scope use specific codes such as 28000 or 28P01; a client-side exception without a server field is not evidence for 08004.

Response

Fix the actual authentication, authorization, or endpoint problem and open a new connection. Keep 08004 as a definition/reference boundary here; no synthetic RAISE or fake rejected-login case is claimed.

Messages

This scope has no confirmed fixed primary-message template for 08004; the available definition/source records do not establish one. Do not treat a client exception without a matching server diagnostic as proof of 08004.

Representative case

This page has no selected natural SQL run. The structured evidence records a source or definition boundary; a client-side RAISE would not represent a backend mechanism.

Versions

The generated facts table records the locked catalogue snapshots and earliest observed definition. This page has no selected natural SQL run; its fixed REL_18_6/REL_10_23 source boundary must not be read as an observed runtime result or as a claim about every intermediate release.

Sources

  • src.errcodes.18.6src/backend/utils/errcodes.txt at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed local call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.

25 - 08006 — connection_failure

PostgreSQL SQLSTATE 08006: connection_failure, source-backed diagnosis and recovery guidance.

08006

At a glance

SQLSTATE 08006 is connection_failure in Class 08. 08006 names failure of an established connection. The fixed paths include postgres_fdw cancel/connection-loss handling and COPY failure handling; they do not define one universal primary or severity, and this batch intentionally has no generic socket run.

Field Value
SQLSTATE 08006
Condition connection_failure
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_CONNECTION_FAILURE
Aliases

Meaning

The fixed source paths show why this class cannot have one universal message. In postgres_fdw, a failed cancel request reports a WARNING while the established foreign connection is being handled; this warning is a diagnostic from the cancel path, not by itself proof that the client session was terminated. In the COPY paths, an open-transaction client EOF is reported as an ERROR, while the older COPY-to-stdout path reports FATAL when the output connection is lost. The severity and phase are part of the meaning: these branches must not be collapsed into “the socket broke”.

An ERROR branch can leave a still-connected session in INERROR when it occurs inside an explicit transaction, so the caller must recover with ROLLBACK or an appropriate savepoint before issuing unrelated SQL. A FATAL branch ends the backend connection; there is no session on which to send ROLLBACK. A client socket that has already reached EOF can also leave the client with no SQLSTATE at all. The evidence here confirms these source branches, but does not claim that every ordinary network disconnect emits 08006.

Branch guide

Fixed branch What it tells you First diagnostic action
postgres_fdw cancel WARNING A cancel request could not be sent or its result could not be read on an established foreign connection. Preserve the dynamic libpq text, FDW operation, and local transaction state; the warning alone does not establish that the local session was closed.
COPY client EOF ERROR The server detected EOF while a COPY-related connection still had an open transaction. The triggering client socket has already reached EOF, so it cannot receive ROLLBACK or be reused; reconnect and reconcile the COPY outcome.
COPY-to-stdout FATAL The fixed 10.23 path lost the output connection while COPY was running and used fatal severity. Discard the backend connection and reconcile any data already sent or received; no session-level rollback is possible.
Ordinary client EOF The peer disappeared before or outside one of the fixed server branches. Use the driver/socket and server log evidence; do not assign 08006 from a null client SQLSTATE alone.

Diagnosis

Correlate backend PID, operation, server log fields, and the client exception. A client-side broken socket can expose SQLSTATE null, while a server-side FDW or COPY path may emit 08006 with path-specific text. Distinguish it from 08001 (no connection was established), 08007/40003 (completion uncertainty), and a normal statement error before deciding whether work may have completed.

Check severity and lifecycle together. WARNING means the FDW cancel branch may still have a live local session; ERROR means inspect INERROR versus IDLE and recover the transaction if needed; FATAL means the backend is gone. If the client saw EOF before an ErrorResponse, the absence of a SQLSTATE is expected evidence of a lost protocol exchange, not proof of 08006.

Response

Discard a connection the pool marks broken, reconcile remote or non-idempotent work, and retry only a complete operation under an explicit idempotency policy. The fixed source paths are useful boundaries here; no artificial RAISE, timeout, or ordinary socket close is counted as observed 08006.

For an independently still-connected ERROR case, roll back the failed explicit transaction (or roll back to a savepoint intentionally established around the operation), then decide whether the complete operation can be retried. That generic transaction rule does not prove that the COPY client-EOF socket is reusable: the source branch has already detected EOF on that client connection. For FATAL or an already-lost socket, establish a fresh session and reconcile the outcome before replaying anything. Autocommit does not make a remote or COPY operation idempotent; it only changes the local transaction boundary.

Messages

The fixed branches include these distinct diagnostics:

  • WARNING could not send cancel request: %s from the postgres_fdw cancel path; the libpq error text is dynamic.
  • WARNING could not get result of cancel request: %s from the same FDW path; the returned connection error text is dynamic.
  • FATAL connection lost during COPY to stdout in the fixed 10.23 COPY path.
  • ERROR unexpected EOF on client connection with an open transaction in the fixed 18.6/10.23 COPY client-EOF paths.

The evidence keeps these as separate variants and does not turn an ordinary client-side null SQLSTATE into 08006.

The ERROR and FATAL variants have different recovery contracts even when their text mentions a connection. The COPY client-EOF ERROR branch detects that the client socket is already gone; it does not establish a reusable socket or a path for sending ROLLBACK. The FATAL variant closes the backend as part of the COPY-to-stdout path. The selected batch has no natural 08006 run, so these distinctions come from fixed source paths and the documented transaction boundary rather than a synthetic socket experiment.

Representative case

This page has no selected natural SQL run. The structured evidence records a source or definition boundary; a client-side RAISE would not represent a backend mechanism.

Versions

The generated facts table records the locked catalogue snapshots and earliest observed definition. This page has no selected natural SQL run; its fixed REL_18_6/REL_10_23 source boundary must not be read as an observed runtime result or as a claim about every intermediate release.

Sources

  • src.fdw-connection-failure.18.6contrib/postgres_fdw/connection.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 67fc002657f2c7df6d93cbf99c933cbc103907d1857ed77aedbb85099ea4dda0 (source).
  • src.copy-connection-failure.10.23src/backend/commands/copy.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 0edb032be1ce8d8c90efc28e504aa9e298a2cd26cd374c85da6da0e33ed0915c (source).
  • src.copy-client-eof.18.6src/backend/commands/copyfromparse.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 bc42754023579cd782a3cb3f144ad2c2c3d3aa46119eb7567fcdb05f2d445571 (source).
  • src.copy-client-eof.10.23src/backend/commands/copy.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 0edb032be1ce8d8c90efc28e504aa9e298a2cd26cd374c85da6da0e33ed0915c (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed local call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.

26 - 08007 — transaction_resolution_unknown

PostgreSQL SQLSTATE 08007: transaction_resolution_unknown, source-backed diagnosis and recovery guidance.

08007

At a glance

SQLSTATE 08007 is transaction_resolution_unknown in Class 08. 08007 names an unknown transaction resolution. The fixed PostgreSQL 18.6 and 10.23 call scans contain no resolved core throw site for it.

Field Value
SQLSTATE 08007
Condition transaction_resolution_unknown
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_TRANSACTION_RESOLUTION_UNKNOWN
Aliases

Meaning

08007 names an unknown transaction resolution. The fixed PostgreSQL 18.6 and 10.23 call scans contain no resolved core throw site for it.

Diagnosis

A network failure around COMMIT may leave the client unable to know whether the server committed, but that uncertainty is not automatically an 08007 ErrorResponse. Check server logs, transaction identifiers, and business reconciliation records.

Response

Treat completion as unknown until reconciled; use a request key or an application-specific result lookup before deciding whether to repeat work. Do not synthesize this condition with RAISE or a timeout.

Messages

This scope has no confirmed fixed primary-message template for 08007; the available definition/source records do not establish one. Do not treat a client exception without a matching server diagnostic as proof of 08007.

Representative case

This page has no selected natural SQL run. The structured evidence records a source or definition boundary; a client-side RAISE would not represent a backend mechanism.

Versions

The generated facts table records the locked catalogue snapshots and earliest observed definition. This page has no selected natural SQL run; its fixed REL_18_6/REL_10_23 source boundary must not be read as an observed runtime result or as a claim about every intermediate release.

Sources

  • src.errcodes.18.6src/backend/utils/errcodes.txt at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed local call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.

27 - 08P01 — protocol_violation

PostgreSQL SQLSTATE 08P01: protocol_violation, source-backed diagnosis and recovery guidance.

08P01

At a glance

SQLSTATE 08P01 is protocol_violation in Class 08. 08P01 means that a frontend/backend protocol message violated the wire contract. The selected raw TCP case completes startup and observes ReadyForQuery (Z), sends an unknown frontend byte Y in a valid frame, receives C=08P01, S=FATAL, primary invalid frontend message type 89, and reads server EOF before the client closes the socket.

Field Value
SQLSTATE 08P01
Condition protocol_violation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_PROTOCOL_VIOLATION
Aliases

Meaning

The server protocol parser accepts the startup exchange, then rejects an unknown frontend message type before it can dispatch SQL. In the selected path this is a FATAL invalid frontend message type 89, followed by server EOF; the code is therefore a synchronization boundary for the affected socket, not a SQL parser error.

The important boundary is the wire state, not the SQL text. A client can reach ReadyForQuery and still fail on its next message type, as the selected case does; a malformed startup frame or a proxy that changes message framing can fail even earlier and may leave no usable session. The selected runtime exercises the unknown-message dispatch branch; the fixed source evidence below also covers distinct Bind and message-buffer parser branches, while other transport failures must be identified from their own ErrorResponse or log evidence.

08P01 does not imply one severity or one socket outcome. In the fixed extended-query path, a Bind message with a mismatched parameter-format count or parameter count reports ERROR; the top-level loop aborts the current command and waits for a protocol-valid Sync before sending the next ReadyForQuery. The fixed message-buffer readers likewise use ERROR for missing bytes, invalid strings, and trailing data. Those recoverable protocol errors are distinct from an unknown message type, which is a FATAL boundary because the server can no longer trust message synchronization.

Diagnosis

Inspect driver/proxy protocol version, message type, frame length, startup mode, and connection ownership. The collector recorded in the selected evidence is a raw protocol ErrorResponse collector (C/S/M plus server EOF), not csvlog/jsonlog. The FATAL socket is closed by the server and is never reused; a separate runner-owned connection returns SELECT 1 and IDLE. This is a wire-protocol boundary, not SQL syntax or a client-created SQLSTATE.

Use the phase to interpret recovery:

  • Before startup completes, there is no session-level transaction and the driver may only have a connection exception. Preserve the raw server response if one was sent.
  • After startup reaches Z, an unknown frontend message is rejected by the established backend, but the selected branch is FATAL; the server then closes that socket. There is no ROLLBACK to send on it, even if the client had begun work before the protocol desynchronization.
  • On a pool or proxy path, compare the bytes sent by the owner with the protocol version and framing expected by the server. A fresh SELECT 1 on another connection proves reachability only; it does not prove that an in-flight request committed.

Use the primary text to identify the branch before choosing a recovery action. bind message has ... parameter formats and bind message supplies ... parameters point to extended-query cardinality; no data left in message, insufficient data left in message, invalid string in message, and invalid message format point to a malformed message body or boundary. These source-defined ERROR variants may be followed by Sync recovery when the driver preserves framing. invalid frontend message type ... with FATAL means the selected socket is already lost.

Response

For a FATAL response or server EOF, close and discard the affected socket, correct the protocol or proxy framing, and reconnect. For an extended-query ERROR, let the driver send protocol-valid Sync and wait for ReadyForQuery, then inspect the transaction status; Sync does not roll back a failed explicit transaction, so status E still requires ROLLBACK or an intentional savepoint recovery. If a non-idempotent request was in flight, reconcile its result before replaying it; the independent probe proves only that a fresh connection works.

Treat the selected case as a session-termination branch: after server EOF, establish a fresh connection and repeat only a reconciled, idempotent operation. If the violation happened before a session existed, fix the startup/proxy configuration first. A client-side parser exception or a socket close without the server’s C field is insufficient to label the event 08P01.

Do not improvise a byte sequence or treat the transaction as successfully committed. If the driver cannot preserve the message boundary or does not implement the Sync contract, discard the connection and reconcile the request. This source-only flow does not change the selected unknown-byte runtime, whose FATAL socket must be discarded.

Messages

The fixed parser branch emits FATAL with primary invalid frontend message type %d; the numeric byte is dynamic. The selected byte Y is reported as 89. The raw ErrorResponse, not a client exception, is the SQLSTATE authority.

Other fixed source branches emit ERROR with these primary templates:

  • bind message has %d parameter formats but %d parameters
  • bind message supplies %d parameters, but prepared statement "%s" requires %d
  • no data left in message
  • insufficient data left in message
  • invalid string in message
  • invalid message format

These Bind and message-buffer variants are source-only in this page; they are not additional runtime observations and do not all terminate the socket.

The selected wire sequence is: startup exchange → Z ReadyForQuery → valid frame with type byte Y (decimal 89) → ErrorResponse C=08P01, S=FATAL, M=invalid frontend message type 89 → server EOF. The collector captures those protocol fields and EOF directly; it is neither a csvlog/jsonlog record nor the later independent probe.

Representative case

The SQL probe is the independent connection check. The actual trigger is a runner-owned TCP handshake followed by an unknown frontend message byte; it cannot be represented by SQL alone.

SELECT 1;

The selected 18.6 server record is C=08P01, S=FATAL, primary invalid frontend message type 89; startup reached Z, the server EOF assertion was True, and the separate probe returned 1 and IDLE. The raw trigger connection is therefore closed and never reused.

The downloadable case and evidence projections are 08P01 case JSON and authored evidence. The runner manifest is verify/cases/08P01/cases.json; the page SQL is checked against its shared registry before publication.

Versions

The generated facts table records the locked catalogue snapshots and earliest observed definition. The selected natural runtime scope is PostgreSQL 18.6 and 10.21; this does not infer behavior for every intermediate release.

Sources

  • src.protocol-invalid-frontend.18.6src/backend/tcop/postgres.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061 (source).
  • src.protocol-invalid-frontend.10.23src/backend/tcop/postgres.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 badfe30749794afa80a799dcdbd142fd4e4732ac1c913002d365549ae5313497 (source).
  • src.postgres-bind.10.23src/backend/tcop/postgres.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 badfe30749794afa80a799dcdbd142fd4e4732ac1c913002d365549ae5313497 (source).
  • src.pqformat.10.23src/backend/libpq/pqformat.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 637923dbf2b9d9a0610350784f3b1d7d36a545cd8a6bd2cbe6272d9549873a91 (source).
  • src.postgres-sync.10.23src/backend/tcop/postgres.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 badfe30749794afa80a799dcdbd142fd4e4732ac1c913002d365549ae5313497 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed local call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.

28 - 09000 — triggered_action_exception

Source-backed reference for PostgreSQL SQLSTATE 09000.

09000

At a glance

SQLSTATE 09000 is an ERROR-level triggered-action condition. In the fixed PostgreSQL 18.6 scan, resolved report paths are in contrib/spi trigger functions: they validate trigger arguments, target-column types, referenced tuples, and SPI return codes. The code is therefore tied to those installed trigger functions and their table/trigger configuration; it is not a label for every trigger failure.

Field Value
SQLSTATE 09000
Condition triggered_action_exception
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_TRIGGERED_ACTION_EXCEPTION
Aliases

Meaning

The confirmed paths include autoinc.c, insert_username.c, moddatetime.c, and refint.c. Their message variants include "%s" has no attribute "%s", attribute "%s" of "%s" must be type INT4, ... TEXT, or ... TIMESTAMP or TIMESTAMPTZ. Referential-integrity support also reports tuple references non-existent key with detail Trigger "%s" found tuple referencing non-existent key in "%s"., can report SPI_execp returned %d, and can report "%s": tuple is referenced in "%s" for a restrictive action. These formats contain relation, argument, attribute, trigger, and return-code values supplied by the failing path.

Messages

The confirmed paths include autoinc.c, insert_username.c, moddatetime.c, and refint.c. Their message variants include "%s" has no attribute "%s", attribute "%s" of "%s" must be type INT4, ... TEXT, or ... TIMESTAMP or TIMESTAMPTZ. Referential-integrity support also reports tuple references non-existent key with detail Trigger "%s" found tuple referencing non-existent key in "%s"., can report SPI_execp returned %d, and can report "%s": tuple is referenced in "%s" for a restrictive action. These formats contain relation, argument, attribute, trigger, and return-code values supplied by the failing path.

Diagnosis

First identify the installed trigger function and operation phase, then compare the relation and trigger arguments with the function’s documented contract. For an attribute/type message, inspect the named column and its type; for the refint variants, inspect the trigger name, referenced relation, and the tuple or key relationship. For SPI_execp returned %d, preserve the numeric return code and inspect the SPI call that returned it. The fixed scan does not establish a single message for all 09000 reports.

Response

Correct the trigger definition, argument list, column type, referenced key, or SPI-side failure identified by the message, then rerun the triggering operation after verifying the change. Do not repair this by blindly replaying a write: a trigger may have performed work before the error, and the correct boundary depends on the surrounding transaction. If the function is supplied by an extension or local code, inspect that implementation and its version before changing application retry behavior.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The release definitions cover the published snapshots listed in the facts block; source-path status is limited to the fixed PostgreSQL 18.6 context cited below.

0A000, 2F000

Sources

autoinc.c, insert_username.c, moddatetime.c, and refint.c and its referential-restriction branch show the fixed emitters; the SPI trigger documentation describes the extension interface. See the structured evidence record for fixed source paths, scan scope, and unresolved runtime boundaries.

29 - 0A000 — feature_not_supported

PostgreSQL SQLSTATE 0A000: feature_not_supported, source-backed diagnosis and recovery guidance.

0A000

At a glance

SQLSTATE 0A000 is feature_not_supported in Class 0A. 0A000 means a recognized feature or option is unsupported in the selected context. The selected hash-index path requests id ASC, reports access method "hash" does not support ASC/DESC options, then accepts the same index without ordering. This is an access-method capability decision, not 42501 privilege denial or 42601 parser failure.

Field Value
SQLSTATE 0A000
Condition feature_not_supported
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FEATURE_NOT_SUPPORTED
Aliases

Meaning

The selected ComputeIndexAttrs path rejects ordering options for the hash access method, even though the index request itself is syntactically valid. The useful distinction is capability versus syntax: id ASC reaches the access-method check and produces the exact ERROR, while the same key without ordering is accepted.

This is a property of the chosen access method, not of the column type or the table’s contents. The command parser has already accepted the index definition; ComputeIndexAttrs then checks whether the access method can honor the requested ordering. A btree index may support the ordering option, while a hash index in this path does not. Other 0A000 producers can reject different features, so the complete primary message and command context remain essential.

Diagnosis

Read the complete primary message and identify the access method, option, command context, and server version. The failed statement leaves the autocommit session IDLE; the repaired index is valid according to pg_index.indisvalid. Other 0A000 paths can have different object and recovery behavior.

Check the object names before interpreting the result. In the case SQL, the first table and indexes are unqualified and therefore use search_path; feature_schema.hash_index in the final regclass lookup is a placeholder for the actual schema-qualified index. Confirm that those names refer to the object just created, then compare the access method and options with its documented capabilities. A privilege error (42501) or parse error (42601) calls for a different branch of diagnosis.

Response

Remove or replace only the unsupported option, or choose an access method whose contract supports it. Verify the resulting object and its semantics; do not treat every 0A000 as an upgrade request or silently discard the requested feature.

The selected autocommit ERROR can be followed by a corrected CREATE INDEX in the same session. In an explicit transaction, recover the local transaction with ROLLBACK or an intentional savepoint before issuing unrelated DDL; after recovery, recreate the index with an access method and options whose semantics meet the original requirement. Do not assume a successful replacement preserves ordering guarantees that the rejected definition requested.

Observed diagnostics

The fixed index-command branch emits ERROR with primary access method "%s" does not support ASC/DESC options; the access-method name is dynamic. This is the selected hash-index variant. Other unsupported features can use different 0A000 messages and recovery boundaries.

In the selected branch the dynamic value is hash, and the server emits no fixed DETAIL or HINT. The run observed the failed command in autocommit with session status IDLE; that status is not a general property of every 0A000 producer or of the same command inside an explicit transaction.

Representative case

The SQL block creates a table, tries the unsupported ordered hash index, creates the repaired index, and verifies pg_index.indisvalid.

feature_schema.hash_index in the final regclass lookup is a placeholder for the schema-qualified relation actually created by the first three statements. Those statements use unqualified feature_table and hash_index, so they depend on the current search_path; when running the block manually, either set that path intentionally or qualify/create the table and index in the schema named by the verification query.

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;

The selected 18.6 run reports SQLSTATE 0A000, primary access method "hash" does not support ASC/DESC options, and the asserted recovery state is IDLE before the final probe/repair. Every assertion and cleanup passed on 18.6 and 10.21.

The downloadable case and evidence projections are 0A000 case JSON and authored evidence. The runner manifest is verify/cases/0A000/cases.json; the page SQL is checked against its shared registry before publication.

Versions

The generated facts table records the locked catalogue snapshots and earliest observed definition. The selected natural runtime scope is PostgreSQL 18.6 and 10.21; this does not infer behavior for every intermediate release.

Sources

  • src.indexcmds-asc-desc.18.6src/backend/commands/indexcmds.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 0bdae365f207ab82865806c5983cac94c5c062e7a61ab7c883ccb7e2015fad36 (source).
  • src.indexcmds-asc-desc.10.23src/backend/commands/indexcmds.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 97766ba385fea1ba642e5b077fd5ce7cbb9f9faff177bcece0de2fc3e2904b23 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed local call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.

30 - 0B000 — invalid_transaction_initiation

Source-bounded reference for PostgreSQL SQLSTATE 0B000.

0B000

At a glance

SQLSTATE 0B000 names the SQL-standard Invalid Transaction Initiation class. The locked PostgreSQL 18.6 definition contains the condition, but the resolved core/contrib call scan did not identify a PostgreSQL report group for this code. Treat the class as an identity and investigation starting point, not as proof that a particular BEGIN, savepoint, or client command emits it.

Field Value
SQLSTATE 0B000
Condition invalid_transaction_initiation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_TRANSACTION_INITIATION
Aliases

Meaning

The class concerns an invalid way to initiate or establish a transaction in an implementation that uses this SQLSTATE. It is distinct from the transaction-state code actually returned by a server. PostgreSQL’s catalogue entry alone does not establish whether a current backend path, an extension, an ECPG layer, or a driver would use 0B000 for a given command.

Messages

No fixed PostgreSQL message variant was adopted for this condition because the bounded scan did not resolve a native emitting call.

Diagnosis

Record the exact SQLSTATE, message type, severity, command phase, and client library before interpreting the name. Check whether the failure occurred during startup, an explicit transaction command, a savepoint operation, or in a wrapper that forwards a remote result. If the observed code is instead 25001 or another transaction-state code, diagnose that code and its server message; do not substitute 0B000 from the class name.

Response

Follow the actual transaction-state diagnostic: end or repair the invalid transaction command, and use a new transaction only when the server and application state require it. If a wrapper or driver owns the path, inspect its fixed implementation and the remote SQLSTATE before changing transaction handling. The bounded source result provides no basis for a generic retry or a PostgreSQL-native repair recipe for 0B000.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The release definitions cover the published snapshots listed in the facts block; source-path status is limited to the fixed PostgreSQL 18.6 context cited below.

25001, 25P02

Sources

The fixed errcodes definition establishes the catalogue row; the transaction-management documentation explains PostgreSQL transaction boundaries. The locked core/contrib call scan found no resolved 0B000 report group. See the structured evidence record for fixed source paths, scan scope, and unresolved runtime boundaries.

31 - 0F000 — locator_exception

Source-bounded reference for PostgreSQL SQLSTATE 0F000.

0F000

At a glance

SQLSTATE 0F000 is the Locator Exception class. It is a category code, not a concrete locator failure message. The PostgreSQL 18.6 definition is present, but the locked core/contrib scan did not resolve a 0F000 report group. A client, embedded-SQL layer, extension, or remote implementation can still expose this standard class, so the observed producer must be identified before applying locator-specific advice.

Field Value
SQLSTATE 0F000
Condition locator_exception
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_LOCATOR_EXCEPTION
Aliases

Meaning

The trailing 000 makes 0F000 a class-level condition. It groups locator-specific members such as 0F001; it does not identify a handle, descriptor, or locator operation by itself. PostgreSQL’s definition row is useful for classification, while the fixed scan leaves the native emitting boundary unresolved.

Messages

No fixed PostgreSQL message variant was adopted for this condition because the bounded scan did not resolve a native emitting call.

Diagnosis

Preserve the member SQLSTATE if one was returned, together with the client or server component, operation, and locator/descriptor identity. Search that component’s fixed source or protocol mapping for the report path. Do not infer a locator handle from the class name, and do not treat a query that returned no rows as a locator exception.

Response

Repair the concrete locator or descriptor operation identified by the producing component, such as its lifetime, declaration, or referenced object, only when that component documents such a mechanism. If the result was forwarded from a remote system, preserve the remote error and use its owner’s recovery rules. No PostgreSQL-native retry rule is established for the category alone.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The release definitions cover the published snapshots listed in the facts block; source-path status is limited to the fixed PostgreSQL 18.6 context cited below.

0F001, 0A000

Sources

The fixed errcodes definition establishes the category and the SQLSTATE appendix describes condition classes. The locked core/contrib scan has no resolved native 0F000 report group. See the structured evidence record for fixed source paths, scan scope, and unresolved runtime boundaries.

32 - 0F001 — invalid_locator_specification

Source-bounded reference for PostgreSQL SQLSTATE 0F001.

0F001

At a glance

SQLSTATE 0F001 is the Invalid Locator Specification member of Class 0F. The locked PostgreSQL definition records the SQL-standard identity, but the resolved PostgreSQL 18.6 core/contrib scan did not find an emitting call. Do not turn the condition name into a claim about PostgreSQL large objects, cursors, FDW handles, or a particular driver API.

Field Value
SQLSTATE 0F001
Condition invalid_locator_specification
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_L_E_INVALID_SPECIFICATION
Aliases

Meaning

The member identifies an invalid locator specification when the producing implementation uses the SQLSTATE. The fixed catalogue does not identify the locator representation or the operation that would be invalid in a current PostgreSQL backend. A member code is more specific than 0F000, but still needs its producer and message.

Messages

No fixed PostgreSQL message variant was adopted for this condition because the bounded scan did not resolve a native emitting call.

Diagnosis

Capture the full diagnostic and phase: parse/prepare, execution, descriptor lookup, or a client-side call. Identify the implementation that owns the locator and inspect its fixed documentation or source for accepted locator syntax and lifetime. If PostgreSQL returns another code, keep that code; the 0F001 definition is not a fallback classification.

Response

Correct the locator specification or its owning handle according to the producing implementation, then repeat only the failed statement when it is safe and no externally visible work was completed. For a forwarded or client-owned error, repair that boundary rather than changing PostgreSQL transaction policy from the condition name alone.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The release definitions cover the published snapshots listed in the facts block; source-path status is limited to the fixed PostgreSQL 18.6 context cited below.

0F000, 0A000

Sources

The fixed errcodes definition establishes the member and macro; the SQLSTATE appendix provides the public class table. No resolved 0F001 report path was identified in the locked core/contrib scan. See the structured evidence record for fixed source paths, scan scope, and unresolved runtime boundaries.

33 - 0L000 — invalid_grantor

PostgreSQL SQLSTATE 0L000: invalid_grantor, source-backed diagnosis and recovery guidance.

0L000

At a glance

SQLSTATE 0L000 is invalid_grantor in Class 0L. The fixed aclparse path uses it as a backward-compatible warning when old ACL item text omits the /grantor suffix: it defaults the grantor to BOOTSTRAP_SUPERUSERID. This is ACL text parsing, not a bootstrap or ACL-initialization phase and not the ordinary “permission denied” or invalid GRANT-operation path.

Field Value
SQLSTATE 0L000
Condition invalid_grantor
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_GRANTOR
Aliases

Meaning

0L000 is invalid_grantor. In aclparse, an ACL item without a /grantor suffix takes a backward-compatibility fallback: the parser sets the grantor to BOOTSTRAP_SUPERUSERID and emits WARNING with SQLSTATE 0L000. This can occur while parsing ordinary ACL text; it does not identify bootstrap initialization. If a slash is present but no name follows it, the same parser instead raises 22P02 with a name must follow the "/" sign.

Diagnosis

If this warning appears, inspect the ACL text being parsed and whether it contains a grantor suffix. A missing slash and an empty name after a slash are different inputs: the first takes the 0L000 compatibility warning, while the second takes 22P02. A normal GRANT statement should be diagnosed with its concrete privilege or object error, such as 0LP01 or 42501.

Response

Preserve or rewrite serialized ACL text with an explicit valid grantor when the text is under your control, then review the resulting ACLs. Do not treat the warning as proof that bootstrap initialization failed. This page records the source path only; no natural SQL trigger is selected for 0L000.

Messages

The fixed omitted-grantor branch emits WARNING with 0L000 and primary defaulting grantor to user ID %u; the numeric user ID is dynamic. The adjacent slash-without-name branch emits ERROR with 22P02 and primary a name must follow the "/" sign. A client exception without the server diagnostic is not proof of 0L000.

Representative case

This page has no selected natural SQL run. The structured evidence records a source or definition boundary; a client-side RAISE would not represent a backend mechanism.

Versions

The generated facts table records the locked catalogue snapshots and earliest observed definition. This page has no selected natural SQL run; the fixed REL_18_6/REL_10_23 aclparse source comparison must not be read as an observed runtime result or as a claim about every intermediate release.

Sources

  • src.aclparse-grantor-fallback.18.6src/backend/utils/adt/acl.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 623f2dd01c1d393d3b224c7622dc2ec946faced444c1f5fd5e396e037903a5b0 (source). This is the aclparse omitted-grantor compatibility branch.
  • src.aclparse-grantor-fallback.10.23src/backend/utils/adt/acl.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 3cfe29c06d211130552d2aab88f61dcdd9a5287c9ab8c450d48562056b32829e (source). This is the aclparse omitted-grantor compatibility branch.
  • src.aclparse-slash-missing-name.10.23 — the same fixed acl.c blob, lines 338–344, records the separate 22P02 branch when / is followed by no name (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed local call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.

34 - 0LP01 — invalid_grant_operation

PostgreSQL SQLSTATE 0LP01: invalid_grant_operation, source-backed diagnosis and recovery guidance.

0LP01

At a glance

SQLSTATE 0LP01 is invalid_grant_operation in Class 0L. 0LP01 means that the GRANT or REVOKE operation is invalid for the object or privilege. The selected sequence case asks for INSERT, which is rejected with the dynamically assembled primary invalid privilege type INSERT for sequence; granting USAGE then succeeds.

Field Value
SQLSTATE 0LP01
Condition invalid_grant_operation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_GRANT_OPERATION
Aliases

Meaning

0LP01 means that the GRANT or REVOKE operation is invalid for the object or privilege. The selected sequence case asks for INSERT, which is rejected with the dynamically assembled primary invalid privilege type INSERT for sequence; granting USAGE then succeeds.

Diagnosis

Check object kind, privilege matrix, target role, ownership, and whether the statement is a column/default-privilege form. The selected error is an ERROR but leaves the autocommit session IDLE; the post-repair privilege check returns true.

Response

Rewrite the statement for the object’s supported privileges and verify the resulting ACL. For a sequence, choose the intended USAGE, SELECT, or UPDATE privilege; do not grant a broader privilege or retry unchanged.

Observed diagnostics

The structured evidence preserves the message template or dynamic assembly boundary. For this page, do not treat a client exception without a server diagnostic as proof of 0LP01.

Representative case

The SQL block creates a sequence, attempts the invalid INSERT privilege, grants USAGE, and verifies the effective privilege for the disposable role.

CREATE SEQUENCE grant_sequence;
GRANT INSERT ON SEQUENCE grant_sequence TO role;
GRANT USAGE ON SEQUENCE grant_sequence TO role;
SELECT has_sequence_privilege(role_literal, 'grant_sequence', 'USAGE');

The selected 18.6 run reports SQLSTATE 0LP01, primary invalid privilege type INSERT for sequence, and the asserted recovery state is IDLE before the final probe/repair. Every assertion and cleanup passed on 18.6 and 10.21.

The downloadable case and evidence projections are 0LP01 case JSON and authored evidence. The runner manifest is verify/cases/0LP01/cases.json; the page SQL is checked against its shared registry before publication.

Versions

The generated facts table records the locked catalogue snapshots and earliest observed definition. The selected natural runtime scope is PostgreSQL 18.6 and 10.21; this does not infer behavior for every intermediate release.

Sources

  • src.acl-invalid-grant-dynamic.18.6src/backend/catalog/aclchk.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 9700258318959b47c42edb423418fb511dd3a008023e732f601eecf4c80868f8 (source).
  • src.acl-invalid-grant-dynamic.10.23src/backend/catalog/aclchk.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 3a4330bd55ea8c0ec12324d7046ec31d64c920f99196235b84612d6cd1a4b26c (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed local call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.

35 - 0P000 — invalid_role_specification

PostgreSQL SQLSTATE 0P000: invalid_role_specification, source-backed diagnosis and recovery guidance.

0P000

At a glance

SQLSTATE 0P000 is invalid_role_specification in Class 0P. Under ENABLE_SSPI, the fixed Windows SSPI path uses it for server LOG branches while converting a SAM account name to a UPN; it is not a generic missing-role login result or a client ErrorResponse.

Field Value
SQLSTATE 0P000
Condition invalid_role_specification
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_ROLE_SPECIFICATION
Aliases

Meaning

0P000 is invalid_role_specification. In the fixed pg_SSPI_make_upn path, PostgreSQL builds DOMAIN\user, calls Windows TranslateName to obtain user@realm, and logs 0P000 when translation fails, the result has no @, or the realm/account would not fit the target buffers. These are server LOG branches under ENABLE_SSPI, not a client ErrorResponse and not a generic missing-role result.

Diagnosis

Confirm that the failing path is Windows SSPI and inspect the server log together with the SAM account/domain and configured realm or UPN mapping. TranslateName failures (including a result without @) log could not translate name; an oversized realm logs realm name too long, and an oversized translated account logs translated account name too long. A trust-auth disposable target cannot faithfully exercise this external identity boundary; a startup ErrorResponse may instead be 28000 or 28P01.

Response

Repair the SSPI account/realm mapping or Windows name translation configuration, then establish a new connection. Keep these server-log diagnostics separate from startup authentication responses, SQL role existence, and password failures.

Messages

The fixed SSPI source emits LOG with SQLSTATE 0P000 for these primary templates: could not translate name, realm name too long, and translated account name too long. These are server log records; a client exception or startup ErrorResponse without the matching server log is not proof of 0P000.

Representative case

This page has no selected natural SQL run. The structured evidence records a source or definition boundary; a client-side RAISE would not represent a backend mechanism.

Versions

The generated facts table records the locked catalogue snapshots and earliest observed definition. This page has no selected natural SQL run; the fixed REL_18_6/REL_10_23 SSPI source comparison must not be read as an observed runtime result or as a claim about every intermediate release.

Sources

  • src.auth-name-translation.18.6src/backend/libpq/auth.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 94252cb1e2c49b0ddb15f6596d0abf8056c84493de07cc81439da4c5b07018f1 (source).
  • src.auth-name-translation.10.23src/backend/libpq/auth.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 15418faa6d6ee1b2a4ad1e50ebc9b34c2daf4799f7062df425e33dbf777ade61 (source).
  • src.auth-sspi-upn.10.23src/backend/libpq/auth.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 15418faa6d6ee1b2a4ad1e50ebc9b34c2daf4799f7062df425e33dbf777ade61 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed local call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.

36 - 0Z000 — diagnostics_exception

Source-bounded reference for PostgreSQL SQLSTATE 0Z000.

0Z000

At a glance

SQLSTATE 0Z000 is the Diagnostics Exception category. In PostgreSQL’s fixed source, the concrete PL/pgSQL path is the member 0Z002; the category row itself is not a separate report group. Use 0Z000 to classify an observed diagnostics member, then keep the member code and its message for diagnosis.

Field Value
SQLSTATE 0Z000
Condition diagnostics_exception
Status active
Known present by 9.2.0
Locked snapshots 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DIAGNOSTICS_EXCEPTION
Aliases

Meaning

The class covers errors raised while accessing diagnostic state. The resolved member path in pl_exec.c reports 0Z002 when GET STACKED DIAGNOSTICS or parameterless RAISE is used outside an active exception handler. That member evidence explains one PostgreSQL path; it does not make every diagnostics API failure a 0Z000 emission.

Messages

No fixed PostgreSQL message variant was adopted for this condition because the bounded scan did not resolve a native emitting call.

Diagnosis

Read the member code and message first. For 0Z002, inspect whether the statement ran inside the EXCEPTION handler that owns the stacked error; ordinary function control flow and a handler’s scope matter more than the class name. If another member or producer is present, follow that component’s source and preserve its diagnostic fields.

Response

Place GET STACKED DIAGNOSTICS and parameterless RAISE inside the active PL/pgSQL exception handler they depend on. If the intended behavior is to raise a new error outside a handler, supply an explicit condition/message instead of trying to re-use stacked state. Preserve the member error and do not retry a failed routine merely because it belongs to class 0Z.

Versions

The locked catalogue places this condition at least by PostgreSQL 9.2.0. The release definitions cover the published snapshots listed in the facts block; source-path status is limited to the fixed PostgreSQL 18.6 context cited below.

0Z002, P0001

Sources

The fixed errcodes definition establishes the class. The concrete member paths are GET STACKED DIAGNOSTICS and parameterless RAISE; the PL/pgSQL error-trapping documentation defines the handler boundary. See the structured evidence record for fixed source paths, scan scope, and unresolved runtime boundaries.

37 - 0Z002 — stacked_diagnostics_accessed_without_active_handler

Source-backed reference for PostgreSQL SQLSTATE 0Z002.

0Z002

At a glance

SQLSTATE 0Z002 is emitted by PL/pgSQL when code tries to use stacked exception state without the active exception handler that owns it. PostgreSQL 18.6 has two confirmed paths: GET STACKED DIAGNOSTICS cannot be used outside an exception handler and RAISE without parameters cannot be used outside an exception handler, both reported at ERROR level.

Field Value
SQLSTATE 0Z002
Condition stacked_diagnostics_accessed_without_active_handler
Status active
Known present by 9.2.0
Locked snapshots 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER
Aliases

Meaning

The first path guards GET STACKED DIAGNOSTICS; the second guards a parameterless RAISE that would re-raise the current exception. The shared boundary is the PL/pgSQL EXCEPTION handler, not a SQL BEGIN/COMMIT transaction block. The SQLSTATE member is more specific than the 0Z000 category.

Messages

The fixed messages are GET STACKED DIAGNOSTICS cannot be used outside an exception handler and RAISE without parameters cannot be used outside an exception handler.

Diagnosis

Locate the failing PL/pgSQL statement and the nearest EXCEPTION block. GET STACKED DIAGNOSTICS reads the exception being handled, while parameterless RAISE re-raises it; neither has stacked state outside a handler. Preserve the exact message and routine context because a transaction-state error or a new explicit RAISE has a different cause.

Response

Move the diagnostic read or re-raise into the active exception handler, or use an explicit RAISE condition/message when no prior exception is being handled. Keep the handler narrow and preserve RETURNED_SQLSTATE, message, detail, and hint before leaving it. A code change, rather than a transaction retry, is the repair supported by this path.

Versions

The locked catalogue places this condition at least by PostgreSQL 9.2.0. The release definitions cover the published snapshots listed in the facts block; source-path status is limited to the fixed PostgreSQL 18.6 context cited below.

0Z000, P0001

Sources

The fixed PL/pgSQL executor source reports the GET STACKED DIAGNOSTICS variant, and the RAISE path reports the parameterless variant. The PL/pgSQL diagnostics documentation describes stacked fields. See the structured evidence record for fixed source paths, scan scope, and unresolved runtime boundaries.

38 - 10608 — invalid_argument_for_xquery

Source-backed reference for PostgreSQL SQLSTATE 10608.

10608

At a glance

SQLSTATE 10608 is an ERROR-level XQuery-class condition for an invalid argument. PostgreSQL 18.6 has resolved backend XML paths for an empty XPath expression, an empty row path filter, and an empty column path filter. The contrib/xml2 sources also reference the macro, but those references alone do not establish an additional report message.

Field Value
SQLSTATE 10608
Condition invalid_argument_for_xquery
Status active
Known present by 18.0
Locked snapshots 18.6, 19beta3
Macros ERRCODE_INVALID_ARGUMENT_FOR_XQUERY
Aliases

Meaning

The fixed backend calls report exactly empty XPath expression, row path filter must not be empty string, and column path filter must not be empty string in src/backend/utils/adt/xml.c. These are argument-validation failures in XML/XPath processing. The core report does not imply that every XPath/XSLT or extension argument error uses 10608.

Messages

The fixed backend calls report exactly empty XPath expression, row path filter must not be empty string, and column path filter must not be empty string in src/backend/utils/adt/xml.c. These are argument-validation failures in XML/XPath processing. The core report does not imply that every XPath/XSLT or extension argument error uses 10608.

Diagnosis

Identify which XML operation supplied the argument and whether the empty value was the XPath expression, row path filter, or column path filter. Preserve the exact message and input shape; for xml2 or another extension, inspect that extension’s call path separately because the macro reference is not a report group. Check server version when comparing behavior: the locked catalogue first places 10608 at PostgreSQL 18.0.

Response

Supply a non-empty expression or filter appropriate to the XML function, then validate the corrected input before repeating the statement. If the operation is extension-owned, use the extension’s documented argument rules. This is input repair; a retry without changing the empty argument cannot address the confirmed path.

Versions

The locked catalogue places this condition at least by PostgreSQL 18.0. The release definitions cover the published snapshots listed in the facts block; source-path status is limited to the fixed PostgreSQL 18.6 context cited below.

22023, 0A000

Sources

The fixed backend xml.c reports the empty XPath variant and the row/column filter checks report the other variants. contrib/xml2/xpath.c and xslt_proc.c contain macro references. See the XML functions documentation. See the structured evidence record for fixed source paths, scan scope, and unresolved runtime boundaries.

39 - 20000 — case_not_found

Source-backed reference for PostgreSQL SQLSTATE 20000.

20000

At a glance

SQLSTATE 20000 is raised by PL/pgSQL for a CASE statement that reaches no matching WHEN and has no ELSE. PostgreSQL 18.6 reports case not found with hint CASE statement is missing ELSE part. The condition is about the procedural CASE statement path; it is not the result of an ordinary query returning zero rows.

Field Value
SQLSTATE 20000
Condition case_not_found
Status active
Known present by 8.4.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_CASE_NOT_FOUND
Aliases

Meaning

The executor path is exec_stmt_case in src/pl/plpgsql/src/pl_exec.c. It evaluates the searched or simple procedural CASE statement and reports 20000 when control reaches the missing-ELSE branch. A SQL CASE expression has different semantics, so diagnose the statement form and routine source before changing a query.

Messages

The fixed message is case not found; the hint is CASE statement is missing ELSE part..

Diagnosis

Find the PL/pgSQL routine and the CASE statement named by the routine context. List the possible selector values or predicates and verify that every intended path has a WHEN; then check whether an ELSE was omitted. Do not use row-count checks or SELECT INTO STRICT diagnostics as a substitute for this condition.

Response

Add an ELSE branch that implements the intended fallback, or make the WHEN predicates exhaustive and verify the routine with representative selector values. If the missing case represents invalid business input, have the branch report the application-specific condition deliberately. After changing the routine, rerun the surrounding transaction only when its side effects were rolled back or the business operation is idempotent.

Versions

The locked catalogue places this condition at least by PostgreSQL 8.4.0. The release definitions cover the published snapshots listed in the facts block; source-path status is limited to the fixed PostgreSQL 18.6 context cited below.

02000, P0001

Sources

The fixed PL/pgSQL executor contains the message and hint. The PL/pgSQL CASE statement documentation describes the missing-ELSE behavior. See the structured evidence record for fixed source paths, scan scope, and unresolved runtime boundaries.

40 - 21000 — cardinality_violation

PostgreSQL SQLSTATE 21000: cardinality_violation, with source-backed scalar-subquery and command-level diagnostics.

21000 — cardinality_violation

At a glance

21000 means that an operation received the wrong number of rows for its cardinality contract. The common user-visible case is a scalar subquery that returns more than one row. It is different from 23505: no unique index conflict is required.

Field Value
SQLSTATE 21000
Condition cardinality_violation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_CARDINALITY_VIOLATION
Aliases

Meaning

A scalar subquery used as an expression must return at most one row. PostgreSQL reports 21000 when the executor sees a second row; zero rows produce NULL. The same condition also covers command-level cases where multiple proposed rows in ON CONFLICT DO UPDATE revisit one target row, or multiple MERGE source rows match one target row. Those paths have different messages and hints, so branch on the SQLSTATE and diagnostic fields rather than on a single English string.

Diagnosis

Capture sqlstate, message_primary, hint, and the statement context. For the scalar path, inspect the subquery without discarding rows: add a predicate that reflects the intended key, or use an aggregate when “many rows become one value” is the business rule. Do not add LIMIT 1 merely to silence the error; it can choose an arbitrary row. For ON CONFLICT, deduplicate the proposed source rows under the arbiter or unique key; for MERGE, make the source-to-target join produce at most one source row per target. Inspect the actual source rows and key mapping rather than treating this as a generic duplicate-key error.

Response

In an explicit transaction, roll back the failed statement’s transaction state before issuing the corrected statement. Then make the cardinality rule explicit and retry the complete operation. For a multi-row ON CONFLICT or MERGE, retry only after the source cardinality is deterministic; repeating the same batch will reproduce the deterministic conflict. In autocommit mode the failed scalar statement left the selected sessions IDLE, but that is a property of the boundary, not a promise for a surrounding transaction or PL/pgSQL block.

Observed diagnostics

18.6 (Homebrew) / latest:SQLSTATE 21000; primary more than one row returned by a subquery used as an expression; status_after_error IDLE. 10.21 (Debian 10.21-1.pgdg90+1) / pg10:SQLSTATE 21000; primary more than one row returned by a subquery used as an expression; status_after_error IDLE.

Representative case

The runner reads these statements from verify/cases/21000/snippets.json (SHA-256 6d820e94518ffca97f407956fdc2df104d47b14263d3117ff59dbc4409774dc2) and qualifies the temporary table names; the complete setup, assertions, and cleanup are in the case export.

-- create
CREATE TABLE source_rows(id integer PRIMARY KEY);
-- seed
INSERT INTO source_rows VALUES (1), (2);
-- trigger
SELECT (SELECT id FROM source_rows ORDER BY id) AS only_id;
-- valid
SELECT (SELECT id FROM source_rows WHERE id = 1) AS only_id;

The SQLSTATE, diagnostic, transaction-state, and repair assertions for this excerpt are produced from the shared registry; structured evidence · case export.

Authored evidence IDs: identity, scalar-subquery, dml-conflict, runtime. Selected runtime records: runtime.21000-batch1-latest-20260909.latest, runtime.21000-batch1-pg10-20260909.pg10.

Versions

The locked catalogue observes the condition by 7.4 and in every listed 9.0–18.6 formal snapshot. The fixed source evidence confirms the 18.6 scalar, ON CONFLICT, and MERGE paths; the selected runtime case covers only a scalar subquery on 18.6 and 10.21.

Compare 23505 unique violation, 23503 foreign-key violation, and 23000 integrity-constraint umbrella.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6 (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)
  • src.nodeSubplan.18.6 (SHA-256 c356a9812691f875974c1f476efa987015ba19e70a4be833a43b692f3554dc47)
  • src.nodeModifyTable.18.6 (SHA-256 0fc3cb180b3443f216142954e43d8ed5f84713d75094ce8cd2785ad8f604bd68)
  • doc.syntax.18.6 (SHA-256 449b0c500fccca068d0f8a1db2a5ebb5430eb83e33f12c6cb310a01a7437b635) · official documentation

41 - 22000 — data_exception

Source-backed reference for PostgreSQL SQLSTATE 22000.

22000

At a glance

22000 is data_exception. The fixed array_append path accepts an empty or one-dimensional array argument and reports the dimensionality requirement otherwise; other Data Exception paths belong to their own subsystem.

Field Value
SQLSTATE 22000
Condition data_exception
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DATA_EXCEPTION
Aliases

Meaning

22000 is data_exception. The fixed array_append path accepts an empty or one-dimensional array argument and reports the dimensionality requirement otherwise; other Data Exception paths belong to their own subsystem.

Messages

The confirmed guard raises ERROR with primary message argument must be empty or one-dimensional array. This fixed path has no separate DETAIL or HINT. The page is source-only; no natural runtime observation is claimed.

Diagnosis

Check the complete message, the array_append call, and the argument type before changing data. The confirmed path rejects an array argument that is neither empty nor one-dimensional.

Response

Correct the array shape or use a function contract that accepts the intended dimensions. This is an ERROR: in an explicit transaction, roll back the whole transaction or roll back to a savepoint established before the call before continuing. Re-run only after validating the argument; do not treat every Data Exception as the same repair. No runtime case was run for this page.

Versions

The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

22001, 22003, 22004

Sources

See the fixed source links and scope limits in the structured evidence record.

42 - 22001 — string_data_right_truncation

Source-backed reference for PostgreSQL SQLSTATE 22001.

22001

At a glance

22001 is string_data_right_truncation. The fixed varchar path reports the declared character width, while hstore and varbit have separate variants.

Field Value
SQLSTATE 22001
Condition string_data_right_truncation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_STRING_DATA_RIGHT_TRUNCATION
Aliases

The shared case creates varchar_limits(value varchar(3)), inserts 'too-long' to capture 22001, inserts 'ok' as the repair, and selects the stored value. Send these statements separately in autocommit: the trigger is expected to fail before the repair statement runs. The runner owns object cleanup after the case.

CREATE TABLE varchar_limits (value varchar(3));
INSERT INTO varchar_limits VALUES ('too-long');
INSERT INTO varchar_limits VALUES ('ok');
SELECT value FROM varchar_limits;

Calibration observed character varying(3) rejecting an overlong value with value too long for type character varying(3); the corrected value ok succeeded and both runner autocommit sessions returned to IDLE.

Messages

The fixed character and varchar guards raise ERROR with primary templates value too long for type character(%d) and value too long for type character varying(%d). The hstore and varbit paths use their own primary templates (string too long for hstore key, string too long for hstore value, and bit string too long for type bit varying(%d)). These source groups provide no separate DETAIL or HINT. The selected runtime observed only the varchar template shown above.

Meaning

22001 is raised when a value cannot satisfy a string type’s length contract. PostgreSQL measures character(n) and character varying(n) in characters, so a message such as value too long for type character(%d) points to the typmod shown in the response. The fixed varchar.c path is the server-side check; hstore keys/values and bit strings have separate source paths and messages.

The boundary also depends on how the value reaches the type. The varchar() and bpchar() functions receive an isExplicit flag: an assignment/input conversion rejects excess non-space characters, while an explicit cast to the bounded type can truncate according to PostgreSQL’s character-type rules; excess trailing spaces are treated differently from non-space characters. Make that choice explicit before changing storage or input validation.

Diagnosis

Capture schema_name, table_name, column_name, datatype_name, routine, and the full primary message. Confirm the target type and typmod from the catalog, then measure the actual value in characters rather than bytes. Check whether the value was inserted/assigned, explicitly cast, or passed through an hstore/bit path; those paths do not share identical truncation behavior.

For the common varchar case, compare the non-space suffix with the declared width. A value that only exceeds the width through trailing spaces can follow the character-type truncation rule, while meaningful non-space data should be treated as a rejected contract. The fixed source message is a type-width diagnosis, not a general encoding or network failure.

Response

Choose the repair that preserves the data contract: validate and reject overlong input, deliberately widen the column/type, or explicitly cast only when truncation is an accepted business rule. Record the original value and target typmod before truncating; silently cutting identifiers, keys, or audit text can create a different row than the caller intended. The frozen case used autocommit, so the failed statement left the session IDLE; inside an explicit transaction, roll back the transaction or use ROLLBACK TO SAVEPOINT for a savepoint created before the statement before retrying the corrected value. After changing the input or schema, re-run the conversion and verify the stored character length.

Versions

The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

22003 for numeric/range overflow, 22007 for datetime format errors, and 22004 for a separate NULL contract.

Sources

The fixed character(n) check is varchar.c#L300-L313, and the character varying(n) check is varchar.c#L633-L640. PostgreSQL 18’s character types document character-count limits, trailing-space behavior, and explicit casts. The structured evidence record pins the source SHA and keeps hstore/varbit variants separate.

43 - 22002 — null_value_no_indicator_parameter

Source-backed reference for PostgreSQL SQLSTATE 22002.

22002

At a glance

22002 is null_value_no_indicator_parameter, an ECPG-oriented condition. The fixed 18.6 call archive has no resolved native report group in this scan.

Field Value
SQLSTATE 22002
Condition null_value_no_indicator_parameter
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NULL_VALUE_NO_INDICATOR_PARAMETER
Aliases

Meaning

22002 is null_value_no_indicator_parameter, an ECPG-oriented condition. The fixed 18.6 call archive has no resolved native report group in this scan.

Messages

No fixed PostgreSQL primary, DETAIL, HINT, or severity was confirmed in the bounded call scan. runtime_verification is not_run; a client or ECPG implementation that reports this code must supply its own exact diagnostic context.

Diagnosis

Locate the ECPG/preprocessor or client path that selected 22002 and inspect its indicator-variable contract; do not infer it from a server column NULL alone.

Response

Supply the required indicator handling in the actual ECPG interface or correct the client binding. Keep this code separate from ordinary column NOT NULL and PL/pgSQL NULL conditions. No server transaction-recovery rule is inferred from this source-only page.

Versions

The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

22000, 22001, 22003, 22004

Sources

See the fixed source links and scope limits in the structured evidence record.

44 - 22003 — numeric_value_out_of_range

Source-backed reference for PostgreSQL SQLSTATE 22003.

22003

At a glance

22003 is numeric_value_out_of_range. Fixed paths cover integer conversion, numeric overflow, and subsystem-specific range checks; the page centers on numeric conversion and preserves those boundaries.

Field Value
SQLSTATE 22003
Condition numeric_value_out_of_range
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE
Aliases

The shared case casts 2147483648 to integer to capture the range error, then casts 2147483647 as the representable repair. Send the two SELECT statements separately; the first is expected to fail before the repair expression runs. The runner controls the session and cleanup; no schema setup is required.

SELECT '2147483648'::integer;
SELECT '2147483647'::integer;

Calibration observed integer input 2147483648 rejected with value "2147483648" is out of range for type integer; 2147483647 succeeded. The PostgreSQL 18.6 path used pg_strtoint32_safe, while the REL_10_23 source path used pg_atoi; both runner autocommit sessions returned to IDLE.

Messages

The fixed integer input guard raises ERROR with primary value "%s" is out of range for type %s. Other confirmed source paths use value overflows numeric format (numeric factorial) and integer out of range (width_bucket’s result conversion). These groups have no separate DETAIL or HINT in the cited source. The selected runtime observed only the integer-input template.

Meaning

22003 covers a numeric or range contract that the selected operation cannot represent. The fixed catalogue member is used by integer conversion, exact-numeric overflow, and subsystem checks; representative messages include integer out of range and value overflows numeric format. Other source paths may use the same SQLSTATE with a different message, so the SQLSTATE alone is not a type diagnosis.

Diagnosis

Read the primary message and source object first. The observed integer case proves only an int4 input-conversion boundary; it does not characterize every numeric expression. For an integer conversion, identify the source and target integer widths and whether the failure occurred during input, assignment, cast, arithmetic, or an extension function. For numeric, distinguish declared precision/scale from arithmetic overflow and preserve the operands and rounding mode. A value can be syntactically valid and still be outside the target range.

Response

Validate the range before the conversion and choose a representation that matches the business contract: reject the value, rescale it explicitly, or use a wider supported type. For arithmetic, inspect intermediate results rather than only the final column. For a subsystem-specific message, repair the named subsystem. The frozen case used autocommit, so the failed cast left the session IDLE; inside an explicit transaction, roll back the transaction or roll back to a pre-existing savepoint before retrying the corrected expression. Do not blanket-retry a deterministic range failure or silently clamp money, identifiers, or counters.

Versions

The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

22001 for string length, 22007 for datetime format, and 22008 for datetime field/range overflow.

Sources

Representative fixed paths include integer input in numutils.c#L603-L612, numeric overflow in numeric.c#L3765-L3769, and the width_bucket result conversion in numeric.c#L2042-L2046. The structured evidence record records the fixed message families and source hashes.

45 - 22004 — null_value_not_allowed

Source-backed reference for PostgreSQL SQLSTATE 22004.

22004

At a glance

22004 is null_value_not_allowed. The fixed table-function path rejects a null namespace URI; many other extensions and core functions use the same condition for different null contracts.

Field Value
SQLSTATE 22004
Condition null_value_not_allowed
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NULL_VALUE_NOT_ALLOWED
Aliases

The shared case supplies a NULL XMLTABLE namespace URI, then repeats the table-function call with URI u and a matching XML row. Send the two SELECT statements separately; the first is expected to fail before the repaired call runs. The runner controls the session and cleanup.

SELECT * FROM XMLTABLE(XMLNAMESPACES (NULL AS p), '/p:row' PASSING '<p:row xmlns:p="u"/>' COLUMNS x text PATH 'p:x');
SELECT count(*) FROM XMLTABLE(XMLNAMESPACES ('u' AS p), '/p:row' PASSING '<p:row xmlns:p="u"><p:x>ok</p:x></p:row>' COLUMNS x text PATH 'p:x');

Calibration observed the table-function namespace URI path: a NULL namespace reported namespace URI must not be null; a valid URI returned one XMLTABLE row, and both runner autocommit sessions returned to IDLE.

Messages

The namespace guard raises ERROR with primary namespace URI must not be null, with no separate DETAIL or HINT. The table-function executor module also has distinct ERROR guards for a null row-filter expression and a null column-filter expression (with a column-name DETAIL). Its output-column guard is narrower: after the XMLTABLE output column is marked NOT NULL, the value is obtained and any DEFAULT expression is applied; only when it is still NULL does it raise null is not allowed in column "%s". That output-column condition is distinct from an ordinary NULL result or a separate 23502 constraint error. The selected runtime observed only the namespace message.

Meaning

22004 is a NULL contract failure. In the fixed nodeTableFuncscan.c path, the rejected value is a namespace URI used by a table function: namespace URI must not be null. The same condition name can be selected by other functions, so a NULL function argument, a NULL result from a STRICT function, and a table column declared NOT NULL are different investigations. A normal SQL NULL result is not evidence of 22004; use the actual SQLSTATE and diagnostic fields.

Diagnosis

Use the full message, routine, context, and object fields to identify which parameter or descriptor was NULL. For the confirmed table-function path, inspect the namespace URI expression and the table-function XML/row description that supplied it. A plain NULL input or a STRICT function returning NULL does not by itself indicate this condition. If the response instead names a column constraint, use its actual SQLSTATE and constraint fields; do not relabel a column NOT NULL violation as 22004.

Response

Fix the function parameter or descriptor that the message identifies, or change the table-function definition so the namespace URI contract is satisfied. Preserve intentional SQL NULLs where the API permits them; replacing every NULL with an empty string can change XML or query semantics. The frozen case used autocommit, so the failed statement left the session IDLE; inside an explicit transaction, roll back the transaction or roll back to a pre-existing savepoint before continuing. Validate the corrected call before repeating a write.

Versions

The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

22000 for other Data Exception paths, 22002 for the ECPG indicator-variable condition, and 23502 when the actual response is a not-null-constraint violation.

Sources

The confirmed table-function check is nodeTableFuncscan.c#L368-L370; the neighboring filter/output guards are in nodeTableFuncscan.c#L380-L419 and nodeTableFuncscan.c#L494-L508. The structured evidence record pins these paths and keeps other NULL contracts conditional.

46 - 22005 — error_in_assignment

Source-backed reference for PostgreSQL SQLSTATE 22005.

22005

At a glance

22005 is error_in_assignment. The fixed PL/pgSQL path reports assignment to a variable declared CONSTANT; ECPG and other assignment layers may have separate boundaries.

Field Value
SQLSTATE 22005
Condition error_in_assignment
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_ERROR_IN_ASSIGNMENT
Aliases

Meaning

22005 is error_in_assignment. The fixed PL/pgSQL path reports assignment to a variable declared CONSTANT; ECPG and other assignment layers may have separate boundaries.

exec_check_assignable applies this guard to PL/pgSQL variables, promise variables, and records whose isconst flag is set. Record fields delegate the check to their parent record, while row datums are assignable; this is why the routine context and the named datum matter.

Messages

The confirmed branch raises ERROR with primary variable "%s" is declared CONSTANT. It has no fixed DETAIL or HINT. This page is source-only; no natural runtime observation is claimed.

Diagnosis

Read the named variable and routine context. The confirmed path is a PL/pgSQL assignment contract, not a general type conversion or target-column error.

Response

Remove the assignment, change the declaration when mutability is intended, or assign to a separate variable. Correct the routine before rerunning its business operation. An uncaught ERROR in an explicit transaction leaves that transaction failed; roll it back or use a savepoint established before the call. A PL/pgSQL EXCEPTION block can contain the failure in its subtransaction when the routine is deliberately written to handle it; this page has no runtime case proving a particular handler.

Versions

The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

22000, 22001, 22003, 22004

Sources

See the fixed source links and scope limits in the structured evidence record.

47 - 22007 — invalid_datetime_format

Source-backed reference for PostgreSQL SQLSTATE 22007.

22007

At a glance

22007 is invalid_datetime_format. The fixed interval-formatting path reports an invalid format specification and explains that intervals are not tied to specific calendar dates.

Field Value
SQLSTATE 22007
Condition invalid_datetime_format
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_DATETIME_FORMAT
Aliases

The shared case formats interval '1 day' with the invalid ID mask, then uses DD as the repaired interval format. Send the two SELECT statements separately; the first is expected to fail before the repaired format runs. This verifies the interval-formatting path only; the runner owns session cleanup.

SELECT to_char(interval '1 day', 'ID');
SELECT to_char(interval '1 day', 'DD');

Calibration observed the interval DCH formatting path: an invalid format reported invalid format specification for an interval value with hint Intervals are not tied to specific calendar dates.; a valid DD format returned 01, and both runner autocommit sessions returned to IDLE. This run covers interval formatting only; general date parsing and DateStyle remain source/document scope.

Messages

The INVALID_FOR_INTERVAL guard raises ERROR with primary invalid format specification for an interval value and HINT Intervals are not tied to specific calendar dates. The cited branch has no separate DETAIL. In the fixed datetime input parser, the DTERR_BAD_FORMAT/default branch maps 22007 to the common primary template invalid input syntax for type %s: "%s"; the adjacent field-overflow and month/day-overflow branches use 22008 instead, with the latter adding HINT Perhaps you need a different "DateStyle" setting. Other datetime-format parsers can use 22007 with different primary/detail/hint variants, so retain the full diagnostic.

Meaning

22007 means the datetime input or format specification is invalid for the selected conversion. The fixed 18.6 interval-formatting path reports invalid format specification for an interval value and explains that intervals are not tied to specific calendar dates. In this DCH path, ID is a calendar-specific day-of-week token rejected for an interval, while DD is accepted. Fixed date input parsing routes text through ParseDateTime/DecodeDateTime and DateTimeParseError: the bad-format/default branch uses invalid input syntax for type %s: "%s"; field overflow belongs to 22008, whose month/day ambiguity branch can suggest a different DateStyle. The 18.6 documentation says DateStyle selects the interpretation order for ambiguous numeric input. DateTimeParseError can fill an ErrorSaveContext instead of throwing, so soft-validation callers differ from normal cast/input calls that propagate ERROR.

Diagnosis

Record the original text, target type, DateStyle, TimeZone, format mask, and whether the operation was a cast, input function, to_date/to_timestamp, or interval formatting. Test the same text under the deployed session settings before changing the data. Distinguish an invalid token or separator from a field such as month/day that parsed but is out of range; those paths may produce 22008 instead.

Response

Make the input unambiguous—prefer an explicit format or ISO form where appropriate—and set session parsing options deliberately at the application boundary. For interval formatting, use a mask supported for intervals rather than a calendar-date mask. The frozen case used autocommit, so the failed formatting call left the session IDLE; inside an explicit transaction, roll back the transaction or roll back to a pre-existing savepoint before continuing. Reject or repair invalid text before writing; do not silently reinterpret it under a different DateStyle.

Versions

The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

22008 for datetime field/range overflow, 22009 for timezone displacement, and 22003 for numeric range failures.

Sources

The fixed interval-formatting path is formatting.c#L555-L558. Fixed date input dispatch is in date.c#L110-L178, and the common parser error mapping is in datetime.c#L4195-L4266. PostgreSQL 18’s date/time input documentation documents DateStyle and ambiguous date text. The structured evidence record pins the fixed sources, message, and hint.

48 - 22008 — datetime_field_overflow

Source-backed reference for PostgreSQL SQLSTATE 22008.

22008

At a glance

22008 is datetime_field_overflow. Fixed date.c paths report out-of-range date values, date fields, and time fields; the exact message identifies which conversion or operation failed.

Field Value
SQLSTATE 22008
Condition datetime_field_overflow
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DATETIME_FIELD_OVERFLOW, ERRCODE_DATETIME_VALUE_OUT_OF_RANGE
Aliases ERRCODE_DATETIME_VALUE_OUT_OF_RANGE

Meaning

22008 is datetime_field_overflow. The confirmed date.c paths cover date input and binary receive, make_date field/range validation, and make_time field validation. Date-to-timestamp and arithmetic paths can have their own range messages; inspect the complete primary before choosing a repair.

Messages

The confirmed guards raise ERROR with primary templates date out of range, date out of range: %d-%02d-%02d, and time field value out of range: %d:%02d:%02g. These cited groups have no separate DETAIL or HINT. This page is source-only; no natural runtime observation is claimed.

Diagnosis

Preserve the field values, target datetime type, and whether the operation parsed a date or performed arithmetic. Do not confuse this with 22007 format syntax.

Response

Correct the date fields or choose a representable finite range. If the complete message names a timestamp conversion or infinity arithmetic, change that operation explicitly. This is an ERROR: in an explicit transaction, roll back the transaction or roll back to a savepoint established before the failing conversion before continuing. Re-run only after the input or operation is fixed. No runtime case was run for this page.

Versions

The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

22000, 22001, 22003, 22004

Sources

See the fixed source links and scope limits in the structured evidence record.

49 - 22009 — invalid_time_zone_displacement_value

Source-backed reference for PostgreSQL SQLSTATE 22009.

22009

At a glance

22009 is invalid_time_zone_displacement_value. The fixed timetz_recv binary-input path rejects a GMT displacement outside the supported range.

Field Value
SQLSTATE 22009
Condition invalid_time_zone_displacement_value
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE
Aliases

Meaning

22009 is invalid_time_zone_displacement_value. The confirmed timetz_recv guard checks the received GMT displacement against PostgreSQL’s supported limit; this is a binary input contract, not a generic session TimeZone setting error.

Messages

The confirmed guard raises ERROR with primary time zone displacement out of range. It has no fixed DETAIL or HINT in this source path. This page is source-only; no natural runtime observation is claimed.

Diagnosis

Inspect the supplied zone offset and the binary timetz receiver or protocol decoder that delivered it. Keep an invalid displacement distinct from a generic datetime field overflow or a session TimeZone setting.

Response

Validate and replace the offset in the client or binary input that supplied it; use a named zone only when the input contract supports that representation. This is an ERROR: in an explicit transaction, roll back the transaction or roll back to a savepoint established before the failing conversion before continuing. Validate at the client boundary before repeating the conversion. No runtime case was run for this page.

Versions

The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

22000, 22001, 22003, 22004

Sources

See the fixed source links and scope limits in the structured evidence record.

50 - 2200B — escape_character_conflict

Source-backed reference for PostgreSQL SQLSTATE 2200B.

2200B

At a glance

2200B is escape_character_conflict. The fixed 18.6 call archive has no resolved native report group in this scan.

Field Value
SQLSTATE 2200B
Condition escape_character_conflict
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_ESCAPE_CHARACTER_CONFLICT
Aliases

Meaning

2200B is escape_character_conflict. The fixed 18.6 call archive has no resolved native report group in this scan.

Messages

No fixed PostgreSQL primary, DETAIL, HINT, or severity was confirmed in the bounded source scan. This page is definition/scan-boundary reference only; runtime_verification remains not_run.

Diagnosis

Locate the pattern/escape parser or extension that selected the code and inspect its escape-character rules. A no-path scan is an evidence boundary, not an absence claim.

Response

Correct the actual pattern and escape configuration according to the deployed parser after locating the component that selected the code. Do not manufacture this SQLSTATE with a generic RAISE to stand in for parser behavior, and do not infer transaction recovery from this source-only boundary.

Versions

The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

22000, 22001, 22003, 22004

Sources

See the fixed source links and scope limits in the structured evidence record.

51 - 2200C — invalid_use_of_escape_character

Source-backed reference for PostgreSQL SQLSTATE 2200C.

2200C

At a glance

The SQL SIMILAR TO pattern translator rejected its escape-double-quote structure before matching. PostgreSQL 18.6 has a concrete regexp.c path that raises SQL regular expression may not contain more than two escape-double-quote separators; this is about the SQL-to-POSIX translation syntax, not generic POSIX backslash escaping.

Field Value
SQLSTATE 2200C
Condition invalid_use_of_escape_character
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_USE_OF_ESCAPE_CHARACTER
Aliases

Meaning

This condition belongs to the data-exception family for an escape form rejected while PostgreSQL translates a SQL SIMILAR TO pattern to its POSIX regular-expression form. In similar_escape_internal, an escaped double quote outside a bracket expression separates the three SQL SUBSTRING parts; the third separator is rejected. The same helper is used by the SQL SIMILAR TO translation path, where those separators do not change ordinary match behavior.

Messages

The confirmed guard raises ERROR with primary SQL regular expression may not contain more than two escape-double-quote separators; this branch has no separate DETAIL or HINT. An invalid ESCAPE string is a different SQLSTATE path, so preserve the actual message and code.

Diagnosis

This is a parser/input problem, so inspect the SQL string layer, the SIMILAR TO pattern, and its ESCAPE character separately. Count escaped double-quote separators outside bracket expressions and confirm whether the operation is SIMILAR TO or SUBSTRING ... SIMILAR; do not diagnose every backslash in a POSIX regexp as 2200C.

Response

Correct the SQL pattern or its ESCAPE representation according to the intended SIMILAR TO/SUBSTRING semantics, then re-run after checking the separator count. Do not add or remove POSIX backslashes indiscriminately.

When this branch raises ERROR, an explicit transaction must first be recovered with ROLLBACK or ROLLBACK TO SAVEPOINT for a savepoint established before the statement; in autocommit, retry only the corrected action after the failed statement completes. See the transaction and retry guide for this boundary rule.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6.

2200D, 22000

Sources

Fixed source: src/backend/utils/adt/regexp.c#L758-951. The structured evidence record retains the definition, message, and scope boundaries. This is PostgreSQL’s SQL SIMILAR TO translation helper; no natural runtime was run for this page. A different escape failure may use another SQLSTATE, so choose by the actual code and message.

52 - 2200D — invalid_escape_octet

Source-backed reference for PostgreSQL SQLSTATE 2200D.

2200D

At a glance

The catalogue condition covers an invalid escape octet. The fixed scan did not resolve a PostgreSQL 18.6 emitting function for this entry, so the condition is useful as a classification boundary rather than proof of one native parser call.

Field Value
SQLSTATE 2200D
Condition invalid_escape_octet
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_ESCAPE_OCTET
Aliases

Meaning

This condition classifies an escape octet that the consuming parser cannot accept; its owner must be identified from the real message.

Diagnosis

Start with the complete server message and the input field named by the surrounding operation. Check byte encoding and the layer that interpreted the escape (SQL literal, regular-expression or extension parser). Do not replace this code with 2200C solely because both names mention escapes; the server’s actual SQLSTATE and message decide the path. No fixed native emitter was confirmed in this scan.

Response

Preserve the complete diagnostic, identify the parser or wrapper that supplied the invalid octet, and correct the input or encoding at that boundary before retrying.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6.

2200C

Sources

The fixed definition is confirmed; this bounded scan did not resolve a native emitting function to cite. The structured evidence record retains the definition, message, and scope boundaries. The definition is fixed in errcodes.txt, but implementation ownership and exact message variants remain unknown here. Locate the wrapper or extension named by the real message before changing data or retrying.

53 - 2200F — zero_length_character_string

Source-backed reference for PostgreSQL SQLSTATE 2200F.

2200F

At a glance

The condition identifies an operation that rejects an empty character string. In the fixed fuzzystrmatch path, metaphone returns empty text immediately for empty input; only after that early return does it read reqlen, and a non-positive requested output length raises output cannot be empty string. A separate core array_to_tsvector path rejects an empty lexeme, so the message and function matter.

Field Value
SQLSTATE 2200F
Condition zero_length_character_string
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_ZERO_LENGTH_CHARACTER_STRING
Aliases

Meaning

This condition is reserved for an operation whose contract does not permit an empty character string. The fixed paths have different guards: metaphone(text, reqlen) first returns empty text when its input text is empty; after that early return, a non-positive reqlen on non-empty input raises 2200F. array_to_tsvector(text[]) independently rejects an element whose length is zero. Neither path proves that every empty SQL string is a 2200F error.

Messages

The metaphone guard raises ERROR with primary output cannot be empty string. The array_to_tsvector lexeme guard raises ERROR with primary lexeme array may not contain empty strings. These paths have no separate DETAIL or HINT in the cited branches.

Diagnosis

If the message names metaphone, inspect the supplied text and requested output length: empty input returns an empty result before reqlen is checked, while a non-positive length on non-empty input triggers 2200F. If the message names array_to_tsvector, inspect every lexeme for an empty string and distinguish NULL lexemes, which use 22004. For a different message, identify the named subsystem first; do not pad arbitrary output merely to silence the condition.

Response

Handle the named function’s input requirement explicitly: choose a positive metaphone output length for non-empty input, or remove/repair empty lexemes before array_to_tsvector. Preserve intended empty input semantics where the function permits them; do not pad data merely to suppress the code.

When this branch raises ERROR, an explicit transaction must first be recovered with ROLLBACK or ROLLBACK TO SAVEPOINT for a savepoint established before the statement; in autocommit, retry only the corrected action after the failed statement completes. See the transaction and retry guide for this boundary rule.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6.

22001, 22000

Sources

Fixed metaphone source: fuzzystrmatch.c#L253-287; the separate core lexeme guard is tsvector_op.c#L741-777. The structured evidence record retains both messages and scope boundaries. No natural runtime was run; SQLSTATE selection and message text remain the deciding evidence.

54 - 2200G — most_specific_type_mismatch

Source-backed reference for PostgreSQL SQLSTATE 2200G.

2200G

At a glance

This condition names a most-specific-type mismatch during type resolution. No fixed PostgreSQL 18.6 emitting path was resolved in the bounded call scan, so the page stays conditional and does not turn a generic cast or operator error into 2200G.

Field Value
SQLSTATE 2200G
Condition most_specific_type_mismatch
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_MOST_SPECIFIC_TYPE_MISMATCH
Aliases

Meaning

This condition concerns type selection when the most specific common type cannot be chosen for the operation.

Diagnosis

Use the full message and the expression or routine signature involved. Inspect unknown literals, polymorphic arguments, overloaded operators, and explicit casts at the point named by the diagnostic. If the server reports 42804 or 42846 instead, follow that actual code; a type mismatch by itself is not evidence for 2200G.

Response

Correct the named expression’s type resolution by making the intended type explicit or fixing the routine signature, after confirming the server’s actual SQLSTATE.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6.

22003, 42804

Sources

The fixed definition is confirmed; this bounded scan did not resolve a native emitting function to cite. The structured evidence record retains the definition, message, and scope boundaries. The catalogue definition is confirmed; an emitting function and message template were not resolved in this scan. A wrapper or extension may own a use, so preserve its actual context when investigating.

55 - 2200H — sequence_generator_limit_exceeded

Source-backed reference for PostgreSQL SQLSTATE 2200H.

2200H

At a glance

A sequence allocation reached its configured limit while trying to obtain the next value. PostgreSQL 18.6’s sequence.c path reports source templates for both maximum and minimum limits. The endpoint value itself can be legal, and the numeric value uses the C PRId64 format macro, so the source spelling is nextval: reached maximum value of sequence "%s" (%" PRId64 ") (and the corresponding minimum form), not a literal (%s) placeholder. The limit is a sequence property, not a generic integer overflow.

Field Value
SQLSTATE 2200H
Condition sequence_generator_limit_exceeded
Status active
Known present by 10.0
Locked snapshots 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED
Aliases

Meaning

This condition means the nextval fetch loop cannot allocate the next value past a configured sequence minimum or maximum. In the ascending path, PostgreSQL checks the maximum boundary; in the descending path, it checks the minimum. At a boundary, rescnt > 0 stops the fetch loop so already fetched legal values can be returned; only when no result remains does the non-cycling branch raise 2200H. With CYCLE, the fixed source wraps to the opposite configured endpoint. This is sequence boundary policy, not a generic integer overflow.

Messages

The non-cycling ascending guard raises ERROR with primary source template nextval: reached maximum value of sequence "%s" (%" PRId64 "); the descending guard uses nextval: reached minimum value of sequence "%s" (%" PRId64 "). The endpoint itself is not inherently an error: if the fetch loop already has a legal result, it stops fetching before the error branch. PRId64 is a C format macro concatenated into the compiled numeric placeholder, so the displayed number is a runtime limit value. The cited branches have no separate DETAIL or HINT.

Diagnosis

Inspect the named sequence, increment, MINVALUE/MAXVALUE, CYCLE setting, and whether the call was nextval. Determine whether the endpoint is maximum or minimum, whether a legal endpoint or cached value was still available, and whether cycling deliberately wraps. CYCLE is a sequence policy, not a universal repair for generated identifiers: changing it can create values that collide with dependent keys or violate an application’s allocation contract. If cycling is not intended, choose a new range, alter the sequence, or rotate to a new sequence after checking dependent keys.

Response

Repair the sequence policy deliberately: adjust a safe limit, enable or disable CYCLE only after checking key semantics, or migrate allocation to a new sequence. Repeating the same nextval, casting its result, or treating this as an integer overflow cannot advance past a fixed endpoint.

When this branch raises ERROR, an explicit transaction must first be recovered with ROLLBACK or ROLLBACK TO SAVEPOINT for a savepoint established before the statement; in autocommit, retry only the corrected action after the failed statement completes. See the transaction and retry guide for this boundary rule.

Versions

The locked catalogue records this condition from 10.0; fixed source coverage is PostgreSQL 18.6.

22003, 22000

Sources

Fixed source: src/backend/commands/sequence.c#L731-769. The structured evidence record retains both limit messages and scope boundaries. The fixed source confirms the ascending and descending guards, CYCLE wrap, and C PRId64 format macro; the exact sequence name and limit are runtime values. Source presence begins at 10.0 in the locked catalogue, without asserting the precise implementation introduction commit.

56 - 2200L — not_an_xml_document

Source-backed reference for PostgreSQL SQLSTATE 2200L.

2200L

At a glance

The SQL/XML SQLSERIALIZE DOCUMENT operation received input that could not satisfy the requested document form. PostgreSQL 18.6 maps this public DOCUMENT path through xmltotext_with_options with XMLOPTION_DOCUMENT; a failed or soft parse is mapped to not an XML document. The wrapper’s early non-DOCUMENT/no-indent bypass is not a CONTENT-mode 2200L claim, and this entry does not cover every XML content or comment violation.

Field Value
SQLSTATE 2200L
Condition not_an_xml_document
Status active
Known present by 8.3.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NOT_AN_XML_DOCUMENT
Aliases

Meaning

This member is the document-level XML failure for the public SQL/XML SQLSERIALIZE DOCUMENT form. That operation reaches xmltotext_with_options with XMLOPTION_DOCUMENT; it calls xml_parse with an ErrorSaveContext, and when no document is returned or the saved parse error is set, the wrapper frees the partial document and raises 2200L. Its early guard returns binary-compatible input for non-DOCUMENT/no-indent, so this mapping should not be generalized to CONTENT. The lower xml_parse routine has separate 2200M/2200N branches, so this wrapper must not be read as a synonym for every parser error.

Messages

The SQLSERIALIZE DOCUMENT wrapper raises ERROR with primary not an XML document. The cited branch has no separate DETAIL or HINT; any parser-specific context must be taken from the actual runtime error and build.

Diagnosis

Capture the full context and the expression supplied to SQLSERIALIZE. Check whether the operation requested DOCUMENT or CONTENT, then inspect the document boundary, top-level structure, and encoding. A 2200L diagnosis is tied to the DOCUMENT mapping described above; do not infer it from a CONTENT request or conflate member codes 2200M/N/S/T with this document-level condition.

Response

Repair the XML document boundary and structure identified by the parser, preserving the caller’s required document-versus-fragment requirement.

When this branch raises ERROR, an explicit transaction must first be recovered with ROLLBACK or ROLLBACK TO SAVEPOINT for a savepoint established before the statement; in autocommit, retry only the corrected action after the failed statement completes. See the transaction and retry guide for this boundary rule.

Versions

The locked catalogue records this condition from 8.3.0; fixed source coverage is PostgreSQL 18.6.

2200M, 2200N, 2200S, 2200T

Sources

Fixed source: src/backend/utils/adt/xml.c#L669-697. The structured evidence record retains the document-option guard, message, and scope boundaries. The source confirms the wrapper mapping; the precise input and any libxml2 context are runtime-dependent. No natural XML case was run for this page.

57 - 2200M — invalid_xml_document

Source-backed reference for PostgreSQL SQLSTATE 2200M.

2200M

At a glance

This catalogue member denotes an invalid XML document. PostgreSQL 18.6 has a core xml_parse document branch that reports invalid XML document, and the contrib/xml2 XSLT path reports the same SQLSTATE for a failed source document or stylesheet parse. These are distinct emitters from the 2200L document-option wrapper.

Field Value
SQLSTATE 2200M
Condition invalid_xml_document
Status active
Known present by 8.3.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_XML_DOCUMENT
Aliases

Meaning

This member names an invalid XML document condition from a concrete document parser guard. In core xml_parse, a failed xmlCtxtReadDoc parse reports 2200M when the original XML option was DOCUMENT; when the original option was CONTENT, the same parser failure reports 2200N. The separate contrib/xml2 functions use 2200M when parsing the input document or stylesheet as XML. The core xml_errsave helper passes these results to errsave: an ErrorSaveContext stores the error and returns, while an ordinary context throws; this soft-error path is distinct from the direct ERROR branches in contrib/xml2.

Messages

The core branch raises ERROR with primary invalid XML document. The contrib/xml2 branches raise ERROR with primary error parsing XML document or error parsing stylesheet as XML document. The cited branches do not provide a fixed DETAIL or HINT template; libxml2 context can be attached dynamically. Do not replace these messages with 2200L’s not an XML document.

Diagnosis

Use the actual SQLSTATE, message, detail, and context to distinguish document-level failure from invalid content (2200N), comment (2200S), or processing instruction (2200T). Inspect whether the producer is core xml_parse or contrib/xml2, then correct the named document or stylesheet. These emitters are source-confirmed here; no natural runtime was run.

Response

Use the actual message and parser context to repair the invalid document; do not substitute a 2200L fix without confirming the emitted SQLSTATE.

When this branch raises ERROR, an explicit transaction must first be recovered with ROLLBACK or ROLLBACK TO SAVEPOINT for a savepoint established before the statement; in autocommit, retry only the corrected action after the failed statement completes. See the transaction and retry guide for this boundary rule.

Versions

The locked catalogue records this condition from 8.3.0; fixed source coverage is PostgreSQL 18.6.

2200L, 2200N

Sources

Fixed core source: src/backend/utils/adt/xml.c#L1780-1862. The separate contrib/xml2/xslt_proc.c#L84-100 paths parse an XML document and stylesheet. The shared xml_errsave/errsave helper defines the soft-error versus ordinary-throw behavior. The structured evidence record retains both emitters, message roles, and scope boundaries. Core availability depends on USE_LIBXML; no natural XML case was run for this page.

58 - 2200N — invalid_xml_content

Source-backed reference for PostgreSQL SQLSTATE 2200N.

2200N

At a glance

This member covers invalid XML content. PostgreSQL 18.6’s core XML parser has a content-mode declaration guard and content-parse guards that report 2200N; the original XML option determines whether a document parse failure is instead reported as 2200M.

Field Value
SQLSTATE 2200N
Condition invalid_xml_content
Status active
Known present by 8.3.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_XML_CONTENT
Aliases

Meaning

This member names invalid XML content at the parser’s CONTENT boundary. In content mode, an invalid XML declaration raises invalid XML content: invalid XML declaration with a detail produced by errdetail_for_xml_code(res_code). A failed balanced-content parse raises invalid XML content; if CONTENT input contains a DOCTYPE and is parsed as a document, the failed document parse still uses the original option to select 2200N. The same failed parser call uses 2200M when the original option was DOCUMENT. The declaration branch calls errsave and the content branches call xml_errsave: with an ErrorSaveContext these errors are saved and returned to the caller, while an ordinary context throws ERROR; that distinction is separate from the dynamic DETAIL text.

Messages

The cited branches raise ERROR with primary invalid XML content: invalid XML declaration for the declaration guard, with dynamic DETAIL from errdetail_for_xml_code(res_code), or primary invalid XML content for the later content/document parse failures. The declaration variant’s evidence template is dynamic errdetail_for_xml_code(res_code), not a fixed DETAIL string. No fixed universal DETAIL or HINT should be invented for those parser failures. 2200L is the outer document-option wrapper, while 2200S and 2200T identify comment and processing-instruction syntax.

Diagnosis

Read the complete parser message and the XML fragment or value it identifies. Check element names, character data, encoding, and the operation’s expected XML level. Follow a reported 2200L, 2200M, 2200S, or 2200T directly when the server emits one of those codes; do not choose 2200N from the word “invalid” alone.

Response

Correct the XML content at the element, character, or encoding boundary named by the diagnostic, and retain the actual code when validating the fix.

When this branch raises ERROR, an explicit transaction must first be recovered with ROLLBACK or ROLLBACK TO SAVEPOINT for a savepoint established before the statement; in autocommit, retry only the corrected action after the failed statement completes. See the transaction and retry guide for this boundary rule.

Versions

The locked catalogue records this condition from 8.3.0; fixed source coverage is PostgreSQL 18.6.

2200L, 2200S, 2200T

Sources

Fixed core source: src/backend/utils/adt/xml.c#L1780-1894. The shared xml_errsave/errsave helper defines the soft-error versus ordinary-throw behavior. The structured evidence record retains the declaration and content-parse guards, dynamic-detail boundary, and scope limits. Core availability depends on USE_LIBXML; no natural XML case was run for this page.

59 - 2200S — invalid_xml_comment

Source-backed reference for PostgreSQL SQLSTATE 2200S.

2200S

At a glance

An XML comment is invalid. PostgreSQL 18.6’s xmlcomment path reports invalid XML comment when the comment text contains the forbidden -- sequence or ends in -; this is comment-specific XML syntax rather than a general document failure.

Field Value
SQLSTATE 2200S
Condition invalid_xml_comment
Status active
Known present by 8.3.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_XML_COMMENT
Aliases

Meaning

This member is specific to XML comment syntax, rather than to all XML document failures. Under USE_LIBXML, xmlcomment scans the input before constructing <!--...-->; a double hyphen anywhere or a trailing hyphen is rejected.

Messages

The guard raises ERROR with primary invalid XML comment. The cited branch has no separate DETAIL or HINT. Without USE_LIBXML, the function follows the separate XML-support path (0A000), so source presence does not by itself prove availability in every server build.

Diagnosis

Inspect the comment text and the exact XML context named by the message. XML comments cannot contain the forbidden double-hyphen form or end with a hyphen; repair that comment while preserving surrounding markup. If the parser instead identifies a processing instruction or non-document content, follow 2200T or 2200L/N as reported.

Response

Repair the comment text while preserving surrounding XML, following the comment-specific message rather than applying a general document workaround.

When this branch raises ERROR, an explicit transaction must first be recovered with ROLLBACK or ROLLBACK TO SAVEPOINT for a savepoint established before the statement; in autocommit, retry only the corrected action after the failed statement completes. See the transaction and retry guide for this boundary rule.

Versions

The locked catalogue records this condition from 8.3.0; fixed source coverage is PostgreSQL 18.6.

2200L, 2200T

Sources

Fixed source: src/backend/utils/adt/xml.c#L490-523. The structured evidence record retains the complete comment guard, message, and scope boundaries. The offending comment is runtime input and the function is compiled under USE_LIBXML; no natural XML runtime was run here.

60 - 2200T — invalid_xml_processing_instruction

Source-backed reference for PostgreSQL SQLSTATE 2200T.

2200T

At a glance

An XML processing instruction violates its XML syntax. PostgreSQL 18.6’s xmlpi path rejects a target whose name is case-insensitively xml, or a non-NULL body containing ?>; both guards report invalid XML processing instruction with a branch-specific DETAIL.

Field Value
SQLSTATE 2200T
Condition invalid_xml_processing_instruction
Status active
Known present by 8.3.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION
Aliases

Meaning

This member is specific to XML processing-instruction syntax, including its target name and body. xmlpi checks the target with case-insensitive comparison, so xml, XML, and mixed-case forms hit the same target guard. Only after that syntax check does it apply the SQL NULL rule: a NULL body returns NULL for a valid target. A non-NULL body containing ?> hits the body guard.

Messages

The target guard raises ERROR with primary invalid XML processing instruction and DETAIL XML processing instruction target name cannot be "%s".. The body guard uses the same primary and DETAIL XML processing instruction cannot contain "?>".. The cited branches have no separate HINT. %s is the runtime target name; a NULL body after a valid target is not a 2200T error.

Diagnosis

Use the full message and detail to identify whether the target name or the instruction body is wrong. Check the target-name rule and remove the terminating ?> sequence from the body while keeping the surrounding XML structure valid. Do not repair a comment or a general document error using this member’s rules.

Response

Repair the target name or instruction body named by the detail, preserving valid XML structure and removing the forbidden processing-instruction form.

When this branch raises ERROR, an explicit transaction must first be recovered with ROLLBACK or ROLLBACK TO SAVEPOINT for a savepoint established before the statement; in autocommit, retry only the corrected action after the failed statement completes. See the transaction and retry guide for this boundary rule.

Versions

The locked catalogue records this condition from 8.3.0; fixed source coverage is PostgreSQL 18.6.

2200L, 2200S

Sources

Fixed source: src/backend/utils/adt/xml.c#L1010-1055. The structured evidence record retains both guards, message/detail variants, NULL ordering, and scope boundaries. Target names and instruction content are runtime values; no natural XML runtime was run.

61 - 22010 — invalid_indicator_parameter_value

Source-backed reference for PostgreSQL SQLSTATE 22010.

At a glance

An indicator parameter value does not satisfy the indicator or descriptor rules of the operation consuming it. The fixed PostgreSQL 18.6 catalogue confirms the condition, but the bounded source scan does not bind it to a native emitter, message template, or severity.

Field Value
SQLSTATE 22010
Condition invalid_indicator_parameter_value
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_INDICATOR_PARAMETER_VALUE
Aliases

Meaning

22010 concerns a value carried alongside an operation as an indicator or descriptor field. The condition name alone does not identify a particular API, indicator layout, or server routine; the operation that reports it defines which values are valid.

Diagnosis

Capture the complete diagnostic, operation or API owner, parameter position, source type, and actual indicator value. Check initialization, permitted sign and value ranges, and whether a wrapper translates the failure. A NULL or cast diagnostic by itself does not establish 22010, and this fixed-source review does not infer an ECPG emitter from the name.

Response

Correct the named indicator or descriptor value according to the consuming operation’s documented rules, then repeat the operation only after checking its other inputs. If the message comes from a wrapper, repair that wrapper’s input mapping rather than assuming a PostgreSQL server-side path.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6. The exact implementation introduction date and an emitting path remain unresolved by this bounded review.

22002, 22004

Sources

The fixed definition is confirmed in errcodes.txt. Runtime verification is not_run; the bounded PostgreSQL 18.6 scan does not resolve a native emitting function, so this page does not assert a primary template, severity, transaction effect, or API owner. The structured evidence record retains the definition and scope boundary.

62 - 22011 — substring_error

Source-backed reference for PostgreSQL SQLSTATE 22011.

At a glance

A text substring path received an invalid explicit length. In fixed PostgreSQL 18.6 code, text_substring reports negative substring length not allowed with SQLSTATE 22011.

Field Value
SQLSTATE 22011
Condition substring_error
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SUBSTRING_ERROR
Aliases

Meaning

The three-argument text substring wrapper passes its explicit length to text_substring; a negative length reaches the ERRCODE_SUBSTRING_ERROR guard. The no-length wrapper instead passes a sentinel with length_not_specified, so it returns the remainder and does not enter that negative-length guard. The same code is also used by OVERLAY when its start position is non-positive. This evidence is for the text path: bytea, bit-string, and pattern-based substring operations have separate consumers and must be identified from the full diagnostic.

Diagnosis

Check the resolved operation and data type before changing values. For text, distinguish an explicit negative length from a start of zero or less: the source clamps the effective start to one and applies the SQL length adjustment. A start past the end returns an empty string. A large start-plus-length that overflows the 32-bit calculation runs to the end; it is not this error. In OVERLAY, a non-positive start uses the same primary, while an overflowing start-plus-length uses 22003 instead.

Response

Pass a non-negative explicit text length, or omit the length when the intended result is the remainder. Preserve the intended one-based start semantics and check the actual data type before applying a text-specific repair. This path raises ERROR; an explicit transaction must be rolled back or rolled back to an existing savepoint before retrying, while autocommit can retry only the corrected statement.

Messages

  • Primary, ERROR: negative substring length not allowed for the explicit text substring guard and the non-positive OVERLAY start guard. There is no fixed DETAIL or HINT on these paths.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6. The cited guards are current-version text and OVERLAY paths, not a claim about every substring implementation.

22000, 22001, 22003

Sources

Runtime verification is not_run; the source evidence is not a runtime observation. The structured evidence record retains the exact primary and source scope.

63 - 22012 — division_by_zero

Source-backed reference for PostgreSQL SQLSTATE 22012.

At a glance

A division or modulo operation reached a zero divisor. PostgreSQL 18.6 uses SQLSTATE 22012 in numeric, integer, floating-point, money, and interval-division paths, while each path keeps its own operand and special-value rules.

Field Value
SQLSTATE 22012
Condition division_by_zero
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DIVISION_BY_ZERO
Aliases
SELECT 10::numeric / 0::numeric;
SELECT 10::numeric / 2::numeric;

The retained PostgreSQL 18.6 and 10.21 observations show the first statement returning primary division by zero with SQLSTATE 22012, then the corrected statement returning 5.0000000000000000; both backends were IDLE after the repaired action. The public case JSON identifies this numeric division case; it is not a runtime comparison of every producer listed below.

Meaning

The direct numeric functions numeric_div and numeric_mod guard a zero numeric divisor; their internal *_opt_error forms can instead set a have_error flag and return NULL to a caller that handles the failure. Integer division and modulo functions check their zero second operand before using / or %. Float4/float8 division routes through float*_div, which raises for a zero divisor when the numerator is not NaN. Money division checks its integer or money divisor, and interval division checks its float factor. These paths share the SQLSTATE and primary text, but the resolved operator and special values still determine the result.

Diagnosis

Locate the denominator or modulo divisor after operator/type resolution; do not infer an int4 rule for all numeric types. Check whether zero came from input, a join, an aggregate, or a business rule, and inspect the complete primary message. A NULL operand normally produces a NULL result before a strict arithmetic function is called, while NULLIF(denominator, 0) deliberately turns the zero case into NULL. A CASE expression can choose a NULL, substitute, or skip policy, so choose the branch that matches the business result rather than silently changing an error into a value.

The planning boundary matters: the PostgreSQL 18.6 conditional-expression documentation warns that a constant 1/0 subexpression can fail during planning even in an unreachable CASE arm. The planner source recursively simplifies constant arguments and evaluates immutable constant expressions. Use a non-constant value or guard the actual denominator with NULLIF/a suitable CASE when the division must be deferred to execution; this does not make an invalid constant expression safe, and it does not decide whether NULL or a substitute is correct for the application.

Response

Repair the producer of the zero divisor or select an explicit zero policy. Use NULLIF when a NULL result is meaningful, or a CASE branch when the application has a documented substitute or skip rule; then validate the downstream aggregates and filters that will see that result. Do not replay the unchanged operation. The ordinary fixed paths raise ERROR; in an explicit transaction use ROLLBACK or ROLLBACK TO SAVEPOINT before retrying, while autocommit can retry only the corrected action. The retained 18.6/10.21 numeric observation is limited to this case.

Messages

  • Primary, ERROR: division by zero.
  • No fixed DETAIL or HINT is attached to the cited numeric, integer, float, money, or interval-division guards. Internal numeric have_error callers are a soft handling path, not a claim that a direct SQL operator returns successfully.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6. The retained numeric runtime records are PostgreSQL 18.6 and 10.21 and cover only 10::numeric / 0::numeric followed by 10::numeric / 2::numeric.

22003, 22008, 22015

Sources

The structured evidence record retains both runtime summaries/raw digests and the fixed source claims.

64 - 22013 — invalid_preceding_or_following_size

Source-backed reference for PostgreSQL SQLSTATE 22013.

At a glance

A window-frame offset is negative in a fixed ROWS or GROUPS executor path. PostgreSQL 18.6 reports either frame starting offset must not be negative or frame ending offset must not be negative with SQLSTATE 22013.

Field Value
SQLSTATE 22013
Condition invalid_preceding_or_following_size
Status active
Known present by 11.0
Locked snapshots 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE
Aliases

Meaning

calculate_frame_offsets evaluates the start and end expressions once for a window scan. After a non-NULL value is copied, the ROWS and GROUPS branches interpret it as an int8 offset and reject a negative value with 22013. The NULL guards use 22004 and different primary messages. RANGE frames use type-specific in_range helpers: the integer helper rejects a negative offset, numeric rejects NaN, negative infinity, or a negative value, the float helper rejects NaN or a negative value, and the timestamp-with-interval helper rejects a negative interval. These helpers use the same 22013 primary, so the frame mode and resolved offset type are part of the diagnosis.

Diagnosis

Read the frame mode, endpoint named by the primary, and the evaluated offset expression. A negative start or end in ROWS/GROUPS is this condition. In RANGE, inspect the resolved offset type: a negative integer or interval, or the rejected NaN/negative numeric and float values, reaches the same code. A NULL start or end is 22004, not 22013. This is a frame-boundary validation failure, not a generic arithmetic overflow.

Response

For a ROWS or GROUPS endpoint, provide a non-negative int8-compatible offset; for RANGE, provide a value accepted by the resolved type-specific in_range helper. Provide a non-NULL value when NULL was the actual issue. Because the cited guard raises ERROR, roll back or roll back to an existing savepoint in an explicit transaction before retrying; autocommit can retry only the corrected statement.

Messages

  • Primary, ERROR: frame starting offset must not be negative.
  • Primary, ERROR: frame ending offset must not be negative.
  • Primary, ERROR: invalid preceding or following size in window function for the cited type-specific RANGE offset guards.
  • The cited guards add no DETAIL or HINT. NULL endpoints use SQLSTATE 22004 with frame starting offset must not be null or frame ending offset must not be null.

Versions

The locked catalogue records this condition from 11.0; fixed source coverage is PostgreSQL 18.6. The cited executor guard covers ROWS/GROUPS; the cited type-specific in_range helpers cover representative RANGE offsets.

22004, 22012, 22003

Sources

Runtime verification is not_run; this source evidence is not a runtime observation. The structured evidence record retains the two endpoint variants, the generic RANGE primary, and their scope.

65 - 22014 — invalid_argument_for_ntile_function

Source-backed reference for PostgreSQL SQLSTATE 22014.

At a glance

ntile received a non-positive bucket count. The fixed window-function path reports argument of ntile must be greater than zero with SQLSTATE 22014.

Field Value
SQLSTATE 22014
Condition invalid_argument_for_ntile_function
Status active
Known present by 8.4.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_ARGUMENT_FOR_NTILE
Aliases

Meaning

While context->ntile is still zero, before a successful initialization, window_ntile evaluates the bucket argument. A NULL argument returns NULL before setting that state, so a later row may evaluate the argument again; a value less than or equal to zero raises 22014, while a positive count initializes the state and is reused for later rows. An empty input produces no window-function row to evaluate and is not this error.

Diagnosis

Inspect the resolved ntile argument for the affected partition and distinguish three cases: positive count, NULL count, and non-positive count. A NULL count gives a NULL result on rows that are evaluated; an empty partition gives no result at all. Neither should be reported as the non-positive-argument error.

Response

Pass a positive integer bucket count after checking the expression that supplies it. Use COALESCE or another fallback only when the resulting bucket policy is intentional. The fixed guard raises ERROR; in an explicit transaction roll back or return to an existing savepoint before retrying, while autocommit can retry only the corrected statement.

Messages

  • Primary, ERROR: argument of ntile must be greater than zero.
  • The fixed guard adds no DETAIL or HINT.

Versions

The locked catalogue records this condition from 8.4.0; fixed source coverage is PostgreSQL 18.6. The cited behavior is the window-function implementation, not a general argument validator.

22013, 22016

Sources

src/backend/utils/adt/windowfuncs.c#L411-L475 shows the partition-row count, NULL early return, positive-count guard, and bucket calculation. Runtime verification is not_run; this source evidence is not a runtime observation. The structured evidence record retains the primary and scope.

66 - 22015 — interval_field_overflow

Source-backed reference for PostgreSQL SQLSTATE 22015.

At a glance

An interval input field exceeds the range accepted by the interval decoder. PostgreSQL 18.6 maps that datetime parsing condition to SQLSTATE 22015; later interval construction or arithmetic can use different range codes.

Field Value
SQLSTATE 22015
Condition interval_field_overflow
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INTERVAL_FIELD_OVERFLOW
Aliases

Meaning

The fixed interval_in path parses the input, decodes the interval fields under the typmod range, and retries ISO 8601 decoding when the first parse reports a bad format. When decoding returns DTERR_FIELD_OVERFLOW, interval_in remaps it to DTERR_INTERVAL_OVERFLOW; DateTimeParseError then uses ERRCODE_INTERVAL_FIELD_OVERFLOW with the original input in the primary. This is the interval-field input boundary. itmin2interval conversion failure, typmod adjustment, and interval arithmetic have separate guards and may report 22008, 22003, or another condition; they are not automatically 22015.

Diagnosis

Read the complete primary and identify the input string, interval field, and declared typmod/range. Check whether the value overflowed while decoding a field, or whether the operation actually failed later while constructing, scaling, or dividing an interval. A date/time field diagnostic belongs to the neighboring datetime codes, and interval division by a zero factor is 22012. Do not replace a field-range failure with a generic numeric overflow fix.

Response

Correct the named interval field or input representation so it fits the operation’s accepted range, and review the interval typmod if it is imposing the boundary. If the failure is in later arithmetic, repair that operation according to its own SQLSTATE. In ordinary error context this path raises ERROR, so an explicit transaction needs ROLLBACK or ROLLBACK TO SAVEPOINT before retrying; an ErrorSaveContext caller receives a saved error and a NULL/failed return instead of a thrown error.

Messages

  • Primary, ERROR in ordinary context: interval field value out of range: "%s", where %s is the original interval input. The cited branch adds no fixed DETAIL or HINT.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6. The source-backed path is interval input decoding; it does not claim that every interval arithmetic overflow uses 22015.

22007, 22003, 22008, 22012

Sources

Runtime verification is not_run; no interval runtime observation is claimed. The structured evidence record retains the exact message role and source boundary.

67 - 22016 — invalid_argument_for_nth_value_function

Source-backed reference for PostgreSQL SQLSTATE 22016.

At a glance

nth_value received a non-positive ordinal. The fixed window-function path reports argument of nth_value must be greater than zero with SQLSTATE 22016.

Field Value
SQLSTATE 22016
Condition invalid_argument_for_nth_value_function
Status active
Known present by 8.4.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_ARGUMENT_FOR_NTH_VALUE
Aliases

Meaning

window_nth_value first reads the ordinal argument: NULL returns NULL, while an ordinal less than or equal to zero raises 22016. A positive ordinal is then converted to a zero-based frame offset. If that row is outside the current frame, or the selected value itself is NULL, the executor returns NULL; neither case is 22016.

Diagnosis

Check the evaluated ordinal, the window ordering, and the frame boundaries. Distinguish an invalid non-positive argument from a valid positive argument whose target row is not in the frame. A NULL ordinal is also a NULL result path, so do not turn it into this error merely because the result is NULL.

Response

Supply a positive ordinal when the function is meant to select a row, then adjust the ordering or frame only if the target row must be included. Preserve a NULL result when it represents a missing frame row or a NULL value. The non-positive guard raises ERROR; in an explicit transaction roll back or return to an existing savepoint before retrying, while autocommit can retry only the corrected statement.

Messages

  • Primary, ERROR: argument of nth_value must be greater than zero.
  • The non-positive-ordinal guard adds no DETAIL or HINT; out-of-frame and NULL-value paths return NULL instead.

Versions

The locked catalogue records this condition from 8.4.0; fixed source coverage is PostgreSQL 18.6. The cited behavior is the window-function implementation, not a general ordinal validator.

22014, 22013

Sources

src/backend/utils/adt/windowfuncs.c#L686-L715 shows NULL handling, the positive-ordinal guard, the frame lookup, and the NULL return when no target row/value is available. Runtime verification is not_run; this source evidence is not a runtime observation. The structured evidence record retains the primary and scope.

68 - 22018 — invalid_character_value_for_cast

Source-backed reference for PostgreSQL SQLSTATE 22018.

At a glance

A character value is rejected by the conversion requested by an operation. The fixed PostgreSQL 18.6 catalogue confirms invalid_character_value_for_cast, but the bounded source scan does not bind this entry to one native emitter or message template.

Field Value
SQLSTATE 22018
Condition invalid_character_value_for_cast
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_CHARACTER_VALUE_FOR_CAST
Aliases

Meaning

22018 identifies a character representation that the requested conversion cannot accept. The condition name does not select a target type, parser, locale rule, or wrapper; those details belong to the operation that reports the code. Do not turn this definition into an assertion about one particular cast implementation.

Diagnosis

Read the complete primary, source and target types, input format, and any locale or type-specific setting. Decide whether the input is malformed for the target parser, outside its range, or rejected by type resolution. A date/time syntax diagnostic, a numeric range diagnostic, and a generic operator mismatch can use neighboring codes; the real message and owner decide which repair applies.

Response

Correct the source representation or explicit conversion according to the actual source type, target type, and format rules. If the diagnostic comes from a wrapper or extension, follow that consumer’s documented parser and do not assume the fixed core scan covers it.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6. The exact implementation introduction date and a fixed native emitter remain unresolved by this bounded review.

22007, 22003

Sources

The fixed definition is confirmed in errcodes.txt. Runtime verification is not_run; the bounded PostgreSQL 18.6 scan does not resolve a single native emitting path, so this page does not assert a primary template, severity, or transaction effect. The structured evidence record retains the definition and scope boundary.

69 - 22019 — invalid_escape_character

Source-backed reference for PostgreSQL SQLSTATE 22019.

At a glance

An operation rejected its escape argument. The fixed catalogue defines invalid_escape_character, but the bounded PostgreSQL 18.6 source scan found no native emitter to which one message or severity can safely be attached.

Field Value
SQLSTATE 22019
Condition invalid_escape_character
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_ESCAPE_CHARACTER
Aliases

Meaning

The relevant rule belongs to the consumer of ESCAPE. PostgreSQL’s LIKE and SIMILAR documentation permits a one-character escape, allows ESCAPE '' to disable escaping, and distinguishes that behavior from the SQL standard’s zero-length rule. Another consumer may require one character, reject a character class, or apply its own empty-string rule. Therefore 22019 cannot be explained by one universal length or character check without an emitting path.

Diagnosis

Identify the consumer and read its complete diagnostic before changing the value. Check the escape expression’s resolved type and character length, whether the value is an empty string, and whether the chosen character has a special meaning in that pattern language. Keep SQL string-literal quoting separate from pattern escaping, and distinguish this bounded definition from 2200C SIMILAR separator syntax and 2200D invalid octets.

Response

Use the consumer’s documented escape representation: a valid single character where that consumer requires one, or the explicitly supported empty string (ESCAPE ‘’) where it disables escaping. Re-encode the SQL literal as needed, then validate the same consumer; do not apply a LIKE rule to an unrelated parser.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6. The exact implementation introduction date and native emitter remain unresolved by this bounded review.

2200C, 2200D

Sources

  • The fixed definition is confirmed in errcodes.txt; no occurrence of ERRCODE_INVALID_ESCAPE_CHARACTER was resolved in the bounded PostgreSQL 18.6 source scan.
  • Same-tag pattern-matching documentation documents LIKE’s one-character/default/empty escape behavior, and #L5724-L5830 documents the corresponding SIMILAR rules. These are consumer rules, not a claimed 22019 emitter.

Runtime verification is not_run; this page does not assert a primary template, severity, or transaction effect. The structured evidence record retains the definition, documentation scope, and bounded-emitter limitation.

70 - 2201B — invalid_regular_expression

Source-backed reference for PostgreSQL SQLSTATE 2201B.

At a glance

SQL regular-expression compilation and execution have separate 2201B paths, and HBA/ident configuration handling uses the same code with log-level reporting. The fixed messages and severities must be read by owner rather than merged into one generic regex failure.

Field Value
SQLSTATE 2201B
Condition invalid_regular_expression
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_REGULAR_EXPRESSION
Aliases

Meaning

In regexp.c, a pattern that cannot compile raises ERROR with invalid regular expression: %s; a compiled pattern whose execution returns a regex-engine error raises ERROR with regular expression failed: %s. REG_NOMATCH is an ordinary no-match result, not this SQLSTATE. In hba.c, configuration regex compilation uses invalid regular expression "%s": %s at the caller’s level (the normal load_hba path passes LOG), and ident-map match/backreference failures are also logged with their own primary text. These configuration messages are not SQL expression ERROR paths.

Diagnosis

Use the complete primary, severity, and context to identify the owner. For SQL regex functions, inspect the pattern and flags and distinguish compile errors from execution errors. For HBA or ident configuration, inspect the named file and line, the token’s leading-slash marker and the regex text after it, and the reload/startup context; a logged configuration failure can leave the previous HBA configuration in place on reload. Do not treat a normal REG_NOMATCH as invalid syntax.

Response

Repair the pattern or flags in the owning syntax and validate that same subsystem. A SQL regex ERROR aborts the current statement, so an explicit transaction must be rolled back or rolled back to an existing savepoint before retrying; autocommit can retry only the corrected statement. A configuration LOG/debug report requires fixing the HBA or ident file and reloading or restarting according to that subsystem, not transaction rollback.

Messages

  • SQL regex compile, ERROR: invalid regular expression: %s.
  • SQL regex execution error, ERROR: regular expression failed: %s.
  • HBA regex compilation, caller-selected level (the normal load_hba path uses LOG): invalid regular expression "%s": %s; the source also adds configuration-file line context.
  • HBA ident-map execution, LOG: regular expression match for "%s" failed: %s.
  • HBA ident backreference without a captured subexpression, LOG: regular expression "%s" has no subexpressions as requested by backreference in "%s".

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6. The cited SQL regex and HBA/ident paths are distinct owners; extension or other subsystem messages are outside this bounded review.

2200C, 2200D

Sources

Runtime verification is not_run; no regex runtime observation is claimed. The structured evidence record retains owner-specific messages, severities, and source limits.

71 - 2201E — invalid_argument_for_logarithm

Source-backed reference for PostgreSQL SQLSTATE 2201E.

2201E

At a glance

Logarithm functions reject zero and negative inputs at their defined-domain guards. Fixed float paths report cannot take logarithm of zero or cannot take logarithm of a negative number; numeric ln and base-log paths apply the same SQLSTATE while handling NaN and infinities separately.

Field Value
SQLSTATE 2201E
Condition invalid_argument_for_logarithm
Status active
Known present by 8.0.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_ARGUMENT_FOR_LOG
Aliases

Meaning

2201E is a logarithm domain error, not a generic numeric overflow. In float.c, ln() and log() reject an argument equal to zero and then one less than zero. Numeric ln rejects negative infinity but returns numeric NaN or positive infinity unchanged; numeric base-log rejects a negative or zero base/argument and has defined NaN/infinity results for some positive special-value combinations.

Diagnosis

Read the function signature and the actual numeric type before changing the value. Match the primary message: zero and negative inputs are different guards. For float inputs, NaN does not satisfy either comparison and therefore is not this particular guard; later float overflow or underflow reports are separate conditions. Preserve the input and business rule while checking whether the logarithm domain is really intended.

Response

Supply a value in the domain required by the named logarithm function, or change the business rule explicitly. If an ERROR occurred inside an explicit transaction, roll back or roll back to the existing savepoint before retrying; an autocommit client can retry the corrected statement. Casting blindly can move the value without making the operation defined.

Versions

The locked catalogue records this condition from 8.0.0; the fixed source paths here are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

22003, 22012

Sources

Fixed paths include src/backend/utils/adt/float.c#L1687-1747 and src/backend/utils/adt/numeric.c#L3935-4020 plus #L11156-11168, which bind the zero/negative guards and special-value branches. The structured evidence record retains the exact message roles and scope boundary; no natural runtime was run.

72 - 2201F — invalid_argument_for_power_function

Source-backed reference for PostgreSQL SQLSTATE 2201F.

2201F

At a glance

Power functions reject operands whose real-valued result is undefined. Fixed numeric paths report zero raised to a negative power is undefined or a negative number raised to a non-integer power yields a complex result.

Field Value
SQLSTATE 2201F
Condition invalid_argument_for_power_function
Status active
Known present by 8.0.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION
Aliases

Meaning

2201F covers two distinct power guards: a zero base with a negative exponent, and a negative base with a non-integer exponent. The checks occur for ordinary finite numeric values and in the special-value path. Numeric NaN handling can return NaN or 1 under POSIX rules, and several infinity combinations are defined; a negative base with an integer exponent is not automatically this error.

Diagnosis

Inspect the resolved base and exponent types and the exact primary message. A decimal exponent that is not integral is different from a negative integer exponent, so changing scale or applying an unrelated cast is not a repair. Check special values separately rather than treating every NaN or infinity as an invalid power.

Response

Choose a base/exponent pair with the intended real result, or change the business rule explicitly. If the ERROR is in an explicit transaction, roll back or roll back to the existing savepoint before retrying; an autocommit client can retry the corrected operation.

Versions

The locked catalogue records this condition from 8.0.0; the fixed source paths here are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

2201E, 22003

Sources

The finite and special-value guards are in src/backend/utils/adt/numeric.c#L4045-4111 and #L4208-4220; the negative-base non-integral guard is in #L11373-11384. The structured evidence record retains the exact message roles; no natural runtime was run.

73 - 2201G — invalid_argument_for_width_bucket_function

Source-backed reference for PostgreSQL SQLSTATE 2201G.

2201G

At a glance

width_bucket validates its bucket count, NaN inputs, histogram bounds, and bound equality. The fixed numeric and float8 paths report distinct 2201G messages for non-positive count, NaN, non-finite bounds, and equal bounds.

Field Value
SQLSTATE 2201G
Condition invalid_argument_for_width_bucket_function
Status active
Known present by 8.0.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION
Aliases

Representative messages

The fixed guards use these primary texts:

Guard Primary
non-positive count count must be greater than zero
any NaN operand or bound operand, lower bound, and upper bound cannot be NaN
non-finite bound lower and upper bounds must be finite
equal bounds lower bound cannot equal upper bound

Meaning

For the numeric and float8 width_bucket(operand, bound1, bound2, count) signatures, count must be greater than zero; operand or either bound cannot be NaN; and both bounds must be finite and unequal. The implementation accepts either ascending or descending bounds, and an infinite operand is allowed even though an infinite bound is not. If a valid endpoint calculation overflows count + 1, the source reports 22003 instead.

Diagnosis

Use the function signature and the exact primary message to identify the offending argument. Check count, then distinguish NaN from infinity and distinguish the operand from the two bounds. Do not impose a lower-than-upper rule: descending bounds have their own valid bucket calculation. An equal pair is the specific ordering failure covered by 2201G.

Response

Correct the named count, operand, or bound while preserving the intended bucket direction. Keep both bounds finite and unequal, use a positive count, and handle an out-of-range result as the separate 22003 condition. If this ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected call.

Versions

The locked catalogue records this condition from 8.0.0; the fixed source paths here are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

22003, 22012

Sources

The complete representative guards are in src/backend/utils/adt/numeric.c#L1959-2045 and src/backend/utils/adt/float.c#L4060-4180. The structured evidence record retains all four primary templates and the bounded source scope; no natural runtime was run.

74 - 2201W — invalid_row_count_in_limit_clause

Source-backed reference for PostgreSQL SQLSTATE 2201W.

2201W

At a glance

A LIMIT or FETCH row count fails a form-specific guard. Fixed paths report LIMIT must not be negative; the parser separately rejects a literal NULL row count in FETCH FIRST ... WITH TIES.

Field Value
SQLSTATE 2201W
Condition invalid_row_count_in_limit_clause
Status active
Known present by 8.4.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_ROW_COUNT_IN_LIMIT_CLAUSE
Aliases

Representative messages

The representative guards use these primary texts:

Path Primary
ordinary LIMIT with a negative count LIMIT must not be negative
literal NULL in FETCH FIRST ... WITH TIES row count cannot be null in FETCH FIRST ... WITH TIES clause

Meaning

The executor evaluates an ordinary LIMIT count: NULL is interpreted as no count (LIMIT ALL), zero is valid and returns no rows, and a negative value emits 2201W. The parser has a separate guard for an unadorned NULL constant in FETCH FIRST ... WITH TIES; it is not a blanket rule that every nullable LIMIT expression has the same behavior. OFFSET is handled by 2201X.

Diagnosis

Identify whether the message came from an ordinary LIMIT evaluation or the WITH TIES parser rule, then inspect the evaluated expression and its type. Keep NULL-without-ties, literal NULL-with-ties, zero, and negative values separate. A hidden expression can pass the parser’s narrow A_Const check, so classify the resulting behavior from the actual statement and message.

Response

For ordinary LIMIT, use a non-negative count or NULL when an unlimited result is intended. For WITH TIES, provide a non-NULL row count accepted by that syntax. If the negative-count or parser ERROR occurred inside an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected statement.

Versions

The locked catalogue records this condition from 8.4.0; the fixed source paths here are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

2201X, 22012

Sources

The executor NULL/zero/negative handling is in src/backend/executor/nodeLimit.c#L347-405, and the literal WITH TIES NULL guard is in src/backend/parser/parse_clause.c#L1890-1907. The structured evidence record retains both primary roles; no natural runtime was run.

75 - 2201X — invalid_row_count_in_result_offset_clause

Source-backed reference for PostgreSQL SQLSTATE 2201X.

2201X

At a glance

An OFFSET expression is negative after evaluation. The fixed executor path reports OFFSET must not be negative.

Field Value
SQLSTATE 2201X
Condition invalid_row_count_in_result_offset_clause
Status active
Known present by 8.4.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE
Aliases

Meaning

During LIMIT-node recomputation, a NULL OFFSET is interpreted as zero (no offset), zero is valid, and only a negative evaluated offset reaches 2201X. This is the OFFSET-specific sibling of 2201W; LIMIT count rules must be diagnosed from their own SQLSTATE.

Diagnosis

Inspect the evaluated OFFSET expression after parameter substitution and type resolution. Distinguish NULL/no offset and zero from a negative value, and do not relabel a LIMIT or FETCH row-count failure as 2201X.

Response

Supply a non-negative OFFSET, or NULL when the intended result is no offset. If the ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected statement.

Versions

The locked catalogue records this condition from 8.4.0; the fixed source path here is PostgreSQL 18.6. No natural runtime observation is claimed for this page.

2201W, 22003

Sources

The executor’s NULL-to-zero and negative guard are in src/backend/executor/nodeLimit.c#L356-375. The structured evidence record retains the exact primary template and source boundary; no natural runtime was run.

76 - 22021 — character_not_in_repertoire

Source-backed reference for PostgreSQL SQLSTATE 22021.

22021

At a glance

A source byte sequence is invalid for the encoding being checked. The fixed conversion path reports invalid byte sequence for encoding "%s": %s and formats the offending bytes.

Field Value
SQLSTATE 22021
Condition character_not_in_repertoire
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_CHARACTER_NOT_IN_REPERTOIRE
Aliases

Meaning

report_invalid_encoding computes the incomplete or invalid multibyte length and emits 22021 with the source encoding name and hexadecimal bytes. A valid source character that has no equivalent in the destination encoding follows the separate 22P05 untranslatable-character path; that is not evidence that the source bytes themselves are malformed.

Diagnosis

Record source and destination encodings, client/database settings, and the exact bytes before changing anything. Invalid source bytes point to input or boundary decoding; a readable but unrepresentable character points to conversion repertoire. Do not treat SQL_ASCII as a universal fix: accepting arbitrary bytes can defer or hide an encoding boundary defect.

Response

Repair the producer or encoding boundary, or explicitly convert the value with a deliberate loss/rejection policy while retaining the offending bytes for diagnosis. If the ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry corrected input.

Versions

The locked catalogue records this condition from 7.4; the fixed conversion paths here are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

22P05, 22018

Sources

The invalid-byte reporter is src/backend/utils/mb/mbutils.c#L1818-1853; the same fixed file’s report_untranslatable_char path emits the distinct 22P05 condition for a valid but non-representable character. The structured evidence record retains both boundaries; no natural runtime was run.

77 - 22022 — indicator_overflow

Source-backed reference for PostgreSQL SQLSTATE 22022.

22022

At a glance

The catalogue condition names an indicator value that cannot fit its interface representation. The bounded PostgreSQL 18.6 source review confirms the definition but does not bind a native emitting report group.

Field Value
SQLSTATE 22022
Condition indicator_overflow
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INDICATOR_OVERFLOW
Aliases

Meaning

22022 is an interface-level indicator-overflow condition, but the fixed source scope here does not identify which client or API owns an emitter. Its condition name must not be turned into an invented ECPG, ordinary SQL cast, or server-column path.

Diagnosis

Use the complete diagnostic and owning interface to determine the indicator type, storage width, and value range. Without a confirmed emitter, this page cannot assign a primary message, severity behavior, transaction effect, or universal server-side repair.

Response

Inspect the actual interface contract and choose an indicator representation that can hold the returned value, following that interface’s documented recovery. Treat this as bounded unknown source coverage rather than applying a generic numeric-overflow fix.

Versions

The locked catalogue records this condition from 7.4; only the PostgreSQL 18.6 definition and bounded source scope are confirmed. No natural runtime observation is claimed for this page.

22003, 22010

Sources

The fixed catalogue definition is recorded in the structured evidence record. Its bounded-scan claim deliberately leaves the native emitter, primary text, severity, and transaction behavior unknown; no natural runtime was run.

78 - 22023 — invalid_parameter_value

Source-backed reference for PostgreSQL SQLSTATE 22023.

22023

At a glance

A named parameter, option, descriptor, or function argument is outside the domain accepted by its owner. Fixed representatives cover built-in GUC parsing, amcheck descriptors/options, postgres_fdw option validation, and regular-expression option checks; the primary text identifies the owner and value.

Field Value
SQLSTATE 22023
Condition invalid_parameter_value
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_PARAMETER_VALUE
Aliases

The retained PostgreSQL 18.6 and 10.21 observations use the same autocommit case: SET work_mem = 'not-a-memory-size' returned SQLSTATE 22023 with invalid value for parameter "work_mem": "not-a-memory-size"; SET work_mem = '1MB' repaired it and SHOW work_mem returned 1MB. Both backends were IDLE after the error and repair. The selected case is the built-in GUC path, not a general result for every 22023 owner; see the public case JSON.

SET work_mem = 'not-a-memory-size';
SET work_mem = '1MB';
SHOW work_mem;

Representative messages

These examples share 22023 but belong to separate owners:

Owner / path Representative primary text
Built-in GUC parsing/checks parameter "%s" requires a Boolean value; invalid value for parameter "%s": "%s"
verify_heapam relation cannot be null; invalid skip option — HINT: Valid skip options are "all-visible", "all-frozen", and "none".
postgres_fdw invalid value for floating point option "%s": %s; invalid value for integer option "%s": %s
Regular-expression option parser invalid regular expression option: "%.*s"

Meaning

22023 is a shared parameter-validation code whose mechanism belongs to the named owner. Built-in GUC parsing first converts Boolean, integer, real, string, or enum values, checks integer/real ranges and units such as B/MB or time units, then invokes parameter-specific check hooks; setting context and permissions are separate constraints. verify_heapam instead checks required non-NULL descriptors and enumerated skip values, postgres_fdw parses numeric/string options and positive bounds, and regexp functions validate option letters or function parameters. These groups share the SQLSTATE but not one universal value domain.

Diagnosis

Start with the command, function, or extension named by the primary message. For a GUC, inspect the parameter’s type, accepted units/range, and whether the current setting context permits the change; for an extension or function, follow its own option list and bounds. The exact work_mem case above demonstrates a bad GUC value and a valid unit-bearing repair only. Do not infer the repair for amcheck, postgres_fdw, regexp, or another parameter from that case.

Response

Correct the value according to the owning parameter’s documented domain, including its unit and setting context where applicable. In an explicit transaction, a statement-level ERROR requires ROLLBACK or ROLLBACK TO SAVEPOINT before continuing; an autocommit client can retry the corrected action. In the retained autocommit case the same backend remained IDLE after the error and repair.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6. The retained observation covers the named work_mem case on PostgreSQL 18.6 and 10.21.

22003, 22025

Sources

Representative built-in GUC conversion/range/check-hook paths are src/backend/utils/misc/guc.c#L3129-3320 and #L6804-6990, with unit tables at #L87-181 and setting-context handling at #L3342-3430, alongside contrib/amcheck/verify_heapam.c#L271-303, contrib/postgres_fdw/option.c#L149-185, and src/backend/utils/adt/regexp.c#L443-446. The structured evidence record retains exact messages, runtime digests, and owner-specific limits.

79 - 22024 — unterminated_c_string

Source-backed reference for PostgreSQL SQLSTATE 22024.

22024

At a glance

The catalogue condition names a C-style string that ended before its required terminator. The bounded PostgreSQL 18.6 source review confirms the definition but does not bind a native emitting report group.

Field Value
SQLSTATE 22024
Condition unterminated_c_string
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_UNTERMINATED_C_STRING
Aliases

Meaning

22024 describes an unterminated C-style string or escape sequence at the interface/parser layer, but the fixed source scope here does not identify which PostgreSQL component emits it. The condition name alone is insufficient to assign a SQL text, ECPG, client, primary message, or recovery path.

Diagnosis

Use the complete diagnostic and the parser or interface that produced it. Check where the quoted string or escape token should terminate and preserve the original input; do not infer that a client truncation or an arbitrary SQL quote problem necessarily maps to 22024.

Response

Terminate or re-encode the string at the owning parser boundary and follow that layer’s documented recovery. Because no emitter was resolved in this bounded review, transaction and severity behavior remain unknown here.

Versions

The locked catalogue records this condition from 7.4; only the PostgreSQL 18.6 definition and bounded source scope are confirmed. No natural runtime observation is claimed for this page.

22025, 22019

Sources

The fixed catalogue definition is recorded in the structured evidence record. Its bounded-scan claim deliberately leaves the native emitter, primary text, severity, and transaction behavior unknown; no natural runtime was run.

80 - 22025 — invalid_escape_sequence

Source-backed reference for PostgreSQL SQLSTATE 22025.

22025

At a glance

An escape sequence is invalid for its specific consumer. Fixed paths distinguish a LIKE escape argument that is not empty or one character, a LIKE pattern ending in an escape character, a regular-expression translation escape argument with the same length rule, and malformed \u/\U Unicode escapes.

Field Value
SQLSTATE 22025
Condition invalid_escape_sequence
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_ESCAPE_SEQUENCE
Aliases

Representative messages

The representative consumers use these primary texts and hint:

Consumer / guard Primary and hint
LIKE or SQL regular-expression translation escape length invalid escape string; HINT: Escape string must be empty or one character.
LIKE pattern with a trailing escape LIKE pattern must not end with escape character
malformed scanner Unicode escape invalid Unicode escape; HINT: Unicode escapes must be \uXXXX or \UXXXXXXXX.

Meaning

22025 is emitted by consumer-specific escape guards. LIKE requires its ESCAPE string to be empty or one character and rejects a pattern ending with the escape character. The SQL regular-expression translation helper applies the same empty-or-one-character rule to its escape argument. The core scanner reports malformed Unicode escape syntax with the \uXXXX/\UXXXXXXXX hint. These are distinct from 22019’s escape-character semantics and 2200C’s SIMILAR separator overflow; a regexp_replace option or start/occurrence parameter is a 22023 parameter-validation path instead.

Diagnosis

Identify the consumer before editing backslashes: LIKE escape argument, LIKE pattern, SQL regular-expression translation, or an extended string literal’s Unicode scanner. Check whether the escape value is an empty string or one character, whether the LIKE pattern ends after an escape, and whether a Unicode escape has exactly the required \u/\U width. Do not call every regular-expression replacement or SIMILAR syntax error 22025; use the SQLSTATE and primary message actually reported.

Response

Provide the escape string and pattern required by the named consumer, preserving an intentional empty string as empty rather than SQL NULL. For malformed Unicode syntax, use \uXXXX or \UXXXXXXXX as required by the scanner. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected statement.

Versions

The locked catalogue records this condition from 7.4; the fixed source paths here are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

22019, 2200C, 22023

Sources

LIKE guards are in src/backend/utils/adt/like_match.c#L159-165 and #L439-449; the SQL regular-expression translation escape-length guard is src/backend/utils/adt/regexp.c#L793-805; malformed Unicode escape syntax is in src/backend/parser/scan.l#L697-704. The structured evidence record retains the exact primaries, hint, and consumer boundaries; no natural runtime was run.

81 - 22026 — string_data_length_mismatch

Source-backed reference for PostgreSQL SQLSTATE 22026.

22026

At a glance

A bit-string value has the wrong declared length. The fixed varbit.c path reports bit string length %d does not match type bit(%d); bitwise operands have separate mismatch messages.

Field Value
SQLSTATE 22026
Condition string_data_length_mismatch
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_STRING_DATA_LENGTH_MISMATCH
Aliases

Messages

The fixed guards use these primary texts:

Guard Primary
bit(n) length mismatch bit string length %d does not match type bit(%d)
bit_and operands cannot AND bit strings of different sizes
bit_or operands cannot OR bit strings of different sizes
bitxor operands cannot XOR bit strings of different sizes

Meaning

22026 covers exact-length bit(n) boundaries and bitwise operations. The fixed bit() input path compares the actual bit length with the declared bit(n) length; an implicit conversion raises bit string length %d does not match type bit(%d), while an explicit bit(n) cast truncates or zero-pads. The varbit(n) path has a different contract: an implicit value that is too long uses 22001, and an explicit cast truncates to the maximum length. The AND, OR, and XOR functions separately compare both operand lengths and use 22026 when they differ.

Diagnosis

First identify whether the primary names a bit(n) typmod or a bitwise operator. For the typmod message, compare the source bit length with the target exact length and check whether the boundary is an implicit assignment/cast or an explicitly requested cast. For varbit(n) overlength, look for 22001 instead; for a bitwise message, inspect both operands. Character width and encoding failures belong to different SQLSTATE paths.

Response

Make an implicit bit(n) value exactly the declared length. Use an explicit cast only when its truncation or zero-padding is intended, and resize both operands before a bitwise operation when their lengths should agree. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected action.

Versions

The locked catalogue records this condition from 7.4; the fixed source paths here are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

22001, 22021

Sources

The exact-length guard is src/backend/utils/adt/varbit.c#L354-357; implicit versus explicit bit(n) and varbit(n) conversion is #L385-414 and #L736-765. The bitwise size guards are #L1257-1343. The structured evidence record retains the message roles and scope; no natural runtime was run.

82 - 22027 — trim_error

Source-backed reference for PostgreSQL SQLSTATE 22027.

22027

At a glance

The trim operation rejected its argument or trim specification. No fixed PostgreSQL 18.6 emitting path was resolved in the bounded scan.

Field Value
SQLSTATE 22027
Condition trim_error
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_TRIM_ERROR
Aliases

Meaning

The locked definition names trim_error, but the bounded PostgreSQL 18.6 source review did not resolve a native emitter for 22027. This page therefore records the condition identity and diagnostic boundary without assigning a particular SQL trim function, whitespace rule, or primary message.

Diagnosis

If a deployment reports 22027, preserve the complete primary, DETAIL, and HINT together with the invoking function or extension. The condition name alone cannot tell whether the rejected input is the source string, trim set, direction, or a consumer-specific option; do not substitute a guessed whitespace rule.

Response

Use the actual emitter’s diagnostic to correct the trim input or operation. If the source is an extension or a version-specific path, check that implementation’s documented argument rules. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected action.

Versions

The locked catalogue records this condition from 7.4. Only the PostgreSQL 18.6 definition row is fixed here; no native emitting path or natural runtime observation is claimed.

22026, 22025

Sources

The fixed definition row is src/backend/utils/errcodes.txt#L202. The bounded source review did not resolve a native 22027 emitter; the structured evidence record keeps that unknown scope explicit, and no natural runtime was run.

83 - 2202E — array_subscript_error

PostgreSQL uses SQLSTATE 2202E for array subscript and shape errors. Separate an out-of-bounds read that returns NULL from assignment, slice, constructor, and concatenation paths that validate array dimensions.

At a glance

2202E is PostgreSQL’s array_subscript_error condition in Class 22, Data Exception. The directory keeps ERRCODE_ARRAY_ELEMENT_ERROR as a compatibility alias and uses ERRCODE_ARRAY_SUBSCRIPT_ERROR for the named condition. Both macros encode the same SQLSTATE.

Do not treat every out-of-range-looking expression as an error. PostgreSQL documents that an array subscript read outside the current bounds returns NULL; a read with the wrong number of subscripts also returns NULL. Array slices have their own historical rules: a slice wholly outside the bounds can produce an empty zero-dimensional array, while a partially overlapping slice is reduced to the overlap.

2202E is raised when another path validates a shape or subscript and rejects it. In the core source this includes incompatible dimensions during array concatenation or construction, invalid slice boundaries, and some subscripted assignment checks. The operation matters as much as the index value.

The executable representative case is incompatible_array_dimensions. It passed on PostgreSQL 18.6 and 10.21. The case raises 2202E for an incompatible concatenation, then proves that the same autocommit connection is IDLE and can execute a valid follow-up concatenation. The SQL excerpt below is the complete ordered pair from the shared snippet registry; the runner remains the single owner of setup and cleanup.

Field Value
SQLSTATE 2202E
Condition array_subscript_error
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_ARRAY_ELEMENT_ERROR, ERRCODE_ARRAY_SUBSCRIPT_ERROR
Aliases ERRCODE_ARRAY_ELEMENT_ERROR

Meaning and trigger paths

The 18.6 directory row is 2202E E ERRCODE_ARRAY_SUBSCRIPT_ERROR array_subscript_error. The preceding alias row is 2202E E ERRCODE_ARRAY_ELEMENT_ERROR; the source comment explains that SQL99’s “array element error” is the subscript error. Code that still names the alias is therefore referring to this same SQLSTATE, not to a second condition.

An array has a rank, a length for each dimension, and lower bounds. PostgreSQL does not require every array to start at one, so diagnostics should inspect the actual bounds rather than assume them. The documented array_ndims, array_dims, array_lower, array_upper, and cardinality functions expose the metadata needed to do that. Use them in the same session when an error needs to be diagnosed; they are inspection tools, not evidence that a particular error was triggered.

The main core paths are:

  1. Array element or slice assignment. arrayfuncs.c validates subscripts and slice boundaries. One-dimensional arrays can be enlarged by assigning to a new element, with intervening positions filled by NULL; multidimensional enlargement is not supported. A slice assigned to an empty array must provide both boundaries. These rules mean that an assignment outside the current read bounds must be analyzed as an assignment operation, not inferred from SELECT a[n].
  2. Array concatenation. array_cat raises 2202E when equal-rank arrays have different lengths or lower bounds on a non-concatenated dimension. This is the path exercised by the representative case.
  3. Multidimensional construction. The expression evaluator raises the same condition when non-empty array expressions used to form a multidimensional array have incompatible dimensions.

The source tree contains other callers, including data-type helper paths. Class 22 is the broad data-exception class; the 2202E row and its source function identify when this particular shape or subscript contract failed.

Messages and diagnostics

The canonical executable excerpt is:

SELECT ARRAY[[1,2]] || ARRAY[[3]];
SELECT ARRAY[1,2] || ARRAY[3,4];

The first statement has two two-dimensional arrays whose inner dimensions differ. PostgreSQL 18.6 reports:

SQLSTATE: 2202E
severity: ERROR
message_primary: cannot concatenate incompatible arrays
message_detail: Arrays with differing element dimensions are not compatible for concatenation.
source: array_userfuncs.c / array_cat / line 450

The same case on PostgreSQL 10.21 reports the same primary and detail text, with the historical array_userfuncs.c source line 356. The second statement returns {1,2,3,4}. The message and detail are templates from the concatenation path, not a universal wording for every 2202E.

Other source-confirmed templates include array subscript out of range, array slice subscript must provide both boundaries with a detail explaining empty-array assignment, and upper bound cannot be less than lower bound. Preserve message_detail, message_hint, source_file, source_function, and source_line when the driver exposes them; they often distinguish a slice check from a concatenation check.

Diagnosis

Start by classifying the expression:

  • A plain element read such as a[999] can legitimately produce NULL. Check a IS NULL, the subscript expressions, and the stored bounds before calling it a server error.
  • A slice read can return NULL, an empty zero-dimensional array, or a reduced overlap according to the documented slice rules. Do not map those values to 2202E without an error response.
  • Assignment, array construction, and concatenation execute validation code. Record the array rank, dimensions, lower bounds, number of supplied subscripts, and whether the statement is changing the value.

For a real error, record SQLSTATE, severity, primary message, detail, hint, statement position, and the relation or function context. Compare the failing expression with array_ndims, array_dims, array_lower, and array_upper from the same value or source expression. For concatenation, compare every non-concatenated dimension and lower bound. For a slice, verify both boundaries and their order. For construction, inspect every subarray’s shape.

In PL/pgSQL, a handler can catch array_subscript_error or SQLSTATE '2202E', but the handler’s transaction behavior depends on the block. A block with an EXCEPTION clause runs its protected body in a subtransaction; if the body errors, persistent changes made there are rolled back before the handler runs. A broad OTHERS handler also has documented exclusions, so use a specific condition when the application intends to repair an array operation.

Response

Repair the operation that violated the shape contract. Normalize dimensions and lower bounds before concatenating; provide complete, ordered slice boundaries; use a one-dimensional expansion only when its NULL fill behavior is intended; or rebuild multidimensional values with matching subarrays. If NULL is a valid result of a read, handle it as a value and do not “fix” it with COALESCE before deciding whether the application should distinguish an absent element from a stored NULL element.

The representative error ran in autocommit. After the failed statement the connection was IDLE, and the valid concatenation succeeded. In an explicit transaction, an ERROR normally aborts the transaction until ROLLBACK or a rollback to a savepoint; the connection itself need not be closed. A PL/pgSQL block with an exception clause can contain the failure in its protected subtransaction body, rolling back that body’s changes before its handler runs. Verify the actual client transaction status rather than deriving connection fate from 2202E alone.

Versions

The catalogue records 2202E in the locked 7.4–8.4.22 pre-9.0 formal sources, every formal snapshot from 9.0.23 through 18.6, and the 19 Beta 3 preview. The same-tag REL8_1_4 errcodes.sgml table already lists 2202E as array_subscript_error, confirming that condition-name observation by 8.1.4. Candidate source gaps remain for 7.0–7.3, so the 7.4 observation is a presence boundary rather than an exact introduction version. The fixed 18.6 source commit is 724edf9bde9d356724ad384a2e196edc3c9f80f7; the alias and named macro are both present in its errcodes.txt row.

The incompatible-dimension case passed on PostgreSQL 18.6 and 10.21 with the same primary/detail wording and different source line numbers. That cross-version result does not guarantee unchanged wording for every older minor release or every other 2202E call path.

22000data_exception is the broad Class 22 category. 22005error_in_assignment is a distinct assignment condition and should not be substituted for an array-specific 2202E path. 22P02invalid_text_representation concerns input text parsing. 2202E also differs from a successful out-of-bounds read, which returns NULL under the documented array rules.

Sources

The structured evidence is recorded in the public evidence JSON. Source records are pinned to PostgreSQL commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; runtime records retain the shared snippet registry, both target versions, and run 2202E-snippet-registry-final-20260909.

84 - 2202G — invalid_tablesample_repeat

Source-backed reference for PostgreSQL SQLSTATE 2202G.

2202G

At a glance

The TABLESAMPLE REPEATABLE seed is invalid when it is NULL. The fixed executor path reports TABLESAMPLE REPEATABLE parameter cannot be null.

Field Value
SQLSTATE 2202G
Condition invalid_tablesample_repeat
Status active
Known present by 9.5.0
Locked snapshots 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_TABLESAMPLE_REPEAT
Aliases

Messages

The executor guard uses this primary text:

Guard Primary
NULL REPEATABLE expression TABLESAMPLE REPEATABLE parameter cannot be null

Meaning

During tablesample_init, PostgreSQL evaluates each TABLESAMPLE method argument first and reports 2202H when one is NULL. It then evaluates the optional REPEATABLE expression separately; a NULL result takes the 2202G branch. A non-NULL REPEATABLE value has already been coerced to float8 by the parser and is hashed with hashfloat8 to make the sampling seed. This code therefore covers the repeat-seed NULL contract, not a negative seed or a method percentage range.

Diagnosis

Inspect the evaluated REPEATABLE expression, including a parameter or function that may become SQL NULL. Keep it separate from a NULL TABLESAMPLE method argument, which uses 2202H, and from a non-NULL but invalid percentage, size, or time argument, which is checked by the selected sampling method. The primary text identifies the repeat-seed branch.

Response

Supply a non-NULL expression to REPEATABLE, or omit the clause when deterministic repetition is not required. Correct the method argument separately if its own 2202H guard fires. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected statement.

Versions

The locked catalogue records this condition from 9.5.0; the fixed source path here is PostgreSQL 18.6. No natural runtime observation is claimed for this page.

2202H, 22004

Sources

The executor evaluates method arguments and then the optional repeat expression in src/backend/executor/nodeSamplescan.c#L232-267. The structured evidence record retains the 2202G guard and its boundary with 2202H; no natural runtime was run.

85 - 2202H — invalid_tablesample_argument

Source-backed reference for PostgreSQL SQLSTATE 2202H.

2202H

At a glance

A TABLESAMPLE method received an invalid argument. Fixed core and contrib methods reject out-of-range percentages or negative sample sizes with method-specific messages.

Field Value
SQLSTATE 2202H
Condition invalid_tablesample_argument
Status active
Known present by 9.5.0
Locked snapshots 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_TABLESAMPLE_ARGUMENT
Aliases

Messages

The fixed executor and sampling methods use these primary texts:

Owner / guard Primary
NULL method argument TABLESAMPLE parameter cannot be null
Bernoulli/system percentage, including NaN sample percentage must be between 0 and 100
system_rows negative size sample size must not be negative
system_time negative or NaN time sample collection time must not be negative

Meaning

2202H is a method-argument code, not one universal TABLESAMPLE range. The executor rejects a NULL method argument before calling the method. Core Bernoulli and system methods accept percentages from 0 through 100 inclusive and reject NaN. The system_rows contrib method rejects only a negative requested row count, so zero is allowed; system_time rejects negative or NaN collection time, so zero is allowed; the shown guard does not impose a finite upper bound, and positive Infinity is not rejected by that comparison itself. REPEATABLE NULL is the separate 2202G branch, and other sampling extensions may define their own argument guards.

Diagnosis

Identify the sampling method and parameter position before changing the value. A NULL method argument points to the executor guard; a Bernoulli/system percentage outside 0..100 or NaN points to the core method; negative system_rows size and negative/NaN system_time are contrib-specific; positive Infinity is not classified by that shown guard. Read the primary text to distinguish these from a NULL REPEATABLE seed (2202G).

Response

Use a non-NULL method argument, a finite percentage in the inclusive 0..100 range, a non-negative row count, or a non-negative finite collection time according to the selected method. Do not repair a 2202G repeat-seed error by changing the method percentage. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected statement.

Versions

The locked catalogue records this condition from 9.5.0; the fixed core and contrib source paths here are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

2202G, 22023

Sources

The executor NULL guard is src/backend/executor/nodeSamplescan.c#L232-245. Core percentage guards are src/backend/access/tablesample/bernoulli.c#L137-149 and src/backend/access/tablesample/system.c#L140-152. Contrib bounds are contrib/tsm_system_rows/tsm_system_rows.c#L178-187 and contrib/tsm_system_time/tsm_system_time.c#L193-203. The structured evidence record retains the method-specific messages and limits; no natural runtime was run.

86 - 22030 — duplicate_json_object_key_value

Source-backed reference for PostgreSQL SQLSTATE 22030.

22030

At a glance

A JSON object construction encountered a duplicate key. The fixed unique-key JSON builder and aggregate paths report duplicate JSON object key value: %s; JSONB finalization has a related variant.

Field Value
SQLSTATE 22030
Condition duplicate_json_object_key_value
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DUPLICATE_JSON_OBJECT_KEY_VALUE
Aliases

Messages

The unique-key paths use these primary texts:

Path Primary
JSON builder or aggregate with unique keys duplicate JSON object key value: %s
JSONB object finalization or unique-key validation duplicate JSON object key value

Meaning

22030 is raised when a JSON object operation has explicitly enabled key uniqueness and sees the same key twice in one object. The JSON builders and object aggregates carry a unique_keys flag; their unique variants record keys and raise at insertion or object finalization. Ordinary json/jsonb input uses the flag as false, and ordinary builders or aggregates do not turn every duplicate in input text into 22030. Strict or absent-on-null variants omit NULL-valued fields from output, but the unique variants retain the key long enough to check it, so a duplicate key can still fail even when its value would be skipped. A NULL key itself is a separate argument error.

Diagnosis

Identify the constructor or aggregate and whether its documented form enforces unique keys. The %s primary names the duplicate key for the JSON builder/aggregate path; the JSONB finalization and validation path uses the shorter primary. Distinguish a duplicate-key policy from invalid JSON syntax, a NULL object key, or ordinary json/jsonb parsing that permits duplicate input under its normal semantics.

Response

Apply the owner’s duplicate-key policy: de-duplicate or aggregate upstream values when uniqueness is required, or use a documented non-unique operation only when retaining the operation’s duplicate-key semantics is intentional. Do not solve a NULL key or malformed JSON error by changing the uniqueness flag. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected action.

Versions

The locked catalogue records this condition from 12.0; the fixed JSON and JSONB source paths here are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

22032, 22023

Sources

JSON unique-key builders and aggregates are src/backend/utils/adt/json.c#L1002-1127 and #L1224-1295; JSON uniqueness validation is #L1810-1853. JSONB ordinary input leaves uniqueness disabled in src/backend/utils/adt/jsonb.c#L74-102, while unique builders and finalization are #L1125-1163 and src/backend/utils/adt/jsonb_util.c#L1952-2005. The structured evidence record retains the unique-key and NULL-skipping boundaries; no natural runtime was run.

87 - 22031 — invalid_argument_for_sql_json_datetime_function

Source-backed reference for PostgreSQL SQLSTATE 22031.

22031

At a glance

A SQL/JSON datetime method received an invalid type, precision, or format. Fixed jsonpath execution reports an unrecognized format and hints to use a datetime template argument.

Field Value
SQLSTATE 22031
Condition invalid_argument_for_sql_json_datetime_function
Status active
Known present by 13.0
Locked snapshots 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION
Aliases

Messages

The datetime-method guards use these primary texts:

Guard Primary and hint
non-string item jsonpath item method .%s() can only be applied to a string
.datetime() format not recognized %s format is not recognized: "%s"; HINT: Use a datetime template argument to specify the input data format.
precision outside integer range time precision of jsonpath item method .%s() is out of range for type integer
invalid adjusted precision time precision of jsonpath item method .%s() is invalid

Meaning

The fixed executeDateTimeMethod path first requires a scalar string. .datetime(template) passes the explicit template to parse_datetime: when jspThrowErrors(cxt) is false, its ErrorSaveContext turns a parse failure into jperError; when throwing is enabled, the parser receives no save context and may throw its underlying error. The no-template .datetime(), .date(), .time(), .time_tz(), .timestamp(), and .timestamp_tz() paths try their enumerated ISO formats, saving each candidate failure in ErrorSaveContext even on a throwing execution; only after every candidate fails does the final 22031 RETURN_ERROR branch decide whether to throw or return jperError. Optional time precision is converted to an integer and checked before adjustment. A missing format, incompatible conversion, non-string item, or invalid precision uses 22031.

Diagnosis

Record the method name, input JSON item type, datetime text, template text if present, and precision argument. The .datetime() no-format match has the HINT to provide a template; the other methods use fixed ISO candidates and have no such template hint. Separate a scalar type mismatch from a format failure and from precision range/adjustment errors. lax controls structural auto-wrap/unwrap and structural-error handling; it does not generally suppress datetime parse or conversion errors. Check the executor’s throwErrors/RETURN_ERROR path and the jsonb_path_* function’s silent parameter or SQL/JSON ON ERROR clause to determine whether a saved parse error was returned or raised.

Response

Pass a string item to the method, use a template matching the datetime text for .datetime(), or choose the method whose ISO type matches the input. Keep precision within the integer and datetime typmod rules. If a non-ERROR ON ERROR behavior intentionally handles parse failure, repair or retain that behavior according to the application contract; otherwise correct the input or template. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected expression.

Versions

The locked catalogue records this condition from 13.0; the fixed SQL/JSON datetime source path here is PostgreSQL 18.6. No natural runtime observation is claimed for this page.

22007, 22018

Sources

The datetime method is src/backend/utils/adt/jsonpath_exec.c#L2326-2780, including string/type checks, explicit-template and ISO candidate parsing, ErrorSaveContext, conversions, and precision guards. The strict/lax/throw split is defined by #L235-249 and #L654-727. The structured evidence record retains the exact primary and hint roles; no natural runtime was run.

88 - 22032 — invalid_json_text

Source-backed reference for PostgreSQL SQLSTATE 22032.

22032

At a glance

JSON text is invalid for the consuming operation. No fixed 18.6 emitting report group was resolved in the bounded scan.

Field Value
SQLSTATE 22032
Condition invalid_json_text
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_JSON_TEXT
Aliases

Meaning

The locked definition names invalid_json_text, but the bounded PostgreSQL 18.6 source review did not resolve a native emitting report group for this code. This page therefore does not assign a parser function, primary text, DETAIL, HINT, severity path, or SQL/JSON mode from the condition name alone.

Diagnosis

If 22032 appears, preserve the complete diagnostic and the consuming operation, including whether the input was json, jsonb, SQL/JSON, or an extension value. Validate the exact text and encoding at that boundary, but do not replace the unknown emitter with a guessed ordinary cast or client path. Related JSON cardinality codes have their own fixed guards.

Response

Use the actual emitter’s primary, DETAIL, and HINT to repair the JSON text or its boundary. If the operation is in an explicit transaction and raises ERROR, roll back or roll back to the existing savepoint before retrying; autocommit can retry corrected input. This recovery guidance is general and is not a 22032 runtime observation.

Versions

The locked catalogue records this condition from 12.0. Only the PostgreSQL 18.6 definition row is fixed here; no native emitting path or natural runtime observation is claimed.

22030, 22033

Sources

The fixed definition row is src/backend/utils/errcodes.txt#L217. The bounded source review did not resolve a native 22032 emitter; the structured evidence record keeps that unknown scope explicit, and no natural runtime was run.

89 - 22033 — invalid_sql_json_subscript

Source-backed reference for PostgreSQL SQLSTATE 22033.

22033

At a glance

A SQL/JSON array subscript is invalid. Fixed jsonpath paths distinguish out-of-bounds, non-single-numeric, and integer-range variants.

Field Value
SQLSTATE 22033
Condition invalid_sql_json_subscript
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_SQL_JSON_SUBSCRIPT
Aliases

Messages

The fixed subscript guards use these primary texts:

Guard Primary
subscript is not one numeric item jsonpath array subscript is not a single numeric value
numeric subscript outside int32 jsonpath array subscript is out of integer range
strict array bound failure jsonpath array subscript is out of bounds

Meaning

The jsonpath executor evaluates each subscript expression as a result list. getArrayIndex requires exactly one numeric scalar, truncates it to an integer, and reports 22033 when the result is not a single numeric item or cannot fit the integer range. The later array-bound guard reports the same code for a negative start, reversed range, or upper bound past the array in strict mode. Lax mode ignores that structural out-of-bounds error and clamps the range to the available array; it does not turn a non-numeric or overflowing subscript into a valid index.

Diagnosis

Inspect the subscript expression’s cardinality and type before inspecting array length. A path that yields multiple items, a non-numeric value, or an integer overflow uses the conversion messages; a numeric index or range that violates strict array bounds uses the out-of-bounds message. Record whether the path is strict or lax, because lax structural handling can produce an empty or clamped result instead of this ERROR. A later no-item behavior is 22035 when its SQL/JSON operation chooses to raise it.

Response

Make the subscript expression return one finite numeric value in the integer range, and keep strict-mode bounds within the target array with a non-reversed range. If lax clamping or an empty result is intended, confirm that the path mode and surrounding SQL/JSON behavior express that intent. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected expression.

Versions

The locked catalogue records this condition from 12.0; the fixed jsonpath source paths here are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

22034, 22035

Sources

Array-bound handling is src/backend/utils/adt/jsonpath_exec.c#L892-929. Subscript cardinality, truncation, and integer conversion are #L3442-3477. The structured evidence record retains all three 22033 guard roles; no natural runtime was run.

90 - 22034 — more_than_one_sql_json_item

Source-backed reference for PostgreSQL SQLSTATE 22034.

22034

At a glance

A SQL/JSON query returned more than one item where the operation requires one. Fixed JSON_QUERY/JSON_VALUE paths report single-item or single-scalar requirements and may hint to use WITH WRAPPER.

Field Value
SQLSTATE 22034
Condition more_than_one_sql_json_item
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM
Aliases

Messages

The no-wrapper cardinality guards use these primary texts:

Operation Primary and hint
JSON_QUERY column without wrapper JSON path expression for column "%s" must return single item when no wrapper is requested; HINT: Use the WITH WRAPPER clause to wrap SQL/JSON items into an array.
JSON_QUERY without a column name JSON path expression in JSON_QUERY must return single item when no wrapper is requested; HINT: Use the WITH WRAPPER clause to wrap SQL/JSON items into an array.
JSON_VALUE with more than one item JSON path expression in JSON_VALUE must return single scalar item

Meaning

The fixed JSON_QUERY path collects the complete SQL/JSON result list and counts it before applying the wrapper mode. Without a wrapper, more than one item raises 22034; unconditional or conditional WITH WRAPPER turns the sequence into an array according to its mode. JSON_VALUE uses the same code when more than one item is returned, because it requires one scalar. Exactly one non-scalar item is a separate 2203F condition, and zero items set the empty flag for ON EMPTY handling. Lax auto-unwrapping can change the result cardinality; silent or non-ERROR ON ERROR behavior can suppress an evaluation error before the cardinality guard is reported.

Diagnosis

Record the operation (JSON_QUERY or JSON_VALUE), wrapper clause, column name, and number of items produced by the path. For JSON_QUERY, use WITH WRAPPER only when an array result is intended; for JSON_VALUE, reduce the path to one scalar rather than wrapping. Distinguish multiple items (22034), one non-scalar item (2203F), and no items handled by ON EMPTY/22035. Check strict/lax and silent settings because they affect the sequence seen by this guard.

Response

Change the path or filter to return one required item, or add the documented wrapper when the consumer expects an array. For JSON_VALUE, also ensure the one item is scalar. If the operation uses an ON ERROR behavior, keep its fallback consistent with the intended cardinality rather than treating NULL as proof that the path returned one item. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected expression.

Versions

The locked catalogue records this condition from 12.0; the fixed SQL/JSON cardinality paths here are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

22033, 22035

Sources

JSON_QUERY wrapper and multi-item guards are src/backend/utils/adt/jsonpath_exec.c#L3880-4005. JSON_VALUE’s multiple-item and scalar distinction is #L4008-4070. The structured evidence record retains the wrapper, cardinality, and hint roles; no natural runtime was run.

91 - 22035 — no_sql_json_item

Source-backed reference for PostgreSQL SQLSTATE 22035.

22035

At a glance

A SQL/JSON path found no item for the requested operation. Fixed expression execution reports no SQL/JSON item found for specified path.

Field Value
SQLSTATE 22035
Condition no_sql_json_item
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NO_SQL_JSON_ITEM
Aliases

Messages

The ERROR behavior uses these primary texts:

Context Primary
named JSON_TABLE/SQL/JSON column no SQL/JSON item found for specified path of column "%s"
no column name no SQL/JSON item found for specified path

Meaning

A JSON path can produce an empty result without immediately throwing. JsonPathQuery and JsonPathValue mark zero matches as empty; the SQL/JSON expression executor then applies ON EMPTY, or uses a non-ERROR ON ERROR behavior when no separate ON EMPTY behavior is supplied. Only when the effective behavior is ERROR does the executor emit 22035, with a column-aware or column-less primary. Helper functions such as jsonb_path_query_first can return NULL for no match directly, so 22035 is not a blanket synonym for every empty path result.

Diagnosis

Record the operation, path, column name, and its ON EMPTY/ON ERROR clauses. Distinguish an expected NULL/default fallback from an ERROR behavior that reaches 22035. Strict versus lax path evaluation and silent mode can change whether structural problems become an empty result or a suppressed evaluation error; multiple results and invalid subscripts use 22034 and 22033 instead.

Response

If an item is required, correct the path, input document, or column mapping. If no match is valid, use the documented ON EMPTY behavior or a helper whose no-match result is intentionally NULL/empty. Do not add a wrapper to solve a no-item condition; wrappers address multiple-item cardinality. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected expression.

Versions

The locked catalogue records this condition from 12.0; the fixed SQL/JSON executor path here is PostgreSQL 18.6. No natural runtime observation is claimed for this page.

22033, 22034

Sources

JSON path helpers mark empty results in src/backend/utils/adt/jsonpath_exec.c#L3880-4070. SQL/JSON ON EMPTY/ON ERROR handling and the two 22035 primaries are in src/backend/executor/execExprInterp.c#L4940-5080. The structured evidence record retains the empty-result and behavior boundary; no natural runtime was run.

92 - 22036 — non_numeric_sql_json_item

Source-backed reference for PostgreSQL SQLSTATE 22036.

22036

At a glance

A JSON path item method received a value that cannot satisfy its numeric or conversion contract. The fixed paths cover .number(), .decimal(), .integer(), .bigint(), .double(), .boolean(), .abs(), .floor(), .ceiling(), and the corresponding type checks in .string().

Field Value
SQLSTATE 22036
Condition non_numeric_sql_json_item
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NON_NUMERIC_SQL_JSON_ITEM
Aliases

Messages

Representative primary texts from the fixed jsonpath methods are:

Guard Primary
.abs(), .floor(), or .ceiling() receives a non-numeric item jsonpath item method .%s() can only be applied to a numeric value
A conversion method receives neither a string nor numeric item jsonpath item method .%s() can only be applied to a string or numeric value
.boolean() receives an unsupported item jsonpath item method .%s() can only be applied to a boolean, string, or numeric value
A string or numeric value cannot be converted to the target type argument "%s" of jsonpath item method .%s() is invalid for type %s
Numeric conversion produces NaN or Infinity NaN or Infinity is not allowed for jsonpath item method .%s()
.string() receives an unsupported item jsonpath item method .%s() can only be applied to a boolean, string, numeric, or datetime value

Meaning

The jsonpath executor dispatches each item method according to its input type. String inputs for .integer(), .bigint(), .double(), and the string side of .number()/.decimal() use their target input or numeric parser with an ErrorSaveContext or explicit error flag. Existing numeric items take method-specific paths: .number() can keep the numeric value, .integer() and .bigint() use numeric_int4_opt_error/numeric_int8_opt_error, and .decimal() applies its precision/scale typmod. .boolean() accepts a boolean directly, converts numeric input through int4in, and parses strings with parse_bool; .abs(), .floor(), and .ceiling() require a numeric scalar. Numeric and double paths reject NaN or Infinity. .string() has a wider contract and accepts boolean, string, numeric, or datetime items; arrays can be unwrapped only when the path mode permits it.

Diagnosis

Read the method name, item type, and value in the primary. Separate string parsing from an existing numeric item: .number() can pass an existing numeric through, .integer()/.bigint() use numeric range checks, .decimal() may apply precision/scale typmod, and .boolean() has direct, numeric, and parse_bool branches. An object, array, or unsupported item is an item-type case. Remove or guard non-finite numeric values where the method rejects them. Do not assign every lower-level precision/scale diagnostic from make_numeric_typmod_safe to 22036; keep only the shown jsonpath error branches in scope. Keep this condition separate from 2203B, which is the unary arithmetic operand check, and from 22031, which covers JSON path datetime methods.

Response

Change the path to select the intended scalar, normalize the document before conversion, or use a method whose input contract matches the value. Validate numeric text and finite values before invoking the method when the source can vary. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected action.

Versions

The locked catalogue records this condition from 12.0; the fixed conversion and item-method paths are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

2203B, 22031, 22038

Sources

The numeric item-method checks are jsonpath_exec.c#L1129-1588, the .string() type contract is #L1592-1647, and numeric-only methods are #L2280-2310. The strict/lax and throw-return macros are #L235-249. The structured evidence record binds these guards and messages; no natural runtime was run.

93 - 22037 — non_unique_keys_in_a_json_object

Source-backed reference for PostgreSQL SQLSTATE 22037.

22037

At a glance

The locked condition names a non-unique-key error for a JSON object. No fixed PostgreSQL 18.6 emitting path was resolved in the bounded scan.

Field Value
SQLSTATE 22037
Condition non_unique_keys_in_a_json_object
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NON_UNIQUE_KEYS_IN_A_JSON_OBJECT
Aliases

Meaning

The definition identifies non_unique_keys_in_a_json_object, but the bounded PostgreSQL 18.6 source review did not resolve a native 22037 emitter. This page therefore records the condition identity and diagnostic boundary without assigning a SQL/JSON constructor, parser, primary text, DETAIL, or HINT.

Diagnosis

If a deployment reports 22037, keep the complete primary, DETAIL, HINT, invoking SQL/JSON operation, and version together. Use that context to determine which object and duplicate-key policy emitted the condition; do not replace it with the related 22030 duplicate-key construction path.

Response

Follow the actual emitter’s duplicate-key policy: normalize or reject repeated keys according to that operation’s documented rule. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected action.

Versions

The locked catalogue records this condition from 12.0. Only the PostgreSQL 18.6 definition row is fixed here; no native emitting path or natural runtime observation is claimed.

22030, 22032, 2203A

Sources

The fixed definition row is errcodes.txt#L222. The bounded source review did not resolve a native 22037 emitting path; the structured evidence record keeps that unknown scope explicit, and no natural runtime was run.

94 - 22038 — singleton_sql_json_item_required

Source-backed reference for PostgreSQL SQLSTATE 22038.

22038

At a glance

A SQL/JSON path operation expected one result of a required type, but received another cardinality or type. The fixed paths cover a singleton boolean result and the two numeric operands of binary jsonpath arithmetic; the SQL function and the @@ operator have different default silent behavior.

Field Value
SQLSTATE 22038
Condition singleton_sql_json_item_required
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED
Aliases

Messages

Representative primary texts are:

Guard Primary
Non-singleton or non-boolean jsonb_path_match result in throwing mode single boolean result is expected
Left binary arithmetic operand is not one numeric item left operand of jsonpath operator %s is not a single numeric value
Right binary arithmetic operand is not one numeric item right operand of jsonpath operator %s is not a single numeric value

Meaning

jsonb_path_match_internal treats exactly two C arguments as the @@ operator path: jsonb_path_match_opr leaves silent=true, so a non-singleton or non-boolean result becomes NULL. The SQL function is declared as jsonb_path_match(target, path, vars DEFAULT '{}', silent DEFAULT false); even a call written with two SQL arguments is expanded with both defaults, so it is non-silent and can raise 22038 unless the caller supplies silent=true. A four-argument call follows its supplied silent value. A single JSON null returns SQL NULL. Binary arithmetic separately evaluates each operand sequence, and both sides must contain exactly one numeric item. The shared evaluator may unwrap arrays in lax mode before this singleton check.

Diagnosis

Identify whether the syntax is the @@ operator or the jsonb_path_match function, and inspect the actual argument/default expansion before interpreting a NULL result. A path that yields several values, a non-boolean match result, or a left/right item that is not numeric belongs to this singleton/type boundary. Distinguish it from 22034 JSON_QUERY/JSON_VALUE cardinality, 2203F scalar-type enforcement, and 22036 numeric item-method conversion.

Response

Narrow the path or select one item explicitly. For binary arithmetic, make both operands resolve to one numeric item. Choose @@ when its suppressing behavior is intended, or call jsonb_path_match(..., false) when a mismatch should remain an ERROR; use silent=true only when NULL is the intended result. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected action.

Versions

The locked catalogue records this condition from 12.0; the fixed match and binary-arithmetic paths are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

22034, 2203F, 22036

Sources

The match wrapper and singleton guard are jsonpath_exec.c#L453-491; binary arithmetic singleton checks are #L2087-2155; the shared strict/lax and throw-return macros are #L235-249. The SQL defaults are fixed in system_functions.sql#L539-544, the direct function and @@ implementation signatures in pg_proc.dat#L10520-10522 and #L10547-10549, and the operator binding in pg_operator.dat#L3262-3264. The structured evidence record keeps both paths and exact primaries; no natural runtime was run.

95 - 22039 — sql_json_array_not_found

Source-backed reference for PostgreSQL SQLSTATE 22039.

22039

At a glance

An array-only JSON path accessor or item method reached a non-array item without permitted auto-wrap or structural-error suppression. Fixed wildcard, indexed, and .size() paths expose separate array-type primaries; an out-of-bounds subscript is 22033.

Field Value
SQLSTATE 22039
Condition sql_json_array_not_found
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SQL_JSON_ARRAY_NOT_FOUND
Aliases

Messages

Representative primary texts are:

Guard Primary
Wildcard array accessor receives a non-array jsonpath wildcard array accessor can only be applied to an array
Indexed array accessor receives a non-array jsonpath array accessor can only be applied to an array
.size() receives a non-array without permitted auto-wrap jsonpath item method .%s() can only be applied to an array

Meaning

The jpiAnyArray wildcard, jpiIndexArray indexed accessor, and .size() item-method branches can each auto-wrap a non-array item when jspAutoWrap(cxt) is enabled by lax mode. If auto-wrap is not permitted, jspIgnoreStructuralErrors can suppress the structural mismatch; when neither applies, the corresponding array-only branch reports 22039. A valid array with an invalid index reaches the separate 22033 subscript guard, so 22039 does not mean an empty array or an out-of-range index.

Diagnosis

Use the exact accessor or method named in the primary and inspect the item returned immediately before it. Separate a scalar/object input from a valid array whose index is outside its bounds, and check whether lax structural-error handling or auto-wrap/unwrap is part of the SQL/JSON path mode.

Response

Make the path select an array, normalize the input shape, or choose a scalar-compatible operation. If variable documents are expected, handle the scalar/array branch explicitly instead of relying on a structural mismatch to become an empty result. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected action.

Versions

The locked catalogue records this condition from 12.0; the fixed array accessor and .size() guards are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

2203C, 2203A, 22033

Sources

The wildcard, indexed, and auto-wrap checks are jsonpath_exec.c#L836-979; the .size() array check is #L1101-1117. The strict/lax structural and throw-return macros are #L235-249. The structured evidence record binds the exact array messages and 22033 boundary; no natural runtime was run.

96 - 2203A — sql_json_member_not_found

Source-backed reference for PostgreSQL SQLSTATE 2203A.

2203A

At a glance

A named JSON object member cannot be read from the current item. Fixed jsonpath member access distinguishes a missing key from a non-object receiver.

Field Value
SQLSTATE 2203A
Condition sql_json_member_not_found
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SQL_JSON_MEMBER_NOT_FOUND
Aliases

Messages

Representative primary texts are:

Guard Primary
Named key is absent from an object JSON object does not contain key "%s"
Member accessor receives a non-object jsonpath member accessor can only be applied to an object

Meaning

The jpiKey branch searches the current JSON object for the requested key. A missing key raises 2203A in a throwing context; a scalar or other non-object receiver uses the same SQLSTATE with the object-type primary. If structural errors are ignored, the mismatch can be skipped, and if the context is non-throwing the path returns an error result for its caller to handle. This is the named-member boundary; wildcard member access and .keyvalue() use the object-only 2203C path.

Diagnosis

Keep the requested key, the item immediately before the member accessor, and the path mode. A missing key may reflect document shape, while a non-object receiver means the path reached the wrong type. Do not turn a missing member into 22035 no-item or a wildcard/object-method mismatch into 2203C without reading the primary.

Response

Correct the key or normalize/branch on the document shape. Use the path’s documented lax or error behavior only when a missing member is an intended input case. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected action.

Versions

The locked catalogue records this condition from 12.0; the fixed named-member guards are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

22039, 2203C, 22035

Sources

The fixed named-member lookup, missing-key, non-object, and structural-error branches are jsonpath_exec.c#L1012-1055. The shared strict/lax and throw-return macros are jsonpath_exec.c#L235-249. The structured evidence record binds both exact primaries; no natural runtime was run.

97 - 2203B — sql_json_number_not_found

Source-backed reference for PostgreSQL SQLSTATE 2203B.

2203B

At a glance

A unary jsonpath arithmetic operator needs a numeric operand but receives another item type. This is the unary-operator boundary, separate from numeric conversion methods.

Field Value
SQLSTATE 2203B
Condition sql_json_number_not_found
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SQL_JSON_NUMBER_NOT_FOUND
Aliases

Messages

The fixed unary branch reports:

operand of unary jsonpath operator %s is not a numeric value

Meaning

executeUnaryArithmExpr walks the operand sequence and accepts every numeric scalar item, applying the unary function to each. A non-numeric item is skipped only when both !found and !hasNext hold: that is a terminal existence-style evaluation that is not collecting results. Otherwise the 2203B guard is reached, including ordinary result collection at a terminal step. The evaluator may unwrap an array in lax mode. Numeric item methods such as .number() or .integer() use 22036 instead.

Diagnosis

Read the operator name and the full item sequence immediately before the unary operator. Check which items are numeric, whether lax unwrapping changed the sequence, and whether the caller is collecting results or only testing existence at a terminal step. Do not interpret this as an out-of-range numeric value or as a failed numeric conversion method.

Response

Constrain the path to the intended numeric sequence, normalize each JSON value, or choose an operation that accepts the actual type. Treat the terminal existence/no-collection optimization as a separate documented behavior; ordinary result collection still requires every processed item to be numeric. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected action.

Versions

The locked catalogue records this condition from 12.0; the fixed unary arithmetic branch is PostgreSQL 18.6. No natural runtime observation is claimed for this page.

22036, 22038, 22012

Sources

The complete unary arithmetic sequence and non-numeric guard are jsonpath_exec.c#L2158-2221. The shared strict/lax and throw-return macros are jsonpath_exec.c#L235-249. The structured evidence record binds the operator primary and terminal-path boundary; no natural runtime was run.

98 - 2203C — sql_json_object_not_found

Source-backed reference for PostgreSQL SQLSTATE 2203C.

2203C

At a glance

An object-only JSON path accessor or .keyvalue() method received a non-object item. Wildcard member access and object key/value expansion use this structural guard.

Field Value
SQLSTATE 2203C
Condition sql_json_object_not_found
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SQL_JSON_OBJECT_NOT_FOUND
Aliases

Messages

Representative primary texts are:

Guard Primary
Wildcard member accessor receives a non-object jsonpath wildcard member accessor can only be applied to an object
.keyvalue() receives a non-object jsonpath item method .%s() can only be applied to an object

Meaning

The wildcard member branch accepts a JSON object; its non-object structural mismatch can be ignored when jspIgnoreStructuralErrors is true, and an array may be auto-unwrapped in lax mode. .keyvalue() may likewise auto-unwrap an array before it requires an object container, but its direct non-object guard uses RETURN_ERROR: throwing versus returning jperError follows jspThrowErrors, as selected by the caller’s silent or ON ERROR handling. Lax mode itself does not suppress this direct .keyvalue() guard. Named member access with a missing key is 2203A, while array-only access is 22039.

Diagnosis

Use the primary to identify the wildcard accessor or item method, then inspect the current item type. Distinguish an object receiver that lacks a named key from a scalar/array receiver that cannot support object expansion. Check lax auto-unwrap and structural-error handling before treating the result as a missing item.

Response

Select an object, normalize the input shape, or branch before applying the object-only operation. For wildcard access, use lax structural suppression only when dropping a non-object branch is intended. For .keyvalue(), lax can only unwrap an array first; a remaining non-object follows the direct throw/silent/ON ERROR path, so do not assume lax suppression will ignore it. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected action.

Versions

The locked catalogue records this condition from 12.0; the fixed object-only accessor and .keyvalue() guards are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

22039, 2203A, 22037

Sources

The wildcard member guard is jsonpath_exec.c#L852-874, and .keyvalue() checks its object container at #L2806-2828. The shared strict/lax and throw-return macros are jsonpath_exec.c#L235-249. The structured evidence record binds both object-only primaries; no natural runtime was run.

99 - 2203D — too_many_json_array_elements

Source-backed reference for PostgreSQL SQLSTATE 2203D.

2203D

At a glance

The locked condition names an excessive number of JSON array elements. No fixed PostgreSQL 18.6 emitting path was resolved in the bounded scan.

Field Value
SQLSTATE 2203D
Condition too_many_json_array_elements
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_TOO_MANY_JSON_ARRAY_ELEMENTS
Aliases

Meaning

The definition identifies too_many_json_array_elements, but the bounded PostgreSQL 18.6 source review did not resolve a native 2203D emitter. This page records the condition identity and cardinality boundary without assigning a JSON_TABLE/SQL/JSON wrapper, primary text, DETAIL, or HINT.

Diagnosis

Preserve the complete diagnostic and identify the actual emitting component and its element-count rule. Confirm from that operation whether it permits one item, multiple elements, or another documented cardinality; the condition name alone does not establish that a wrapper or aggregate exists or would repair it.

Response

After identifying the actual emitter, follow that component’s documented element-count rule and correct the input or cardinality accordingly. Do not presume that a wrapper or aggregate is available or that either would resolve this condition. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected action.

Versions

The locked catalogue records this condition from 12.0. Only the PostgreSQL 18.6 definition row is fixed here; no native emitting path or natural runtime observation is claimed.

22034, 22035, 2203E

Sources

The fixed definition row is errcodes.txt#L228. The bounded source review did not resolve a native 2203D emitting path; the structured evidence record keeps that unknown scope explicit, and no natural runtime was run.

100 - 2203E — too_many_json_object_members

Source-backed reference for PostgreSQL SQLSTATE 2203E.

2203E

At a glance

The locked condition names an excessive number of JSON object members. No fixed PostgreSQL 18.6 emitting path was resolved in the bounded scan.

Field Value
SQLSTATE 2203E
Condition too_many_json_object_members
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_TOO_MANY_JSON_OBJECT_MEMBERS
Aliases

Meaning

The definition identifies too_many_json_object_members, but the bounded PostgreSQL 18.6 source review did not resolve a native 2203E emitter. This page records the condition identity and object-cardinality boundary without assigning a JSON_TABLE/SQL/JSON constructor, primary text, DETAIL, or HINT.

Diagnosis

Preserve the complete diagnostic and identify the actual emitting component and its object-member count rule. Confirm from that operation whether it permits the observed number of members or has another documented cardinality; the condition name alone does not establish that a wrapper or aggregate exists or would repair it. Do not infer a generic duplicate-key condition.

Response

After identifying the actual emitter, follow that component’s documented object-member count rule and correct the input or cardinality accordingly. Do not presume that a wrapper or aggregation is available or that either would resolve this condition. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected action.

Versions

The locked catalogue records this condition from 12.0. Only the PostgreSQL 18.6 definition row is fixed here; no native emitting path or natural runtime observation is claimed.

22034, 22037, 2203D

Sources

The fixed definition row is errcodes.txt#L229. The bounded source review did not resolve a native 2203E emitting path; the structured evidence record keeps that unknown scope explicit, and no natural runtime was run.

101 - 2203F — sql_json_scalar_required

Source-backed reference for PostgreSQL SQLSTATE 2203F.

2203F

At a glance

A JSON_VALUE operation received one item, but that item was not a scalar. Multiple items are handled earlier as 22034; empty results are handled by the empty/ON EMPTY path.

Field Value
SQLSTATE 2203F
Condition sql_json_scalar_required
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SQL_JSON_SCALAR_REQUIRED
Aliases

Messages

The fixed JSON_VALUE scalar guard uses these primary forms:

Context Primary
JSON_VALUE mapped to a named column JSON path expression for column "%s" must return single scalar item
Standalone JSON_VALUE JSON path expression in JSON_VALUE must return single scalar item

Meaning

JsonPathValue first executes the path and marks an empty result. More than one item is the separate 22034 cardinality branch. With exactly one item, it unwraps a scalar JSON container if needed and then requires a JSON scalar; an object or array reaches 2203F. When the caller supplies an error pointer for ON ERROR handling, the function sets the error flag and returns NULL rather than throwing. The ordinary ERROR path reports the column-aware or column-less primary shown above.

Diagnosis

Check the JSON_VALUE path result count and the selected item type. An empty result, several items, or a non-scalar single item has a different branch and response. Inspect the column mapping and ON EMPTY/ON ERROR clauses before changing the source JSON, and distinguish JSON_QUERY’s wrapper semantics from JSON_VALUE’s scalar requirement.

Response

Make the path resolve to one scalar, change the SQL/JSON operation when an object or array is intended, or configure the documented empty/error behavior for expected absence. Do not add a wrapper to JSON_VALUE to make a collection scalar. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected action.

Versions

The locked catalogue records this condition from 12.0; the fixed JSON_VALUE cardinality and scalar checks are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

22034, 22035, 22036

Sources

The complete JSON_VALUE empty, multiple-item, scalar, and ON ERROR pointer branches are jsonpath_exec.c#L3991-4067. The structured evidence record binds the 22034 boundary and both 2203F primaries; no natural runtime was run.

102 - 2203G — sql_json_item_cannot_be_cast_to_target_type

Source-backed reference for PostgreSQL SQLSTATE 2203G.

2203G

At a glance

2203G is the catalogue condition sql_json_item_cannot_be_cast_to_target_type. In the fixed PostgreSQL 18.6 tree, the bounded search found its macro in errcodes.txt but no core or contrib call that emits it. This is therefore a definition-only reference; a JSON conversion that merely looks similar is not evidence that the server used this SQLSTATE.

Field Value
SQLSTATE 2203G
Condition sql_json_item_cannot_be_cast_to_target_type
Status active
Known present by 15.0
Locked snapshots 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SQL_JSON_ITEM_CANNOT_BE_CAST_TO_TARGET_TYPE
Aliases

Meaning

The fixed catalogue gives this condition a SQL/JSON name, but the bounded 18.6 source scan did not find a PostgreSQL core or contrib emitter. It is not safe to turn the name into an invented JSONPath, constructor, scalar/array, or object conversion scenario. An extension or user-defined RAISE can have its own usage, but that is outside the fixed-tree result.

Diagnosis

Capture the exact SQLSTATE, primary/detail/hint, server log context, statement, and the extension or function that produced it. Use that evidence to identify the actual producer; do not classify a JSON syntax, ordinary type-input, or other conversion failure as 2203G from its wording alone.

Messages

No fixed PostgreSQL 18.6 primary, detail, or hint template was resolved for this definition-only entry.

Response

There is no source-backed PostgreSQL-core repair recipe for this definition-only entry. After identifying the real producer, correct that producer’s contract and retry the affected operation. If the producer did emit an ERROR in an explicit transaction, use ROLLBACK or ROLLBACK TO SAVEPOINT before retrying; in autocommit, correct the cause first and then submit the operation again. A connection reset is not implied by this condition definition.

Versions

The locked catalogue records the condition from PostgreSQL 15.0. The fixed source boundary for this review is PostgreSQL 18.6 REL_18_6; the absence of a bounded-tree emitter does not establish when any concrete implementation path was introduced, nor how an extension or a future version behaves.

2203F

Sources

src/backend/utils/errcodes.txt#L231

The structured evidence record records the fixed definition and the bounded source-scan limit. It contains no runtime observation.

103 - 22P01 — floating_point_exception

Source-backed reference for PostgreSQL SQLSTATE 22P01.

22P01

At a glance

PostgreSQL’s fixed core path installs FloatExceptionHandler for SIGFPE. The handler emits an ERROR with primary floating-point exception and detail stating that an invalid floating-point operation was signaled, probably because of an out-of-range result or an invalid operation such as division by zero.

Field Value
SQLSTATE 22P01
Condition floating_point_exception
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FLOATING_POINT_EXCEPTION
Aliases

Meaning

FloatExceptionHandler(SIGNAL_ARGS) is a signal-to-ereport(ERROR) boundary in src/backend/tcop/postgres.c; PostgresMain registers it for SIGFPE. This is a floating-point signal path, not a promise that every division or numeric range failure uses 22P01. Exact numeric division by zero and numeric range checks have their own conditions, commonly 22012 and 22003.

Diagnosis

Preserve the complete ErrorResponse and server-log context, including statement position and any routine or context fields. Inspect operand types and the expression path: distinguish a hardware or floating-point invalid operation from an exact-numeric operator that reports 22012 or 22003. The fixed handler’s detail is a diagnostic explanation, not proof that division by zero was the particular operation.

Messages

  • ERROR primary: floating-point exception
  • DETAIL: An invalid floating-point operation was signaled. This probably means an out-of-range result or an invalid operation, such as division by zero.

Response

Correct the arithmetic or input range, and cast deliberately before the operation when that changes the intended numeric domain. In an explicit transaction, an ERROR leaves the transaction aborted, so issue ROLLBACK or ROLLBACK TO SAVEPOINT before retrying; in autocommit, fix the expression or data first and submit it again. The cited path is ERROR, not FATAL, so a normal client backend need not be reset merely because this condition occurred.

Versions

The locked catalogue records this condition from PostgreSQL 7.4. The handler and SIGFPE registration cited here are from PostgreSQL 18.6 REL_18_6; the catalogue boundary does not prove the exact introduction of the current wording.

22012, 22003, 22023

Sources

src/backend/tcop/postgres.c#L3072-L3082

src/backend/tcop/postgres.c#L4245-L4249

The structured evidence record records the exact primary/detail, severity, and source/runtime boundary. No signal was induced for this review.

104 - 22P02 — Invalid text representation

PostgreSQL SQLSTATE 22P02: Invalid text representation (invalid_text_representation), source-backed diagnosis and recovery guidance.

22P02 — Invalid text representation

At a glance

22P02 means a text input routine cannot interpret a value as the requested type. This page selects the ordinary integer input path and also marks the COPY/text boundary; COPY, enum, extension, and contrib callers can use different primary messages.

Field Value
SQLSTATE 22P02
Condition invalid_text_representation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_TEXT_REPRESENTATION
Aliases

Meaning

For a cast, assignment, or text COPY field, the destination type’s input routine decides whether text is valid. PostgreSQL 18.6 emits invalid input syntax for type integer: "%s", while the locked PostgreSQL 10.23 source uses invalid input syntax for integer: "%s"; both are dynamic templates, not a universal localized string. Other fixed callers include COPY reject-limit reporting, enum input, and extension validation, so the primary text and context can differ.

Diagnosis

Record the destination type, the exact value after client encoding and parameter binding, and whether the operation is a cast, assignment, text COPY field, enum input, or another type wrapper. Distinguish malformed text (22P02) from numeric range overflow (22003), invalid date/time syntax (22007), invalid binary representation (22P03), and a malformed COPY file/header or framing (22P04). Do not diagnose a binary COPY payload with the text-input message alone.

Response

Validate at the input boundary and preserve the intended target type. Retry only after correcting the value; do not silently truncate or turn the value into NULL unless that is the explicit business rule. In an explicit transaction, an input ERROR leaves the transaction aborted (25P02); use ROLLBACK or a savepoint such as ROLLBACK TO SAVEPOINT convert_input before continuing. A COPY error likewise requires transaction recovery before another command.

Observed diagnostics

The fixed ordinary integer path has ERROR severity and the version-specific primary templates above. The selected runtime records the exact values: "not-an-integer" produced 22P02, and a valid "42" returned 42 on the same autocommit session.

Representative case

The shared registry sends one invalid text cast in autocommit, inspects the real diagnostic and IDLE state, then sends a valid integer text on the same connection. That observed recovery is different from an explicit transaction, where the client must roll back or roll back to a savepoint before continuing. The page uses the registry SQL; the runner substitutes no hidden second definition.

SELECT 'not-an-integer'::integer;
SELECT '42'::integer

The selected PostgreSQL 18.6 and 10.21 runs passed SQLSTATE, severity, state or disconnect recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence.

Versions

The locked catalogue records 22P02 from 7.4 through the listed snapshots. The bounded runtime comparison passed on 18.6 and 10.21, with the primary wording differing as shown; that does not generalize every 22P02 caller or every intermediate implementation.

Sources

  • src.errcodes.18.6src/backend/utils/errcodes.txt at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.invalid-integer.18.6src/backend/utils/adt/numutils.c at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 9018d559d8a2b04f6d3fa8fedeb754fc5f1f8cd8594292e6adc5108e8f97f1bf (source).
  • src.invalid-integer.10.23src/backend/utils/adt/numutils.c at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 6cb3fd7e4b38a66c16f2cc4a3de0c52ce44e01dd22edd3dd9340d2a8faea0d35 (source).
  • src.copy-text.18.6 — the fixed text-COPY conversion/reject-limit path in src/backend/commands/copyfrom.c at lines 1169-1172 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.22P02 / snippet-registry.22P02 — hashes are recorded in evidence/22P02.json and each selected runtime record.

105 - 22P03 — invalid_binary_representation

Source-backed reference for PostgreSQL SQLSTATE 22P03.

22P03

At a glance

22P03 is PostgreSQL’s invalid-binary-representation boundary. In the fixed source it covers binary COPY fields, extended-protocol Bind parameters, fast-path function arguments, logical-replication columns, and guards inside representative type receive functions.

Field Value
SQLSTATE 22P03
Condition invalid_binary_representation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_BINARY_REPRESENTATION
Aliases

Meaning

The receiver has been told to decode binary bytes, but the bytes do not satisfy the receiver’s format or do not get consumed completely. Binary COPY calls a type receive function and reports incorrect binary data format when bytes remain. Bind reports incorrect binary data format in bind parameter %d; fast-path calls report incorrect binary data format in function argument %d; logical replication reports incorrect binary data format in logical replication column %d. Representative array and numeric receivers use the same SQLSTATE for invalid dimensions/flags, array element framing, or numeric sign/scale/digit fields.

This is different from text input that fails a type input routine, and from COPY header or row framing errors that use 22P04. The exact receiving boundary and type OID matter.

Messages

The fixed representative primaries are incorrect binary data format (binary COPY), incorrect binary data format in bind parameter %d (Bind), incorrect binary data format in function argument %d (fast-path), and incorrect binary data format in logical replication column %d (logical replication). Type receivers also use invalid number of dimensions: %d, invalid array flags, insufficient data left in message, improper binary format in array element %d, invalid sign in external "numeric" value, invalid scale in external "numeric" value, and invalid digit in external "numeric" value; all cited variants are ERROR and have no DETAIL or HINT in the fixed calls.

Diagnosis

First identify the transport: extended-protocol Bind, binary COPY, fast-path function call, logical replication, or a type’s binary receive function. Preserve the parameter, argument, or remote-column number and the complete message. Compare the producer’s format code and type OID with the receiver’s expected type. For receiver guards, check whether the type consumed the complete length-delimited buffer; a leftover cursor is evidence of a format mismatch, not merely a bad textual value.

Response

Correct the producer or type contract, then retry at the protocol boundary that failed. Every client-visible ERROR inside an explicit transaction leaves that transaction aborted, including a Bind error: issue ROLLBACK or an already-established ROLLBACK TO SAVEPOINT before retrying. Sync and ReadyForQuery restore protocol synchronization and report status; they do not clear INERROR. For an extended-protocol Bind error, the backend skips frontend messages until the next Sync; send Sync and consume ReadyForQuery before issuing another extended-protocol operation. In autocommit, wait for that boundary before resubmitting the corrected operation. A fast-path FunctionCall is handled outside the extended-query skip flag and the normal loop can return ReadyForQuery, but the same explicit-transaction recovery rule applies. For COPY FROM STDIN, terminate a malformed stream according to the COPY protocol, using CopyFail when appropriate while still in COPY-in. If the COPY was issued through the extended protocol, after ErrorResponse send Sync and wait for ReadyForQuery; if it was issued in a simple Query, the remaining query message is discarded and ReadyForQuery follows; no client Sync is required, so consume that ReadyForQuery before sending the next query. Do not issue ordinary SQL during COPY-in. If message framing itself was lost while reading from the client, PostgreSQL has a separate protocol-synchronization FATAL path; do not infer that connection loss from the binary-format ERROR alone. For logical replication, repair the publisher/receiver binary encoder or type definition and let the replication worker’s own retry policy apply; this page does not justify killing or resetting every connection.

Versions

The locked catalogue records this condition from PostgreSQL 7.4. The binary transport, replication, array, and numeric paths cited here are from PostgreSQL 18.6 REL_18_6; no binary-protocol runtime was executed.

22P02, 22P04, 08P01

Sources

src/backend/commands/copyfromparse.c#L2047-L2055

src/backend/tcop/postgres.c#L1922-L1945

src/backend/tcop/fastpath.c#L426-L448

src/backend/replication/logical/worker.c#L832-L853

src/backend/utils/adt/arrayfuncs.c#L1476-L1510

src/backend/utils/adt/numeric.c#L1093-L1123

src/backend/tcop/postgres.c#L416-L445

src/backend/tcop/postgres.c#L4483-L4504

src/backend/tcop/postgres.c#L4843-L4875

doc/src/sgml/protocol.sgml#L1287-L1318

doc/src/sgml/protocol.sgml#L7821-L7823

The structured evidence record records exact primary templates and the source/runtime boundary.

106 - 22P04 — bad_copy_file_format

Source-backed reference for PostgreSQL SQLSTATE 22P04.

22P04

At a glance

22P04 is the COPY file-format boundary. The fixed parser uses it for binary signatures and headers, text or CSV framing, header/row field counts, and malformed binary field lengths. It is a structural COPY error, not a generic synonym for a value that failed type conversion.

Field Value
SQLSTATE 22P04
Condition bad_copy_file_format
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_BAD_COPY_FILE_FORMAT
Aliases

Meaning

Binary input validates the PGCOPY signature, flags, extension length, row field count, field length, and end marker. Representative primaries include COPY file signature not recognized, invalid COPY file header (missing flags), invalid COPY file header (wrong length), row field count is %d, expected %d, invalid field size, and unexpected EOF in COPY data.

Text and CSV input has separate framing guards. Header matching can report wrong number of fields in header line: got %d, expected %d or a column-name mismatch; ordinary rows can report extra data after last expected column or missing data for column "%s". CSV quoting and line endings can report unterminated CSV quoted field, unquoted carriage return found in data, or unquoted newline found in data, while text mode uses the corresponding literal ... found in data messages and hints. A valid frame whose value cannot be converted belongs to the type-input boundary, commonly 22P02; a binary type receiver that leaves bytes unconsumed can be 22P03.

Messages

Representative fixed ERROR primaries include:

  • Binary headers/fields: COPY file signature not recognized; invalid COPY file header (missing flags); unrecognized critical flags in COPY file header; invalid COPY file header (missing length); invalid COPY file header (wrong length); invalid field size; unexpected EOF in COPY data.
  • Header and rows: wrong number of fields in header line: got %d, expected %d; column name mismatch in header line field %d: got "%s", expected "%s"; extra data after last expected column; missing data for column "%s"; row field count is %d, expected %d.
  • CSV and line framing: unterminated CSV quoted field; literal carriage return found in data; unquoted carriage return found in data; literal newline found in data; unquoted newline found in data; end-of-copy marker is not alone on its line. The carriage-return/newline variants carry the source hints to use \r, \n, or a quoted CSV field.

Diagnosis

Determine whether the source is text, CSV, binary COPY, or frontend COPY-in. Preserve the exact primary because it identifies the parser stage. Check binary signature/flags/length, header and target-column order, row field count, CSV quote/escape and newline rules, and whether the text COPY end-of-data marker is alone on its line. Only after framing is valid should you investigate the target type’s input conversion.

ON_ERROR IGNORE is narrower than a general malformed-row switch. The fixed text/CSV path wraps safe type-input conversion and can emit a notice while skipping a data-type-incompatible row; header, field-count, line-framing, CSV-quote, and binary-structure errors are raised as ERROR and are not all skippable through that option.

Response

Regenerate the stream in the declared text/CSV/binary format with the exact target column order and correct headers, lengths, quoting, and row framing. In frontend COPY-in, finish the COPY sub-protocol at its current boundary, using CopyFail when appropriate. If the COPY was issued through the extended protocol and the backend sends ErrorResponse, send Sync and wait for ReadyForQuery; if it was issued in a simple Query, the remaining query message is discarded and ReadyForQuery follows; no client Sync is required, so consume that ReadyForQuery before sending the next query. Do not send ordinary SQL in the middle of COPY-in. An ERROR inside an explicit transaction requires ROLLBACK or ROLLBACK TO SAVEPOINT after the protocol boundary; ReadyForQuery reports status but does not replace that transaction recovery. ON_ERROR IGNORE may be suitable for the documented safe type-input failures, but it does not repair a bad header or malformed CSV/binary framing. A normal COPY ERROR does not by itself require resetting the connection.

Versions

The locked catalogue records this condition from PostgreSQL 7.4. The cited parser and its ON_ERROR boundary are from PostgreSQL 18.6 REL_18_6; no natural COPY-file runtime was executed.

22P02, 22P03, 2200B

Sources

src/backend/commands/copyfromparse.c#L190-L228

src/backend/commands/copyfromparse.c#L779-L827

src/backend/commands/copyfromparse.c#L937-L977

src/backend/commands/copyfromparse.c#L1026-L1073

src/backend/commands/copyfromparse.c#L1084-L1130

src/backend/commands/copyfromparse.c#L1388-L1432

src/backend/commands/copyfromparse.c#L1818-L1922

src/backend/tcop/postgres.c#L416-L445

doc/src/sgml/protocol.sgml#L1287-L1318

The structured evidence record records representative exact primaries/hints and the structural ON_ERROR limit.

107 - 22P05 — untranslatable_character

Source-backed reference for PostgreSQL SQLSTATE 22P05.

22P05

At a glance

PostgreSQL could identify a source character but could not represent it in the destination encoding. The fixed helper reports the offending bytes and both encoding names with primary character with byte sequence %s in encoding "%s" has no equivalent in encoding "%s" at ERROR severity.

Field Value
SQLSTATE 22P05
Condition untranslatable_character
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_UNTRANSLATABLE_CHARACTER
Aliases

Meaning

report_untranslatable_char(src_encoding, dest_encoding, ...) determines the source multibyte length, formats the offending bytes as 0x.., and raises 22P05 when the destination conversion table has no equivalent character. This means the source character is valid enough to identify, but the target representation cannot carry it. It is different from malformed source bytes: the fixed conversion loop can call report_invalid_encoding, which uses 22021 instead.

Messages

  • ERROR primary: character with byte sequence %s in encoding "%s" has no equivalent in encoding "%s"
  • The fixed call supplies no DETAIL or HINT.

Diagnosis

Read the exact byte sequence, source encoding, destination encoding, and conversion direction from the primary. Check client_encoding, server/database encoding, import or COPY file encoding, and the actual conversion boundary. Do not treat the presence of a non-ASCII character as proof of 22P05; malformed source bytes and ordinary type-input failures have different paths.

Response

Choose a destination encoding that represents the data, or correct the producer and conversion boundary while preserving the character. Do not silently replace or discard it unless loss is an explicit data policy. Because the cited path is ERROR, an explicit transaction needs ROLLBACK or ROLLBACK TO SAVEPOINT before retrying; in autocommit, correct the encoding or input and submit again. This source path does not imply a connection reset or a FATAL session end.

Versions

The locked catalogue records this condition from PostgreSQL 7.4. The reporting helper and representative conversion branch cited here are from PostgreSQL 18.6 REL_18_6; no encoding runtime was executed.

22021, 22P02

Sources

src/backend/utils/mb/mbutils.c#L1862-L1902

src/backend/utils/mb/conv.c#L674-L684

The structured evidence record records the exact primary and the valid-character versus malformed-byte boundary.

108 - 22P06 — nonstandard_use_of_escape_character

Source-backed reference for PostgreSQL SQLSTATE 22P06.

22P06

At a glance

The SQL scanner found a backslash escape form that is nonstandard or unsafe under the current string-literal settings. PostgreSQL 18.6 has one ERROR branch for unsafe quote escaping and three WARNING branches for backslash-quote, backslash-backslash, and other escape use.

Field Value
SQLSTATE 22P06
Condition nonstandard_use_of_escape_character
Status active
Known present by 8.1.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER
Aliases

Meaning

The scanner copies backslash_quote, escape_string_warning, and standard_conforming_strings into its state. Ordinary quoted strings enter the escape-aware xe rules only when standard_conforming_strings is off; explicit E'...' strings enter them directly. The explicit-E start also initializes warn_on_first_escape to false, so it avoids this legacy first-escape WARNING; it still enters xe and remains subject to the backslash_quote ERROR guard. An E prefix is not a general way to bypass that guard. For an escaped single quote, backslash_quote = off, or safe-encoding mode combined with a client-only encoding, raises ERROR with primary unsafe use of \' in a string literal and a quote-doubling hint.

When escape_string_warning and the scanner’s first-escape guard are enabled, the lexer emits one WARNING per string for \', \\, or another escape. The exact primaries are nonstandard use of \' in a string literal, nonstandard use of \\ in a string literal, and nonstandard use of escape in a string literal. These warnings are warning diagnostics, not NOTICE, and do not by themselves abort a statement.

Messages

  • ERROR primary: unsafe use of \' in a string literal; HINT: Use '' to write quotes in strings. \' is insecure in client-only encodings.
  • WARNING primary: nonstandard use of \' in a string literal; HINT: Use '' to write quotes in strings, or use the escape string syntax (E'...').
  • WARNING primary: nonstandard use of \\ in a string literal; HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
  • WARNING primary: nonstandard use of escape in a string literal; HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.

Diagnosis

Preserve the literal spelling and character position, the presence or absence of the E prefix, standard_conforming_strings, backslash_quote, escape_string_warning, client encoding, and message severity. A backslash-quote under the ERROR guard is a rejected statement; a warning branch may allow the statement to proceed. The same text can therefore have different outcomes when the scanner settings or client encoding change.

Response

Write embedded quotes as doubled single quotes. Use explicit E'...' syntax for intended backslash escapes and make the desired escape semantics clear. If the branch was ERROR, an explicit transaction is aborted and needs ROLLBACK or ROLLBACK TO SAVEPOINT before retrying; in autocommit, correct the literal first. A WARNING does not require transaction recovery, although correcting the literal is preferable to hiding the warning or globally changing policy. The cited paths do not imply a connection reset.

Versions

The locked catalogue records this condition from PostgreSQL 8.1.0. The scanner guards and exact messages cited here are from PostgreSQL 18.6 REL_18_6; no locale or GUC runtime was executed.

22019, 42601

Sources

src/backend/parser/scan.l#L545-L560

src/backend/parser/scan.l#L706-L720

src/backend/parser/scan.l#L1423-L1459

The structured evidence record records all four exact primaries, hints, guards, severity, and the source/runtime boundary.

109 - 23000 — integrity_constraint_violation

PostgreSQL SQLSTATE 23000: the Class 23 integrity_constraint_violation umbrella and its concrete descendants.

23000 — integrity_constraint_violation

At a glance

23000 names the Class 23 integrity-constraint umbrella. It is a protocol category, not a reliable substitute for a concrete PostgreSQL constraint error. Use the exact five-character code returned by the server.

Field Value
SQLSTATE 23000
Condition integrity_constraint_violation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION
Aliases

Meaning

The class covers row and schema operations that violate declared integrity rules. PostgreSQL’s locked errcodes.txt maps concrete mechanisms to descendants such as 23001, 23502, 23503, 23505, 23514, and 23P01. The core PostgreSQL 18.6 call scan contains no resolved 23000 report group, so this page records a definition and dispatch boundary rather than inventing a natural SQL reproduction.

Diagnosis

Read the server SQLSTATE first, then use constraint_name, table_name, column_name, schema_name, and the primary/detail fields when present. A client that collapses every Class 23 value to 23000 loses the distinction needed to repair a NOT NULL, foreign-key, unique, CHECK, exclusion, or RESTRICT failure.

Response

Keep the original statement and transaction boundary. Handle the concrete descendant if one is returned; repair the data or schema rule that it identifies, roll back a failed explicit transaction, and retry only after the intended invariant is satisfied. Do not emit RAISE EXCEPTION ... ERRCODE 23000 as if it demonstrated a natural server path.

Source message templates

Applicability boundary

This batch does not construct a natural SQL trigger for 23000; treat it as a source/protocol boundary rather than a copyable reproduction. structured evidence · case export.

Authored evidence IDs: identity, specific-codes, handling. Selected runtime records: —.

Versions

The locked catalogue observes the umbrella by 7.4 and in every listed 9.0–18.6 formal snapshot. The absence of a resolved 18.6 core call site is a bounded source observation, not a claim about extensions or future releases.

See 23001 RESTRICT violation, 23502 NOT NULL violation, 23514 CHECK violation, 23P01 exclusion violation, and 23505 unique violation.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6 (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

110 - 23001 — restrict_violation

PostgreSQL SQLSTATE 23001: restrict_violation from an immediate foreign-key RESTRICT action.

23001 — restrict_violation

At a glance

23001 is the specific RESTRICT violation condition. In the selected PostgreSQL 18.6 case, deleting a referenced parent row raised it with the child constraint and key in the diagnostic. PostgreSQL 10 reported the same tested operation through 23503, so version and server diagnostics must be recorded. A separate PostgreSQL 17.11 comparison also returned 23503 for this RESTRICT operation; it is not 23001 coverage.

Field Value
SQLSTATE 23001
Condition restrict_violation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_RESTRICT_VIOLATION
Aliases

Meaning

An ON DELETE RESTRICT or ON UPDATE RESTRICT action checks the referencing row immediately and refuses the parent change. This differs from NO ACTION: a DEFERRABLE NO ACTION constraint can postpone its check until the relevant commit, while RESTRICT is not deferrable. The source builds a dynamic primary/detail message from the parent table, foreign-key constraint, child table, and key visibility.

Diagnosis

Record the exact SQLSTATE and constraint_name, table_name, schema_name, and detail. Check the child rows before changing the parent. In an explicit transaction the failed delete leaves the connection INERROR; ROLLBACK is required before the repair transaction can delete the child and then the parent.

Response

Choose the action deliberately: remove or reassign dependent rows, change the parent operation, or redesign the FK action after reviewing its integrity meaning. Do not turn RESTRICT into a deferred NO ACTION merely to make a migration pass. The selected repair deletes the dependent row in a new BEGIN/COMMIT sequence and then deletes the parent.

Observed diagnostics

18.6 (Homebrew) / latest:SQLSTATE 23001; primary update or delete on table "parents" violates RESTRICT setting of foreign key constraint "children_parent_id_fkey" on table "children"; DETAIL Key (id)=(1) is referenced from table "children".; after_error INERROR; after_rollback IDLE. 10.21 (Debian 10.21-1.pgdg90+1) / pg10:SQLSTATE 23503; primary update or delete on table "parents" violates foreign key constraint "children_parent_id_fkey" on table "children"; DETAIL Key (id)=(1) is still referenced from table "children".; after_error INERROR; after_rollback IDLE. 17.11 (pg17) / boundary:SQLSTATE 23503; primary update or delete on table "parents" violates foreign key constraint "children_parent_id_fkey" on table "children"; DETAIL Key (id)=(1) is still referenced from table "children".; after_error INERROR; after_rollback IDLE; final counts [0, 0]. This boundary case is not 23001 coverage.

Representative case

The runner reads these statements from verify/cases/23001/snippets.json (SHA-256 6086c1ce982afa5438bbcd29b86ec4cd0cbe0c76fa6152c1eb4a330a7706d5c8) and qualifies the temporary table names; the complete setup, assertions, and cleanup are in the case export.

-- create_parent
CREATE TABLE parents(id integer PRIMARY KEY);
-- create_child
CREATE TABLE children(id integer PRIMARY KEY, parent_id integer NOT NULL REFERENCES parents(id) ON DELETE RESTRICT);
-- seed_parent
INSERT INTO parents VALUES (1);
-- seed_child
INSERT INTO children VALUES (10, 1);
-- begin
BEGIN;
-- trigger
DELETE FROM parents WHERE id = 1;
-- rollback
ROLLBACK;
-- repair_begin
BEGIN;
-- repair_child
DELETE FROM children WHERE id = 10;
-- repair_parent
DELETE FROM parents WHERE id = 1;
-- commit
COMMIT;
-- verify
SELECT (SELECT count(*) FROM parents), (SELECT count(*) FROM children);

The SQLSTATE, diagnostic, transaction-state, and repair assertions for this excerpt are produced from the shared registry; structured evidence · case export.

Authored evidence IDs: identity, restrict-path, no-action-boundary, runtime, runtime.pg17-boundary. Selected base runtime records: runtime.23001-batch1-latest2-20260909.latest, runtime.23001-batch1-pg10b-20260909.pg10. Separate boundary record: runtime.23001-boundary-pg17-final-20260909.pg17.

Versions

The locked catalogue observes the condition by 7.4 and in all listed formal snapshots. The selected base cases observe 23001 on 18.6 and 23503 on 10.21 for the same RESTRICT delete. A separate PG17.11 boundary comparison also returned 23503, with the same INERROR to IDLE recovery; it is retained as a comparison and does not establish a universal result for every PostgreSQL 11–17 minor release.

Compare 23503 foreign-key violation, 23505 unique violation, and 23514 CHECK violation.

Sources

111 - 23502 — not_null_violation

PostgreSQL SQLSTATE 23502: not_null_violation with column-aware diagnosis and repair boundaries.

23502 — not_null_violation

At a glance

23502 means a NULL reached a NOT NULL rule. The selected case identifies column label and relation items; the exact PG18 and PG10 primary messages differ slightly in relation wording, while the SQLSTATE and structured object identity agree.

Field Value
SQLSTATE 23502
Condition not_null_violation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NOT_NULL_VIOLATION
Aliases

Meaning

The executor checks the tuple against the relation’s NOT NULL attributes and reports 23502 with the column and relation. PostgreSQL also uses the code for schema validation and domain NOT NULL validation, with different source templates; a failing domain CHECK is a 23514 path instead. A default, an explicit value, a generated expression, or a schema change may be the correct repair depending on why the NULL was produced.

Diagnosis

Capture the exact column_name, table_name, and optional failing-row detail. The selected PG18 primary includes of relation "items", while PG10 omits that phrase; use structured fields rather than matching the full English string. Trace the value through application parameters, casts, generated columns, triggers, and INSERT ... SELECT; do not infer the source from the final row alone. The selected autocommit case remained IDLE after the failed insert, but an explicit transaction must be rolled back or handled before reuse.

Response

Supply a value that is valid for the column, intentionally apply a default, or change the constraint only after checking existing rows and downstream readers. Do not drop NOT NULL or replace it with a weaker CHECK merely to silence a missing-value error; make NULLability a deliberate data-contract decision. Retry the insert with the corrected value. For a migration that adds NOT NULL, validate existing data separately and keep the schema change’s transaction boundary explicit.

Observed diagnostics

18.6 (Homebrew) / latest:SQLSTATE 23502; primary null value in column "label" of relation "items" violates not-null constraint; DETAIL Failing row contains (2, null).; status_after_error IDLE. 10.21 (Debian 10.21-1.pgdg90+1) / pg10:SQLSTATE 23502; primary null value in column "label" violates not-null constraint; DETAIL Failing row contains (2, null).; status_after_error IDLE.

Representative case

The runner reads these statements from verify/cases/23502/snippets.json (SHA-256 f701e32a0e9214d6c88deabcda99981c288cae0f176d1dcaf383863c3942f8e0) and qualifies the temporary table names; the complete setup, assertions, and cleanup are in the case export.

-- create
CREATE TABLE items(id integer PRIMARY KEY, label text NOT NULL);
-- seed
INSERT INTO items VALUES (1, 'seed');
-- trigger
INSERT INTO items VALUES (2, NULL);
-- repair
INSERT INTO items VALUES (2, 'valid');
-- verify
SELECT id, label FROM items ORDER BY id;

The SQLSTATE, diagnostic, transaction-state, and repair assertions for this excerpt are produced from the shared registry; structured evidence · case export.

Authored evidence IDs: identity, dml-path, schema-path, runtime. Selected runtime records: runtime.23502-batch1-latest-20260909.latest, runtime.23502-batch1-pg10-20260909.pg10.

Versions

The locked catalogue observes the condition by 7.4 and in all listed formal snapshots. The selected runtime is one ordinary INSERT on 18.6 and 10.21; it does not cover ALTER TABLE validation, domains, partition routing, or trigger-generated NULLs.

Compare 23514 CHECK violation, 23503 foreign-key violation, and 23505 unique violation.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6 (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)
  • src.execMain.18.6 (SHA-256 33b97337fa23a649c5e7a092e1bd405a54e8503529236c62c9d5bb93a1774a8d)
  • src.tablecmds.18.6 (SHA-256 422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9)
  • src.typecmds.18.6 (SHA-256 60d1e9754646e100f6b74aa367ad8c2c52386c400df721707423d329209c47eb)
  • doc.ddl-constraints.18.6 (SHA-256 ce1919d9236f2e71672660e1a347146472e966e4d19b77fde5ae345dd1db6ec7) · official documentation

112 - 23503 — foreign_key_violation

PostgreSQL reports SQLSTATE 23503 for a child foreign-key violation and some ordinary parent actions. Identify the action, relation, and constraint, then repair the data or transaction boundary.

At a glance

23503 is PostgreSQL’s foreign_key_violation condition in Class 23, integrity_constraint_violation. A child insert or update without a matching parent key, or an ordinary parent key action covered by the foreign-key rules, can produce it. In PostgreSQL 18.6, the RESTRICT parent branch instead uses 23001, so classify the action and complete diagnostic before assigning this SQLSTATE.

The most useful diagnostic fields are the SQLSTATE (C), primary message (M), detail (D), and the schema, table, and constraint fields when the server supplies them. In psycopg these are available through exc.sqlstate and exc.diag. Preserve the complete diagnostic before retrying, because the detail names the missing or still-referenced key when PostgreSQL can show it.

For an immediate foreign-key constraint, the error is raised by the violating statement. A deferred constraint can let the statement finish and raise 23503 at COMMIT instead. In autocommit, the connection can execute the next command after an immediate failed statement. In an explicit transaction, an immediate failure leaves the transaction INERROR; issue ROLLBACK or roll back to a savepoint before sending an unrelated command. A valid parent row and a fresh child write are the repair proof in the representative case.

The case fk_insert_missing_parent uses a real parents/children foreign key. It passed on PostgreSQL 18.6 and the isolated PostgreSQL 10.21 target. The run IDs and per-case assertions are retained in the public evidence JSON.

Field Value
SQLSTATE 23503
Condition foreign_key_violation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FOREIGN_KEY_VIOLATION
Aliases

Meaning and trigger paths

A foreign key on the child table points to a primary key or a suitable unique key on the parent table. PostgreSQL checks that relationship on child INSERT and key-changing UPDATE, and checks the reverse relationship when a parent key is updated or deleted. The exact timing depends on whether the constraint is immediate or deferred.

The column matching rule also matters. With the default MATCH SIMPLE, a referencing row with any null key column does not have to match a parent. MATCH FULL permits an all-null key or an all-non-null key that matches, but rejects a mixture of null and non-null key columns. The representative case uses one NOT NULL column, so it deliberately does not demonstrate either null rule.

For a parent DELETE or key-changing UPDATE, ON DELETE/UPDATE NO ACTION can wait until the constraint’s check point when the constraint is deferrable, whereas RESTRICT checks immediately and cannot be deferred. In the fixed PostgreSQL 18.6 source, the RESTRICT branch uses 23001 (restrict_violation) with a dedicated message rather than the 23503 shown by this page’s child-write case. The action is part of the relationship contract, so a parent operation cannot be assigned a SQLSTATE by analogy with a missing-parent insert.

The ordinary child-row path in ri_triggers.c reports the condition with the template insert or update on table "%s" violates foreign key constraint "%s". Its conditional detail is Key (%s)=(%s) is not present in table "%s".; the server also attaches the child table and constraint through the protocol’s table and constraint fields. The ordinary parent-key branch can use a different 23503 primary template, while the fixed-version RESTRICT branch uses 23001. This page’s runtime evidence covers only the missing-parent child write, not parent actions.

23503 identifies the relationship failure, not the application fix. A missing parent can mean an ordering bug, an incorrect identifier, an uncommitted parent in another transaction, or a deliberate delete that needs a cascade or another business rule. Inspect the operation and constraint definition before choosing a repair.

Messages and diagnostics

The representative operation creates a parent and child table, inserts no parent with key 99, and then inserts the child row. The executable excerpt is the same trigger and recovery sequence used by the runner; names are schema-qualified by the disposable harness.

CREATE TABLE parents(id integer PRIMARY KEY);
CREATE TABLE children(
    id integer PRIMARY KEY,
    parent_id integer NOT NULL,
    CONSTRAINT children_parent_fk FOREIGN KEY (parent_id) REFERENCES parents(id)
);
BEGIN;
INSERT INTO children VALUES (1, 99);
-- The server reports 23503 and the transaction is now INERROR.
ROLLBACK;
BEGIN;
INSERT INTO parents VALUES (99);
INSERT INTO children VALUES (1, 99);
COMMIT;

On PostgreSQL 18.6, the natural error was:

SQLSTATE: 23503
severity: ERROR
message_primary: insert or update on table "children" violates foreign key constraint "children_parent_fk"
message_detail: Key (parent_id)=(99) is not present in table "parents".
schema_name: c23503_fk_insert_missing_parent
table_name: children
constraint_name: children_parent_fk
source: ri_triggers.c / ri_ReportViolation / line 2783

PostgreSQL 10.21 produced the same primary and detail text; its corresponding source line was 3266. The detail is conditional on permission to describe the key and may be absent. Do not parse a localized English message as the protocol contract: branch on 23503, then use the structured fields and the operation context.

Diagnosis

First capture the failing statement, SQLSTATE, severity, primary message, detail, hint, server version, and transaction status. For an explicit transaction, record the status immediately after the error (INERROR) and after recovery (IDLE or INTRANS). A later 25P02 means the client sent a command while the transaction was already failed; it is a follow-on state, not a replacement for 23503.

Inspect the named constraint and its referenced relation with pg_constraint and pg_get_constraintdef(). Compare the attempted key with the parent table under the relevant isolation level. If the parent row is being created by another transaction, determine whether the write order and commit ordering are intentional; a fixed delay does not prove that a parent became visible.

For a parent delete or key update, inspect the referencing rows and the action declared by ON DELETE or ON UPDATE. For a deferred foreign key, the violating statement may succeed and COMMIT may be the command that raises 23503. Preserve that timing in logs and in retry logic.

Response and repair

Choose the repair that matches the relationship:

  • Create or select the intended parent before retrying the child write, as in the representative case.
  • Correct the child identifier when it is stale or malformed; do not disable the constraint to hide a data error.
  • For a parent removal, apply the declared cascade, set-null, or restrict policy only when it matches the business rule. Otherwise update or archive the referencing rows first.
  • If another transaction owns the parent write, use a transaction design that establishes the intended ordering and isolation. Re-read after a rollback rather than replaying a stale child request blindly.

After a failed explicit transaction, ROLLBACK discards its pending work and returns the connection to IDLE. A savepoint can retain earlier work when the child operation is optional. A successful repair must include a real parent lookup, a committed child row, and a post-commit read; merely receiving a new connection or issuing ROLLBACK is not proof that the relationship is fixed.

Versions and boundaries

The catalogue has a definition-presence observation for 23503 at PostgreSQL 7.4 and through the locked 8.4.22 pre-9.0 definitions, then in every listed formal snapshot through PostgreSQL 18.6 and the PostgreSQL 19 Beta 3 preview. This is a definition-only presence boundary, not an exact implementation introduction or runtime-use claim. No condition definition change is recorded in the scanned range.

The representative case passed on PostgreSQL 18.6 and 10.21. Source line numbers differ between those releases, while SQLSTATE, constraint identity, and the foreign-key diagnostic shape remain the compatibility boundary used here. Deferred timing, permissions, cascading actions, and concurrent parent creation are separate dimensions and are not implied by this one immediate-constraint run.

23505unique_violation covers duplicate values in a unique invariant. 23502not_null_violation covers a required column receiving NULL. 40001serialization_failure and 40P01deadlock_detected describe concurrency outcomes that can surround a relationship repair. 25P02in_failed_sql_transaction is the follow-on transaction state after an unhandled error.

Sources

The structured evidence is recorded in the public evidence JSON. Source records are fixed to PostgreSQL commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; runtime records retain both target run IDs and their structured observations.

113 - 23505 — unique_violation

PostgreSQL reports 23505 when a row or index operation violates a unique invariant. Diagnose the named object, recover the transaction, and choose a business-safe repair.

At a glance

23505 is PostgreSQL’s unique_violation condition. A row, an index build, or a logical-apply operation found a value that cannot coexist with an enforced unique invariant.

First capture the complete ErrorResponse and the statement that failed. The most useful fields are C (SQLSTATE), M (primary message), D (detail), and, when supplied, s (schema), t (table), and n (constraint or index). In psycopg, these are available through exc.sqlstate and exc.diag. The object fields belong to the wire protocol; they are not standard column names in CSV logs or keys in JSON logs.

The recovery action depends on where the error occurred:

  • An autocommit statement fails, but that connection is ready for its next command.
  • A statement inside an explicit transaction leaves the transaction aborted. Roll back the transaction, or roll back to a savepoint, before issuing another statement. Otherwise PostgreSQL returns 25P02.
  • A deferred unique constraint can accept duplicate rows temporarily and report 23505 at COMMIT.
  • A PL/pgSQL EXCEPTION block can catch the violation in a subtransaction, provided the handler is narrow enough to identify the failing operation.

The selected public runtime records cover 12 distinct passing cases on PostgreSQL 18.6 and 11 passing cases on PostgreSQL 10.21, with NULLS NOT DISTINCT marked not applicable on PG10. The full run remains the source for unreplaced cases; targeted final records select the DML diagnostic, exact log_fields correlation, registry excerpts, and manual transaction boundaries without duplicating or overriding those cases. A separate PG14.24/PG15.19 boundary comparison records unsupported syntax 42601 on PG14 and natural 23505 on PG15 for explicit UNIQUE NULLS NOT DISTINCT; it is excluded from those base counts. The selected run IDs and structured observations are retained in the public evidence JSON; superseded summaries and raw JSONL remain local audit data.

Field Value
SQLSTATE 23505
Condition unique_violation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_UNIQUE_VIOLATION
Aliases

The generated locked snapshots above are the catalogue’s release-definition coverage. The executable compatibility targets in this page are PostgreSQL 18.6 and 10.21; the catalogue entry does not claim that 23505 was introduced in PostgreSQL 10.

Meaning and trigger paths

The SQLSTATE directory places 23505 in Class 23, integrity_constraint_violation, with the condition name unique_violation. In the normal btree path, PostgreSQL checks an index entry and raises an error when a conflicting committed or concurrently inserted key is not allowed by the index’s semantics. A primary key is also a unique index, so a duplicate primary-key value uses this condition.

The same SQLSTATE can describe several mechanisms:

  1. DML against a unique constraint or index. An INSERT, or an UPDATE that changes a key, can conflict with a row already protected by a unique index. The normal message template is duplicate key value violates unique constraint "..."; the optional detail is Key (...)=(...) already exists.
  2. A unique index build. Building a unique index over existing duplicate rows uses a different template: could not create unique index "...", with Key (...)=(...) is duplicated. This is an index-build failure, not an ordinary row-insert message.
  3. A deferred constraint. With DEFERRABLE INITIALLY DEFERRED, the duplicate can remain in the transaction until the constraint check at commit. The error is therefore associated with COMMIT, and a failed top-level commit rolls back that transaction.
  4. Logical replication apply. PostgreSQL 18 classifies an apply conflict such as insert_exists; the conflict reporter still maps the relevant insert/update/multiple-unique paths to 23505. The message shape and server log context are different from a client-side btree insert. This page has source and documentation evidence for that path, but the current runtime batch did not create a publisher/subscriber topology.

The code tells you what class of condition occurred. It does not tell you whether the collision is a permanent business duplicate, a race in key selection, or a failed maintenance operation. That distinction comes from the statement, schema, constraint definition, transaction context, and any concurrent activity.

The SQL blocks below are explanatory excerpts with the same operations as the named cases. The authoritative executable source is scripts/verify_cases.py together with verify/cases/23505/cases.json; the excerpts identify their case and omit only disposable schema naming and cleanup, so they are not a second runnable case definition.

Messages and diagnostics

For a normal DML conflict, the PostgreSQL 18.6 source path nbtinsert.c calls BuildIndexValueDescription, then reports the unique violation and attaches the table and constraint identity. A representative run record was:

SQLSTATE: 23505
severity: ERROR
message_primary: duplicate key value violates unique constraint "users_email_key"
message_detail: Key (email)=(a@example.test) already exists.
schema_name: c23505_dml_unique_conflict
table_name: users
constraint_name: users_email_key
source: nbtinsert.c / _bt_check_unique

That detail is conditional. PostgreSQL can omit key values when the caller lacks permission to inspect the relevant columns, when row-level security prevents the description, or for an expression index. The same run with an INSERT-only role kept SQLSTATE and object identity but had no message_detail.

The protocol fields are defined in the Error and Notice Message Fields reference. They should be read from the driver exception rather than inferred from a log parser. The 18.6 logging configuration describes CSV fields such as sql_state_code, message, and detail, and JSON fields such as state_code, message, and detail; neither format defines the protocol’s constraint_name as a standard field. The targeted log_fields run matched the collector records to the same backend PID, schema/table, constraint, primary message, and DETAIL as the driver diagnostic: PostgreSQL 18.6 exposed both CSV and JSON, while PostgreSQL 10.21 exposed CSV.

The index-build message is deliberately separate:

SQLSTATE: 23505
message_primary: could not create unique index "idx_concurrent"
message_detail: Key (email)=(dup) is duplicated.
source: tuplesortvariants.c / comparetup_index_btree_tiebreak

Do not parse only the English message to classify this error. Branch on SQLSTATE, then use the structured fields and the operation context. Localized message text can change while the five-character SQLSTATE remains the stable protocol value.

Diagnosis

Record the failed statement, SQLSTATE, primary message, detail, hint, schema/table/constraint fields, server version, and transaction status. A driver should expose the original exception; a generic ORM error string may discard fields needed to identify the conflicting object.

For a named table, inspect both constraints and indexes before changing data. These are the diagnostic_catalog_queries statements used by the runner; the disposable run executes them against its accounts table:

SELECT conname, contype, condeferrable, condeferred,
       pg_get_constraintdef(oid)
FROM pg_constraint
WHERE conrelid = 'accounts'::regclass;

SELECT indexrelid::regclass AS index_name,
       indisunique, indisvalid, indisready, indislive,
       pg_get_indexdef(indexrelid)
FROM pg_index
WHERE indrelid = 'accounts'::regclass;

For an ordinary DML error, compare the attempted key with the row protected by the named constraint. Check every unique invariant on the table; a statement that names one conflict target can still violate another unique constraint. For an index-build error, find duplicate keys before retrying the build and inspect pg_index after a concurrent failure.

The runtime case concurrent_unique_conflict used two sessions and an observer. Session A held an uncommitted token='raced'; before A committed, the observer saw B’s statement with wait_event_type=Lock and wait_event=transactionid. After A committed, B received 23505 and was INERROR until rollback. This synchronization is evidence of the ordering; a fixed sleep would not establish it.

Response and repair

Recover the transaction first (cases: explicit_tx_abort_recovery, savepoint_recovery)

With autocommit enabled, the failed operation is complete and the connection was IDLE in the runtime cases. Decide what the application should do with the input, then issue a new command.

Inside an explicit transaction, stop using the connection after the first failure until the failed transaction is handled:

The INSERT INTO items VALUES (3, 'seed') statement below is the natural duplicate trigger; the following ROLLBACK is the required recovery.

CREATE TABLE items(id integer PRIMARY KEY, note text UNIQUE NOT NULL);
INSERT INTO items VALUES (1, 'seed');
BEGIN;
INSERT INTO items VALUES (2, 'outer');
INSERT INTO items VALUES (3, 'seed');
ROLLBACK;
BEGIN;
INSERT INTO items VALUES (2, 'after rollback');
COMMIT;

If only a part of the unit of work is optional, use a savepoint and retain the outer work:

The insert after the savepoint reuses the seeded unique value, so it is the natural 23505 trigger. ROLLBACK TO SAVEPOINT then removes only that failed subtransaction.

CREATE TABLE items(id integer PRIMARY KEY, note text UNIQUE NOT NULL);
INSERT INTO items VALUES (1, 'seed');
BEGIN;
INSERT INTO items VALUES (2, 'outer');
SAVEPOINT unique_case;
INSERT INTO items VALUES (3, 'seed');
-- This statement is expected to return 25P02 while the transaction is failed.
SELECT count(*) FROM items;
ROLLBACK TO SAVEPOINT unique_case;
INSERT INTO items VALUES (3, 'after savepoint');
RELEASE SAVEPOINT unique_case;
COMMIT;

The runner observed 25P02 when it issued a SELECT before rollback, then observed INTRANS after ROLLBACK TO SAVEPOINT. A plain ROLLBACK returns an explicit transaction to IDLE; ROLLBACK TO preserves work before the savepoint.

A deferred constraint changes the failure point (case: deferred_commit_conflict). In the real case, both duplicate inserts succeeded while the connection was INTRANS; COMMIT then raised 23505, returned the connection to IDLE, and left zero rows from that failed top-level transaction. Fix the keys before commit or roll back and retry the entire unit of work.

PL/pgSQL can handle a natural unique violation inside an exception block (case: plpgsql_exception_recovery):

CREATE TABLE items(id integer PRIMARY KEY, note text);
INSERT INTO items(id, note) VALUES (1, 'seed');

CREATE FUNCTION try_insert(wanted integer) RETURNS text
LANGUAGE plpgsql AS $$
DECLARE returned_state text;
BEGIN
    INSERT INTO items(id, note) VALUES (wanted, 'body');
    RETURN 'inserted';
EXCEPTION WHEN unique_violation THEN
    GET STACKED DIAGNOSTICS returned_state = RETURNED_SQLSTATE;
    INSERT INTO items(id, note) VALUES (wanted + 1, 'handler');
    RETURN returned_state;
END
$$;

SELECT try_insert(1);

The protected block is executed with subtransaction behavior. If an error occurs, persistent changes made inside that block are rolled back before the handler runs; changes made before entering the block remain. Keep the handler narrow: if the block contains several statements that can violate different unique constraints, a caught unique_violation does not by itself prove which operation caused it. PostgreSQL’s own PL/pgSQL documentation warns about this shape in generic upsert handlers.

Choose the business operation (case: on_conflict_target_scope)

ON CONFLICT is a tool for an intentional conflict policy, not a general instruction to hide duplicates. A conflict target chooses the arbiter. In the runtime case, an existing row occupied phone='phone-1':

CREATE TABLE accounts(
    id integer PRIMARY KEY,
    email text NOT NULL,
    phone text NOT NULL,
    CONSTRAINT accounts_email_uq UNIQUE (email),
    CONSTRAINT accounts_phone_uq UNIQUE (phone)
);
INSERT INTO accounts VALUES (1, 'existing@example.test', 'phone-1');

INSERT INTO accounts(id,email,phone)
VALUES (2, 'existing@example.test', 'phone-2')
ON CONFLICT (email) DO NOTHING;

-- Handles an email conflict only. A phone-only conflict still raises 23505.
INSERT INTO accounts(id,email,phone)
VALUES (3, 'new@example.test', 'phone-1')
ON CONFLICT (email) DO NOTHING;

-- With no target, DO NOTHING covers a conflict with any usable arbiter.
INSERT INTO accounts(id,email,phone)
VALUES (4, 'third@example.test', 'phone-1')
ON CONFLICT DO NOTHING;

For DO UPDATE, make the update deterministic and check its business result. For an idempotency key, compare the incoming request’s relevant identity and parameters with the stored request, then verify the existing business result before returning “already processed.” A key collision alone is not proof that the earlier request was equivalent.

Repair sequences carefully (case: sequence_lag_repair)

A manually supplied key can leave a sequence behind the table. The controlled runtime case used a non-default sequence:

The second nextval insert below is the natural duplicate trigger. The setval call is followed by a real insert that verifies the repaired next value.

CREATE SEQUENCE ids_seq START WITH 100 INCREMENT BY 7 MINVALUE 100 MAXVALUE 100000;
CREATE TABLE items(id integer PRIMARY KEY, note text);
INSERT INTO items(id,note) VALUES (100, 'explicit');
INSERT INTO items(id,note) VALUES (nextval('ids_seq'), 'generated');
SELECT setval('ids_seq', (SELECT max(id) FROM items), true);
INSERT INTO items(id,note) VALUES (nextval('ids_seq'), 'after repair');

After the controlled setval, the next value was 107. This is a repair pattern with explicit preconditions: quiesce writers, confirm the sequence identity and ownership, handle an empty table without passing an invalid value, and inspect increment, bounds, cache, and is_called. setval is not a universal concurrent repair; sequence changes are not rolled back like ordinary table writes.

Retry only when the operation is retryable

The serialization failure guidance documents a class of cases where concurrent key selection can surface as 23505. When the application has established that meaning, retry the complete transaction, including the key-selection logic, and apply a bounded backoff and an idempotency policy. Do not retry blindly: a duplicate requested by the user can be permanent, and repeated retries can produce the same conflict.

For the two-session case, the conflict happened after a lock-established ordering. The runner does not claim that every application operation with the same code is safe to retry.

Handle failed concurrent index builds (case: index_build_conflict)

The CREATE INDEX documentation explains that a concurrent build can leave an INVALID index when a scan problem such as a uniqueness failure occurs. In this duplicate-scan case, pg_index showed indisvalid=false, indisready=false, indislive=true, and indisunique=true; the regular transactional build left no index after rollback. Resolve duplicates, inspect the actual catalog state, drop a leftover invalid index when appropriate, and retry. Do not generalize this state to every possible CREATE INDEX CONCURRENTLY failure stage.

Versions and boundaries

The same SQLSTATE was observed in both PostgreSQL 10.21 and 18.6. Source line numbers and internal function names differ between those releases; use the SQLSTATE and the operation context rather than a source line as the compatibility contract.

UNIQUE NULLS NOT DISTINCT is available in PostgreSQL 15 and later and must be selected explicitly. The runtime case inserted two NULLs into a default unique column successfully, while a separately declared UNIQUE NULLS NOT DISTINCT constraint raised 23505 on the second NULL. An upgrade does not silently change the old default to NULLS NOT DISTINCT.

The separate boundary comparison records the executed availability and behavior: PostgreSQL 14.24 accepted two ordinary NULL rows but rejected the explicit declaration with 42601 and no 23505; PostgreSQL 15.19 raised 23505 on the second explicit NULL, left the autocommit session IDLE, and committed the valid repair. These records are retained separately and do not inflate the base selected case counts. On another disposable target, check the version before executing the branch: run ordinary_create, ordinary_first, ordinary_second, and ordinary_verify; then run explicit_create. If explicit_create returns the expected PG14 42601, stop that boundary case and do not send explicit_first, explicit_second, explicit_repair, or explicit_verify. Only when explicit_create succeeds on PG15 or later should you continue with the explicit inserts, observe the second-NULL result, and then run the repair and verification steps.

-- ordinary_create
CREATE TABLE ordinary_nulls (external_id integer UNIQUE);
-- ordinary_first
INSERT INTO ordinary_nulls VALUES (NULL);
-- ordinary_second
INSERT INTO ordinary_nulls VALUES (NULL);
-- ordinary_verify
SELECT count(*) FROM ordinary_nulls;
-- explicit_create
CREATE TABLE explicit_nulls (external_id integer, CONSTRAINT nulls_not_distinct_uq UNIQUE NULLS NOT DISTINCT (external_id));
-- explicit_first
INSERT INTO explicit_nulls VALUES (NULL);
-- explicit_second
INSERT INTO explicit_nulls VALUES (NULL);
-- explicit_repair
INSERT INTO explicit_nulls VALUES (1);
-- explicit_verify
SELECT count(*) FROM explicit_nulls;

PostgreSQL 18’s logical conflict reporter uses labels such as insert_exists in its apply context. That message change does not turn the relevant unique conflict into a different SQLSTATE. The current evidence is source and documentation based; the runtime report does not claim a replication topology was tested.

The locked catalogue has a definition-presence observation for 23505 at PostgreSQL 7.4 and through the 8.4.22 pre-9.0 definitions, then in every listed formal snapshot through PostgreSQL 18.6 and the PostgreSQL 19 Beta 3 preview. This is a definition-only presence boundary, not an exact implementation introduction or runtime-use claim.

Sources and evidence

Evidence IDs used by this page are identity.class-and-condition, runtime.dml-template, runtime.protocol-fields, runtime.index-build-template, runtime.logical-apply-sqlstate, runtime.tx-contexts, runtime.retry-boundary, runtime.on-conflict-scope, runtime.sequence-repair-limit, runtime.nulls-choice, runtime.detail-visibility, and runtime.version-boundary in the public evidence JSON. The selected runtime records use the base run for unreplaced cases, 23505-diagnostic-snippet-20260909 for DML, 23505-log-fields-final-20260909 for exact collector correlation, 23505-snippet-contract-20260909 for the registry excerpts, and the manual-boundary runs for explicit transaction and savepoint recovery. The separate boundary records are runtime.23505-boundary-pg14-20260909.pg14 and runtime.23505-boundary-pg15-20260909.pg15; they are a version comparison, not additions to the base case count. Superseded full-run selections remain local audit data.

114 - 23514 — check_violation

PostgreSQL SQLSTATE 23514: check_violation with CHECK and partition validation boundaries.

23514 — check_violation

At a glance

23514 means a CHECK or related row constraint evaluated as false. The selected named constraint is amount_positive; the server reports the table and constraint and the invalid row detail.

Field Value
SQLSTATE 23514
Condition check_violation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_CHECK_VIOLATION
Aliases

Meaning

For an ordinary table row, the executor evaluates the CHECK expression and reports 23514 when it is false; a CHECK expression that evaluates to NULL passes PostgreSQL’s CHECK rule, so add NOT NULL when NULL itself is forbidden. Partition routing can report no partition of relation ... found for row with a partition-key detail, while a partition constraint check reports a partition-constraint message. Domain validation has its own “values that violate the new constraint” template, and an empty WITHOUT OVERLAPS value is another source path. These are the same SQLSTATE with different mechanisms and messages.

Diagnosis

Record constraint_name, table_name, and the failing-row or partition-key detail. Re-evaluate the expression with the actual types and NULL behavior, including implicit casts and trigger changes. For a partition error, inspect the partition bounds and the route selected by the key; for a domain or validation error, identify the schema object whose rule was checked. The selected autocommit case became IDLE after the error; explicit transactions still require the caller’s rollback or handler boundary.

Response

Correct the value or the business rule, then retry. If the rule is changing, validate existing rows and deploy the new constraint deliberately; do not disable a CHECK to hide bad data. For partitions, route the row to a partition whose bound admits it rather than treating the error as a generic row retry.

Observed diagnostics

18.6 (Homebrew) / latest:SQLSTATE 23514; primary new row for relation "items" violates check constraint "amount_positive"; DETAIL Failing row contains (2, -1).; status_after_error IDLE. 10.21 (Debian 10.21-1.pgdg90+1) / pg10:SQLSTATE 23514; primary new row for relation "items" violates check constraint "amount_positive"; DETAIL Failing row contains (2, -1).; status_after_error IDLE.

Representative case

In this example, the first insert violates the named CHECK because amount is -1; changing it to 1 is the concrete repair. The complete setup, assertions, and cleanup are in the case export:

-- create
CREATE TABLE items(id integer PRIMARY KEY, amount integer CONSTRAINT amount_positive CHECK (amount > 0));
-- seed
INSERT INTO items VALUES (1, 10);
-- trigger
INSERT INTO items VALUES (2, -1);
-- repair
INSERT INTO items VALUES (2, 1);
-- verify
SELECT id, amount FROM items ORDER BY id;

The SQLSTATE, diagnostic, transaction-state, and repair assertions for this excerpt are produced from the checked case registry; see the structured evidence and case export.

Authored evidence IDs: identity, row-path, schema-path, runtime. Selected runtime records: runtime.23514-batch1-latest-20260909.latest, runtime.23514-batch1-pg10-20260909.pg10.

Versions

The locked catalogue observes the condition by 7.4 and in all listed formal snapshots. The selected runtime covers one immediate named CHECK INSERT on 18.6 and 10.21. It does not cover partition routing, domain validation, validation-time errors, or the WITHOUT OVERLAPS path. The fixed DDL documentation describes CHECK as passing when its expression is true or NULL; it does not define a DEFERRABLE CHECK path.

Compare 23502 NOT NULL violation, 23P01 exclusion violation, and 23505 unique violation.

Sources

115 - 23P01 — exclusion_violation

PostgreSQL SQLSTATE 23P01: exclusion_violation for conflicting exclusion-constraint operators.

23P01 — exclusion_violation

At a glance

23P01 means an exclusion constraint found an existing row for which all configured comparison operators conflict. The selected range case uses &&, so it rejects an overlap rather than merely a duplicate value.

Field Value
SQLSTATE 23P01
Condition exclusion_violation
Status active
Known present by 9.0.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_EXCLUSION_VIOLATION
Aliases

Meaning

An exclusion constraint combines an index access method with operators such as range overlap. In the case registry, [5,12) conflicts with [1,10), while [10,12) is accepted because PostgreSQL’s half-open ranges do not overlap at 10. Operator classes and the configured operator combination determine the result; DEFERRABLE changes when the conflict is checked.

Diagnosis

Capture constraint_name, the key values in DETAIL, and whether the constraint is immediate or deferred. Inspect the existing rows with the same operator semantics; equality checks alone are insufficient. An immediate conflict is raised at the statement boundary, while a DEFERRABLE conflict can surface at SET CONSTRAINTS or COMMIT. The selected case is immediate and runs in autocommit mode, so its connection returns IDLE after the rejected insert.

Response

Choose a non-conflicting value or coordinate the conflicting booking/resource under the application’s concurrency policy. In autocommit, a failed statement ends its own transaction boundary and the connection can be reused. In an explicit transaction, an immediate error can leave the transaction aborted just as a deferred error can; issue ROLLBACK, or ROLLBACK TO SAVEPOINT when the operation was deliberately isolated in a savepoint, before retrying the complete operation. A DEFERRABLE conflict may be reported at SET CONSTRAINTS or COMMIT, so retry from the clean boundary required by that check point; retry only when the operation is safe and the conflict can actually resolve. Do not “fix” an overlap by changing range bounds without applying the business rule.

Observed diagnostics

18.6 (Homebrew) / latest:SQLSTATE 23P01; primary conflicting key value violates exclusion constraint "bookings_no_overlap"; DETAIL Key (during)=([5,12)) conflicts with existing key (during)=([1,10)).; status_after_error IDLE. 10.21 (Debian 10.21-1.pgdg90+1) / pg10:SQLSTATE 23P01; primary conflicting key value violates exclusion constraint "bookings_no_overlap"; DETAIL Key (during)=([5,12)) conflicts with existing key (during)=([1,10)).; status_after_error IDLE.

Representative case

In this example, the second booking overlaps the existing range and is repaired by moving its lower bound to the existing upper bound. The complete setup, assertions, and cleanup are in the case export:

-- create
CREATE TABLE bookings(id integer PRIMARY KEY, during int4range NOT NULL, CONSTRAINT bookings_no_overlap EXCLUDE USING gist (during WITH &&));
-- seed
INSERT INTO bookings VALUES (1, int4range(1, 10));
-- trigger
INSERT INTO bookings VALUES (2, int4range(5, 12));
-- repair
INSERT INTO bookings VALUES (2, int4range(10, 12));
-- verify
SELECT id, during::text FROM bookings ORDER BY id;

The SQLSTATE, diagnostic, transaction-state, and repair assertions for this excerpt are produced from the checked case registry; see the structured evidence and case export.

Authored evidence IDs: identity, mechanism, runtime. Selected runtime records: runtime.23P01-batch1-latest-20260909.latest, runtime.23P01-batch1-pg10-20260909.pg10.

Versions

The locked catalogue observes 23P01 from the 9.0.0 boundary and in every listed formal snapshot. The selected immediate range case passes on 18.6 and 10.21; it does not test deferred or concurrent exclusion checks.

Compare 23505 unique violation, 23514 CHECK violation, and 23001 RESTRICT violation.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6 (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)
  • src.execIndexing.18.6 (SHA-256 24c80553ab4b28d7d2a288dd9196c8db9459c7f308853cd8c8c939485e15f199)
  • doc.rangetypes.18.6 (SHA-256 cfeffb134d2acc2ec45141726583b041410665c4a2f8ecf66cd3f9484a7f0014) · official documentation

116 - 24000 — invalid_cursor_state

PostgreSQL SQLSTATE 24000: invalid_cursor_state for a cursor that is not positioned on a row.

24000 — invalid_cursor_state

At a glance

24000 means the cursor or portal state does not satisfy the operation. The selected CURRENT OF case declares a valid cursor but tries to update before FETCH has positioned it, producing “cursor … is not positioned on a row”.

Field Value
SQLSTATE 24000
Condition invalid_cursor_state
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_CURSOR_STATE
Aliases

Meaning

WHERE CURRENT OF needs a cursor declared for an updatable query, with a current row selected by FETCH. Declaration alone is not positioning. PostgreSQL uses 24000 for other cursor states too, including non-SELECT, held, non-updatable, or missing FOR UPDATE/SHARE references.

Diagnosis

Record the cursor name and operation, then inspect declaration, transaction lifetime, FETCH direction, and whether the cursor is updatable. In an explicit transaction the selected error leaves INERROR; ROLLBACK restores IDLE. The selected repair updates by primary key, so it verifies transaction recovery and a safe direct repair, not a second DECLARE/FETCH path.

Response

Position the cursor with FETCH before CURRENT OF, or use a deterministic key-based update when that is the intended operation. Keep cursor lifetime and transaction boundaries explicit, and roll back a failed transaction before issuing the repair.

Observed diagnostics

18.6 (Homebrew) / latest:SQLSTATE 24000; primary cursor "item_cursor" is not positioned on a row; after_error INERROR; after_rollback IDLE. 10.21 (Debian 10.21-1.pgdg90+1) / pg10:SQLSTATE 24000; primary cursor "item_cursor" is not positioned on a row; after_error INERROR; after_rollback IDLE.

Representative case

The runner reads these statements from verify/cases/24000/snippets.json (SHA-256 cafca57825378362df0527384614bf658bf86cd3101e1eb520ea0641819f2789) and qualifies the temporary table names; the complete setup, assertions, and cleanup are in the case export.

-- create
CREATE TABLE items(id integer PRIMARY KEY, note text NOT NULL);
-- seed
INSERT INTO items VALUES (1, 'seed');
-- begin
BEGIN;
-- declare
DECLARE item_cursor CURSOR FOR SELECT id FROM items FOR UPDATE;
-- trigger
UPDATE items SET note = 'bad' WHERE CURRENT OF item_cursor;
-- rollback
ROLLBACK;
-- repair
UPDATE items SET note = 'repaired' WHERE id = 1;
-- verify
SELECT id, note FROM items;

The SQLSTATE, diagnostic, transaction-state, and repair assertions for this excerpt are produced from the shared registry; structured evidence · case export.

Authored evidence IDs: identity, current-of, runtime. Selected runtime records: runtime.24000-batch1-latest2-20260909.latest, runtime.24000-batch1-pg10-20260909.pg10.

Versions

The locked catalogue observes the condition by 7.4 and in all listed formal snapshots. The selected before-FETCH path passes on 18.6 and 10.21; other cursor-state templates require separate cases.

Compare 25001 active SQL transaction, 25P02 failed SQL transaction, and 34000 invalid cursor name.

Sources

117 - 25000 — invalid_transaction_state

PostgreSQL SQLSTATE 25000: the broad invalid_transaction_state condition and its internal parallel-operation boundary.

25000 — invalid_transaction_state

At a glance

25000 is the broad Class 25 invalid transaction state. The locked 18.6 source uses it for internal states such as executing a utility or defining a savepoint during a parallel operation. This batch does not claim a safe ordinary SQL reproduction.

Field Value
SQLSTATE 25000
Condition invalid_transaction_state
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_TRANSACTION_STATE
Aliases

Meaning

Transaction state is more specific than “a transaction exists”. The same class contains 25001 for active transaction restrictions and 25P02 for a failed transaction. The resolved 18.6 call scan shows 25000 guards in heap access, transaction, utility, GUC, and savepoint paths that depend on parallel-worker state.

Diagnosis

First distinguish a failed transaction (25P02), an active transaction block restriction (25001), and a parallel-operation state (25000). For a natural client error, preserve the exact source SQLSTATE and message; do not infer 25000 from a generic “transaction is open” observation.

Response

Follow the command’s documented transaction and parallel-worker contract. If the server reports a recoverable client transaction state, use the exact rollback or retry boundary; if it is an internal parallel-operation guard, collect server logs and context before changing application SQL. Do not manufacture a natural result with RAISE.

Source message templates

  • parallel-savepoint: primary cannot define savepoints during a parallel operation (ERROR).
  • parallel-utility: primary cannot execute %s during a parallel operation (ERROR).

Applicability boundary

This batch does not construct a natural SQL trigger for 25000; treat it as a source/protocol boundary rather than a copyable reproduction. structured evidence · case export.

Authored evidence IDs: identity, core-paths, boundary. Selected runtime records: —.

Versions

The locked catalogue observes the condition by 7.4 and in all listed formal snapshots. The 18.6 source scan confirms the cited parallel-operation paths; this page intentionally has no runtime case because the required internal state is not a safe standalone SQL precondition.

Compare 25001 active SQL transaction, 25P02 failed SQL transaction, and 40001 serialization failure.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6 (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)
  • src.xact.18.6 (SHA-256 75b012c0b047d1dc905a30975c244beec366e45eac0dbf109fd21bcd611a8e39)
  • src.utility.18.6 (SHA-256 7aae5d07628b6debf8456d1d4ea96f28912232192e56ea25773b4c4b61235a00)

118 - 25001 — active_sql_transaction

PostgreSQL SQLSTATE 25001: active_sql_transaction and the explicit transaction boundary required by utility commands.

25001 — active_sql_transaction

At a glance

25001 means the command requires a transaction boundary that the current session violates. The selected case runs VACUUM after BEGIN, receives the exact active-transaction error, rolls back, and then successfully runs VACUUM outside the transaction block.

Field Value
SQLSTATE 25001
Condition active_sql_transaction
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_ACTIVE_SQL_TRANSACTION
Aliases

Meaning

PostgreSQL uses 25001 for several paths. PreventInTransactionBlock rejects a prohibited utility in an explicit transaction block, subtransaction, or function; the source formats these as %s cannot run inside a transaction block, %s cannot run inside a subtransaction, and %s cannot be executed from a function. Other paths reject creating a logical replication slot after transaction writes, exporting a snapshot from a subtransaction, or setting an imported snapshot after a query. BEGIN inside an already active block is a separate WARNING, so severity and recovery depend on the source path.

Diagnosis

Record SQLSTATE, severity, primary message, transaction status, and the command. In the selected case the VACUUM ERROR moves the explicit session to INERROR; only ROLLBACK restores IDLE. For a function or subtransaction report, end that context and issue the command as one top-level utility statement outside any explicit transaction block (for example, a single command on an autocommit connection); retrying inside the same wrapper cannot satisfy PreventInTransactionBlock. For logical-slot and snapshot reports, inspect whether the transaction has writes, a subtransaction, or an earlier query. A WARNING that a transaction is already in progress is not the VACUUM ERROR and does not by itself require rollback. The selected repair then executes VACUUM items outside the transaction block and asserts success plus IDLE, proving the repair boundary instead of merely proving the connection is usable.

Response

Move a prohibited utility outside the transaction block, function, or subtransaction that violates its contract: issue it as one top-level command outside any explicit transaction block, typically on an autocommit connection. After an ERROR in an explicit transaction, issue ROLLBACK before reuse; do not put the retry inside another BEGIN. A logical replication slot must be created in a transaction with no prior writes; export a snapshot outside a subtransaction, and call SET TRANSACTION SNAPSHOT before any query. Preserve an already active transaction after the WARNING branch instead of rolling it back solely because BEGIN was repeated. Follow the exact source path rather than applying the VACUUM repair mechanically.

Observed diagnostics

18.6 (Homebrew) / latest:SQLSTATE 25001; primary VACUUM cannot run inside a transaction block; after_error INERROR; after_rollback IDLE; status_after_vacuum IDLE. 10.21 (Debian 10.21-1.pgdg90+1) / pg10:SQLSTATE 25001; primary VACUUM cannot run inside a transaction block; after_error INERROR; after_rollback IDLE; status_after_vacuum IDLE.

Source message templates

The selected VACUUM run does not cover these source-backed branches:

  • ERROR %s cannot run inside a subtransaction (the command name is substituted).
  • ERROR %s cannot be executed from a function (the command name is substituted).
  • ERROR cannot create logical replication slot in transaction that has performed writes.
  • ERROR cannot export a snapshot from a subtransaction.
  • ERROR SET TRANSACTION SNAPSHOT must be called before any query.
  • WARNING there is already a transaction in progress.

These templates are source evidence, not additional runtime claims for this case.

Representative case

In this example, VACUUM is rejected inside an explicit BEGIN block; after ROLLBACK, the same utility succeeds as a standalone command outside that block. The complete setup, assertions, and cleanup are in the case export:

-- create
CREATE TABLE items(id integer PRIMARY KEY, note text NOT NULL);
-- seed
INSERT INTO items VALUES (1, 'seed');
-- begin
BEGIN;
-- trigger
VACUUM items;
-- rollback
ROLLBACK;
-- followup
SELECT 1 AS usable;
-- repair
VACUUM items;

The SQLSTATE, diagnostic, transaction-state, and repair assertions for this excerpt are produced from the checked case registry; see the structured evidence and case export.

Authored evidence IDs: identity, utility-path, other-paths, runtime. Selected runtime records: runtime.25001-batch1-latest2-20260909.latest, runtime.25001-batch1-pg10b-20260909.pg10.

Versions

The locked catalogue observes the condition by 7.4 and in all listed formal snapshots. The selected VACUUM case passes on 18.6 and 10.21, including rollback recovery and the successful outside-transaction repair; other 25001 paths are source-backed only.

Compare 25000 invalid transaction state, 25P02 failed SQL transaction, and 24000 invalid cursor state.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6 (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)
  • src.xact.18.6 (SHA-256 75b012c0b047d1dc905a30975c244beec366e45eac0dbf109fd21bcd611a8e39)
  • src.logical.18.6 (SHA-256 3f1bd4c3e627fe78522c4dc9bacf9fa8200e6c82c2d01f7670706eee102b76d1)
  • src.snapmgr-export.18.6 (SHA-256 b605b69e77a026c143f4cabca079de364b9a8732bfc40f7595be44fb0971ee8)
  • src.snapmgr-set-snapshot.18.6 (SHA-256 b605b69e77a026c143f4cabca079de364b9a8732bfc40f7595be44fb0971ee8)
  • doc.vacuum.18.6 (SHA-256 80ca5592cda7b74938385f84f09faac33574374c1a05d605a2d55982e4cf1bbf) · official documentation

119 - 25002 — branch_transaction_already_active

PostgreSQL SQLSTATE 25002: the narrow branch_transaction_already_active definition.

25002 — branch_transaction_already_active

At a glance

25002 names a branch transaction that is already active. It is narrower than 25001 and separate from 25P02; this page records the locked condition definition and the absence of a resolved core 18.6 call site.

Field Value
SQLSTATE 25002
Condition branch_transaction_already_active
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_BRANCH_TRANSACTION_ALREADY_ACTIVE
Aliases

Meaning

The code belongs to Class 25, but it should not be used as a generic label for nested transactions or savepoints. PostgreSQL’s core errcodes.txt defines the macro, while the exhaustive resolved 18.6 call scan in this project contains no direct 25002 report group.

Diagnosis

Use the exact server SQLSTATE and transaction context. Distinguish a branch/transaction-management API from ordinary savepoints, subtransactions, active transaction-block restrictions, and failed-transaction recovery. A missing core report group is not permission to infer a message or trigger from another code.

Response

Preserve the branch-management operation and its transaction boundary, then consult the API that created the branch. This batch does not provide a natural SQL repair because no safe core path was confirmed; do not replace the missing path with a hand-written RAISE example.

Source message templates

Applicability boundary

This batch does not construct a natural SQL trigger for 25002; treat it as a source/protocol boundary rather than a copyable reproduction. structured evidence · case export.

Authored evidence IDs: identity, source-boundary. Selected runtime records: —.

Versions

The locked catalogue observes the condition by 7.4 and in all listed formal snapshots. The 18.6 call scan has no resolved core path; extensions or future code may add one.

Compare 25001 active SQL transaction, 25000 invalid transaction state, and 3B000 savepoint exception.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6 (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

120 - 25003 — inappropriate_access_mode_for_branch_transaction

PostgreSQL SQLSTATE 25003: the branch-transaction access-mode condition, with a conservative source boundary.

25003 — inappropriate_access_mode_for_branch_transaction

At a glance

25003 is the SQLSTATE name for an inappropriate access mode in a branch transaction. The fixed PostgreSQL 18.6 core scan resolves no direct report site, so this entry documents the definition boundary without inventing an ordinary SQL trigger.

Field Value
SQLSTATE 25003
Condition inappropriate_access_mode_for_branch_transaction
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION
Aliases

Meaning

The condition name belongs to Class 25 and describes branch-transaction management. It should not be used as a synonym for 25006 read-only SQL transactions, 25P01 missing transaction blocks, or an application-defined exception.

Diagnosis

When this code is reported by a branch-transaction API, retain the exact SQLSTATE, API operation, access mode, and transaction context. The current fixed core evidence does not provide a server message template or a safe SQL reproduction.

Response

Inspect the branch-transaction API contract and correct its access-mode choice before retrying. Do not replace the missing path with RAISE, and do not retry a regular read-only statement under this code.

Source message and runtime boundary

The fixed errcodes.txt row defines the condition and macro; the resolved call scan in raw/calls/REL_18_6.jsonl contains no direct report group, so this batch publishes no message template and constructs no natural SQL trigger.

Applicability boundary and case

The selected runner cases on PostgreSQL 18.6 and 10.21 are not_applicable; they record the source boundary and contain no copyable SQL trigger. Structured evidence · case export

Versions and limits

The locked catalogue records the condition by the generated known present by boundary and in the listed snapshots. Runtime status is deliberately not applicable: both selected runner targets record the source-only boundary, not a passed natural trigger.

25004 branch transaction isolation mode, 25006 read-only SQL transaction, 25P01 no active SQL transaction.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6raw/calls/REL_18_6.jsonl (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

121 - 25004 — inappropriate_isolation_level_for_branch_transaction

PostgreSQL SQLSTATE 25004: the branch-transaction isolation-level condition, with a fixed source boundary.

25004 — inappropriate_isolation_level_for_branch_transaction

At a glance

25004 names an inappropriate isolation level for a branch transaction. The fixed PostgreSQL 18.6 resolved-call scan has no direct report group for this code, so no ordinary SQL reproduction is claimed.

Field Value
SQLSTATE 25004
Condition inappropriate_isolation_level_for_branch_transaction
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION
Aliases

Meaning

This is a branch-transaction condition, separate from 40001 serialization failure and from the normal SET TRANSACTION ISOLATION LEVEL checks documented for an ordinary transaction.

Diagnosis

Keep the branch API, requested isolation level, and transaction state together when diagnosing it. The source evidence does not justify borrowing a message from another isolation-level error.

Response

Correct the isolation-level negotiation in the branch API, then retry only if that API defines retry semantics. An ordinary SQL session should be diagnosed with the SQLSTATE it actually returned.

Source message and runtime boundary

The fixed errcodes.txt row defines the condition and macro; the resolved call scan in raw/calls/REL_18_6.jsonl contains no direct report group, so this batch publishes no message template and constructs no natural SQL trigger.

Applicability boundary and case

The selected runner cases on PostgreSQL 18.6 and 10.21 are not_applicable; they record the source boundary and contain no copyable SQL trigger. Structured evidence · case export

Versions and limits

The generated facts record the locked catalogue snapshots. Both runner targets are source-boundary observations with not_applicable case status; no natural trigger is being promoted to runtime coverage.

25003 branch transaction access mode, 40001 serialization failure, 25P01 no active SQL transaction.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6raw/calls/REL_18_6.jsonl (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

122 - 25005 — no_active_sql_transaction_for_branch_transaction

PostgreSQL SQLSTATE 25005: the branch-transaction no-active-transaction condition and its source-only boundary.

25005 — no_active_sql_transaction_for_branch_transaction

At a glance

25005 is the branch-transaction form of a no-active-SQL-transaction condition. It is distinct from 25P01, and the fixed PostgreSQL 18.6 core scan does not resolve a natural server call site.

Field Value
SQLSTATE 25005
Condition no_active_sql_transaction_for_branch_transaction
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION
Aliases

Meaning

The code belongs to the branch-transaction family. A normal SAVEPOINT outside BEGIN is the 25P01 path demonstrated elsewhere; it must not be relabeled as 25005.

Diagnosis

Capture the branch API operation and whether it had an active branch transaction. With no resolved core message in the fixed scan, the exact server text must come from the reporting implementation that actually emitted the code.

Response

End or start the branch transaction according to that API’s contract. Do not send a generic rollback recipe based on the name alone, and do not fabricate a PL/pgSQL reproduction.

Source message and runtime boundary

The fixed errcodes.txt row defines the condition and macro; the resolved call scan in raw/calls/REL_18_6.jsonl contains no direct report group, so this batch publishes no message template and constructs no natural SQL trigger.

Applicability boundary and case

The selected runner cases on PostgreSQL 18.6 and 10.21 are not_applicable; they record the source boundary and contain no copyable SQL trigger. Structured evidence · case export

Versions and limits

The locked catalogue contains the generated historical membership facts. The selected latest and PG10 cases are both explicit source-only boundaries and are not natural runtime passes.

25P01 no active SQL transaction, 25003 branch transaction access mode, 25P02 failed SQL transaction.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6raw/calls/REL_18_6.jsonl (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

123 - 25006 — read_only_sql_transaction

PostgreSQL SQLSTATE 25006: read-only transaction failures, diagnostics, and the transaction boundary needed for repair.

25006 — read_only_sql_transaction

At a glance

25006 is returned when a command would write in a read-only transaction. The selected case issues CREATE TABLE after SET TRANSACTION READ ONLY, observes INERROR, rolls back, and creates the table after leaving the read-only block.

Field Value
SQLSTATE 25006
Condition read_only_sql_transaction
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_READ_ONLY_SQL_TRANSACTION
Aliases

Meaning

The code covers several guards. PreventCommandIfReadOnly formats the command name into cannot execute %s in a read-only transaction; the fixed source also has recovery-only messages for temporary tables and replication origins. The selected case covers the ordinary explicit read-only transaction path, while a standby or recovery path can use a different command-specific message.

Diagnosis

Record the exact command, SQLSTATE, severity, and transaction status. Before retrying, inspect the effective SHOW transaction_read_only and, for a server-level boundary, pg_is_in_recovery(); also identify whether a pool routed this connection to a standby. In the selected run, CREATE TABLE returns 25006 and leaves the explicit block INERROR; ROLLBACK is required before the same session can be used. A later CREATE TABLE outside the read-only block succeeds.

Response

Decide whether the operation belongs in a read-only transaction. If it must write, use a read/write transaction on the primary or run it outside the read-only block, and roll back the failed block before returning the connection to a pool. A standby or recovery-only 25006 path requires routing the operation to the primary; retrying the same write on the same target cannot change its access mode.

Source messages

The core utility template is cannot execute %s in a read-only transaction. The same utility guard uses cannot execute %s during recovery on a recovery target; recovery-only temporary-table and replication-origin paths have their own fixed text. %s is the executing command name, so these are not context-free static messages.

Observed diagnostics

18.6 (Homebrew) / latest: SQLSTATE 25006; primary cannot execute CREATE TABLE in a read-only transaction; INERROR → IDLE; repaired relation count 0; final IDLE. 10.21 (Debian 10.21-1.pgdg90+1) / pg10: SQLSTATE 25006; primary cannot execute CREATE TABLE in a read-only transaction; INERROR → IDLE; repaired relation count 0; final IDLE.

Representative case

The runner reads the setup, read-only transaction, rollback, and outside-block repair statements below from the shared registry; complete assertions, environment, and cleanup are in case export.

-- create
CREATE TABLE items(id integer PRIMARY KEY, note text NOT NULL);
-- begin
BEGIN;
-- read_only
SET TRANSACTION READ ONLY;
-- trigger
CREATE TABLE blocked(id integer PRIMARY KEY);
-- rollback
ROLLBACK;
-- repair
CREATE TABLE blocked(id integer PRIMARY KEY);
-- verify
SELECT count(*) FROM blocked;

The SQLSTATE, diagnostics, states, and repair assertions for this excerpt come from the shared registry (SHA-256 62db30e401b1f72fa50958d0ac612b2b1eb636299532dd1ad246c167e4f9fadf); structured evidence.

Authored evidence IDs: identity, utility-path, other-paths, runtime. Selected runtime records: runtime.25006-batch2-latest-20260909.latest, runtime.25006-batch2-pg10-20260909.pg10.

Versions and limits

The selected CREATE TABLE case passes on PostgreSQL 18.6 and 10.21 with the same primary text, INERROR → IDLE recovery, and a successful repaired relation. Other 25006 source paths remain outside this runtime case.

25P02 failed SQL transaction, 25001 active SQL transaction, 25P03 idle-in-transaction timeout.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6raw/calls/REL_18_6.jsonl (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)
  • src.utility.18.6 (SHA-256 7aae5d07628b6debf8456d1d4ea96f28912232192e56ea25773b4c4b61235a00)
  • src.namespace.18.6 (SHA-256 8c9e6a99e84fa2cec8a9b1de2ecbe3966a13f4ad68c6ccfbfb8134a754d73e56)
  • src.origin.18.6 (SHA-256 81e5d5b4539b67bb372f0f0a05395af900c322cdbcec8a4b1f358333a16e6518)
  • doc.set-transaction.18.6 (SHA-256 33554463a2c9da1cf2c72cc27d4647d557204bb13a03cfeccb1b83f237a46589) · official documentation

124 - 25007 — schema_and_data_statement_mixing_not_supported

PostgreSQL SQLSTATE 25007: the schema/data statement mixing condition and its conservative source boundary.

25007 — schema_and_data_statement_mixing_not_supported

At a glance

25007 names a transaction-state condition for mixing schema and data statements. The fixed PostgreSQL 18.6 core scan resolves no direct report group, so this page does not manufacture a SQL example.

Field Value
SQLSTATE 25007
Condition schema_and_data_statement_mixing_not_supported
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED
Aliases

Meaning

The condition name describes a narrow statement-composition boundary. It is not a general replacement for syntax, read-only, or active-transaction errors.

Diagnosis

Keep the protocol or API operation, statement sequence, and exact server SQLSTATE together. The fixed core evidence has no message template to quote and no safe natural case to run.

Response

Use the API’s documented statement grouping and separate schema changes from data operations when it requires that boundary. Do not invent a retry or RAISE path from the condition name.

Source message and runtime boundary

The fixed errcodes.txt row defines the condition and macro; the resolved call scan in raw/calls/REL_18_6.jsonl contains no direct report group, so this batch publishes no message template and constructs no natural SQL trigger.

Applicability boundary and case

The selected runner cases on PostgreSQL 18.6 and 10.21 are not_applicable; they record the source boundary and contain no copyable SQL trigger. Structured evidence · case export

Versions and limits

The generated facts record the locked catalogue membership. Both runner targets are not_applicable source-boundary cases; no natural runtime coverage is claimed.

25006 read-only SQL transaction, 25008 held cursor isolation, 25P01 no active SQL transaction.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6raw/calls/REL_18_6.jsonl (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

125 - 25008 — held_cursor_requires_same_isolation_level

PostgreSQL SQLSTATE 25008: the held-cursor isolation-level condition and its source-only boundary.

25008 — held_cursor_requires_same_isolation_level

At a glance

25008 is reserved for a held cursor whose transaction isolation level is not compatible with the required operation. The fixed PostgreSQL 18.6 core scan has no direct report group for it.

Field Value
SQLSTATE 25008
Condition held_cursor_requires_same_isolation_level
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL
Aliases

Meaning

This is narrower than 24000 invalid cursor state and unrelated to the general 40001 serialization retry path. A cursor being held across transactions does not by itself prove that 25008 was emitted.

Diagnosis

Capture the cursor declaration, holdability, isolation level of both transactions, and exact SQLSTATE from the actual reporting implementation. This fixed evidence provides no message template or copyable SQL trigger.

Response

Keep the cursor and consuming transaction at a compatible isolation level, or close and re-declare it according to the API contract. Do not substitute a 24000 repair or a generic rollback without the actual state.

Source message and runtime boundary

The fixed errcodes.txt row defines the condition and macro; the resolved call scan in raw/calls/REL_18_6.jsonl contains no direct report group, so this batch publishes no message template and constructs no natural SQL trigger.

Applicability boundary and case

The selected runner cases on PostgreSQL 18.6 and 10.21 are not_applicable; they record the source boundary and contain no copyable SQL trigger. Structured evidence · case export

Versions and limits

The generated facts record the locked catalogue membership. The selected latest and PG10 cases intentionally remain source-only and not_applicable.

24000 invalid cursor state, 25004 branch transaction isolation, 40001 serialization failure.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6raw/calls/REL_18_6.jsonl (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

126 - 25P01 — no_active_sql_transaction

PostgreSQL SQLSTATE 25P01: operations such as SAVEPOINT require an explicit transaction block.

25P01 — no_active_sql_transaction

At a glance

25P01 reports that an operation needs an active SQL transaction. The selected case sends SAVEPOINT with autocommit enabled, receives the exact error while the session remains IDLE, then repeats the operation inside BEGIN and commits.

Field Value
SQLSTATE 25P01
Condition no_active_sql_transaction
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NO_ACTIVE_SQL_TRANSACTION
Aliases

Meaning

The source formats the statement name into %s can only be used in transaction blocks; the selected SAVEPOINT path is an ERROR. The same SQLSTATE also has COMMIT AND CHAIN/ROLLBACK AND CHAIN errors and no-transaction COMMIT/ROLLBACK warnings with the fixed text there is no transaction in progress.

Diagnosis

Check whether the client is in an explicit block before issuing SAVEPOINT, RELEASE SAVEPOINT, or ROLLBACK TO SAVEPOINT. In the selected run, the failed autocommit statement leaves IDLE; the repair uses BEGIN, SAVEPOINT, RELEASE, and COMMIT.

Response

Start an explicit transaction before creating a savepoint. If the operation was sent without a block, correct the client transaction wrapper and retry the intended operation; no rollback is needed for this autocommit error because no open failed block remains.

Source message

xact.c formats %s can only be used in transaction blocks; this case substitutes SAVEPOINT with ERROR. COMMIT AND CHAIN and ROLLBACK AND CHAIN use the same dynamic form when no block exists, while no-transaction COMMIT/ROLLBACK use the WARNING text there is no transaction in progress.

Observed diagnostics

18.6 (Homebrew) / latest: SQLSTATE 25P01; primary SAVEPOINT can only be used in transaction blocks; after-error IDLE; explicit repair INTRANS → IDLE. 10.21 (Debian 10.21-1.pgdg90+1) / pg10: SQLSTATE 25P01; primary SAVEPOINT can only be used in transaction blocks; after-error IDLE; explicit repair INTRANS → IDLE.

Representative case

The runner reads the no-block SAVEPOINT and explicit-block repair statements below from the shared registry; complete assertions, environment, and cleanup are in case export.

-- trigger
SAVEPOINT outside_block;
-- begin
BEGIN;
-- savepoint
SAVEPOINT inside_block;
-- release
RELEASE SAVEPOINT inside_block;
-- commit
COMMIT;
-- verify
SELECT 1;

The SQLSTATE, diagnostics, states, and repair assertions for this excerpt come from the shared registry (SHA-256 a1ffffc778f82789f1c1ac4027a109fc76e4b315ef2e3a5bdbfc47c8f84ce951); structured evidence.

Authored evidence IDs: identity, savepoint-path, runtime. Selected runtime records: runtime.25P01-batch2-latest-20260909.latest, runtime.25P01-batch2-pg10-20260909.pg10.

Versions and limits

The SAVEPOINT case returns 25P01 with the same primary text on 18.6 and 10.21, and the explicit-block repair finishes IDLE on both.

25005 branch transaction no active SQL transaction, 25P02 failed SQL transaction, 25006 read-only SQL transaction.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6raw/calls/REL_18_6.jsonl (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)
  • src.xact.18.6 (SHA-256 75b012c0b047d1dc905a30975c244beec366e45eac0dbf109fd21bcd611a8e39)
  • doc.savepoint.18.6 (SHA-256 aa6e167d373da6118249c87404a7b2ff8be8c7df790449814f1d9dc433bbd428) · official documentation
  • src.xact.savepoint.18.6 (SHA-256 75b012c0b047d1dc905a30975c244beec366e45eac0dbf109fd21bcd611a8e39)

127 - 25P02 — in_failed_sql_transaction

PostgreSQL SQLSTATE 25P02: the secondary transaction state after an earlier statement error.

25P02 — in_failed_sql_transaction

At a glance

25P02 is usually the second diagnostic, not the root cause. In the selected case a duplicate key first returns 23505; a following SELECT is rejected with 25P02 while the block remains INERROR. ROLLBACK is required before a valid retry.

Field Value
SQLSTATE 25P02
Condition in_failed_sql_transaction
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_IN_FAILED_SQL_TRANSACTION
Aliases

Meaning

postgres.c checks the aborted transaction state before planning another ordinary command and reports current transaction is aborted, commands ignored until end of transaction block. A driver exposes the corresponding failed transaction status; the original error remains the diagnostic anchor, while 25P02 tells the client that ordinary work is no longer admissible in this block.

Diagnosis

Locate the first statement error before acting on 25P02, and log both diagnostics with the connection transaction status. The selected runs show root 23505, then 25P02, INERROR after each, IDLE after ROLLBACK, and a committed valid row after a new explicit BEGIN/COMMIT. Check whether a savepoint was established before the root error: ROLLBACK TO SAVEPOINT can preserve the outer transaction, whereas without one the whole failed block must end. A pool must not hand an INERROR connection to another request.

Response

Stop issuing business statements after the first error. Preserve the root SQLSTATE and details. If a deliberately established savepoint is still usable, roll back to it and continue the outer transaction; otherwise issue ROLLBACK, verify the connection is IDLE, and start a fresh transaction. Re-evaluate the operation instead of blindly replaying the root statement.

Source message

The fixed primary message is current transaction is aborted, commands ignored until end of transaction block. It describes the state left by an earlier error and does not replace the root SQLSTATE, DETAIL, or constraint identity.

Observed diagnostics

18.6 (Homebrew) / latest: root SQLSTATE 23505; secondary SQLSTATE 25P02; after root/secondary INERROR; after rollback IDLE; rows [[1, 'seed'], [2, 'repaired']]. 10.21 (Debian 10.21-1.pgdg90+1) / pg10: root SQLSTATE 23505; secondary SQLSTATE 25P02; after root/secondary INERROR; after rollback IDLE; rows [[1, 'seed'], [2, 'repaired']].

Representative case

The runner reads the root error, secondary diagnostic, rollback, and valid retry statements below from the shared registry; complete assertions, environment, and cleanup are in case export.

-- create
CREATE TABLE items(id integer PRIMARY KEY, note text UNIQUE NOT NULL);
-- seed
INSERT INTO items VALUES (1, 'seed');
-- begin
BEGIN;
-- trigger
INSERT INTO items VALUES (2, 'seed');
-- followup
SELECT 1 AS ignored;
-- rollback
ROLLBACK;
-- repair_begin
BEGIN;
-- repair
INSERT INTO items VALUES (2, 'repaired');
-- commit
COMMIT;
-- verify
SELECT id, note FROM items ORDER BY id;

The SQLSTATE, diagnostics, states, and repair assertions for this excerpt come from the shared registry (SHA-256 04da3240dcf3c03fe60d13715f8187350fadf5b8d1f10e5b837acd45289759cd); structured evidence.

Authored evidence IDs: identity, abort-state, runtime. Selected runtime records: runtime.25P02-batch2-latest-20260909.latest, runtime.25P02-batch2-pg10-20260909.pg10.

Versions and limits

The selected duplicate-key-to-25P02 case passes on PostgreSQL 18.6 and 10.21. It demonstrates transaction-state recovery, not a claim that the duplicate itself can be retried unchanged.

23505 unique violation, 25P01 no active SQL transaction, 40001 serialization failure.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6raw/calls/REL_18_6.jsonl (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)
  • src.postgres.18.6 (SHA-256 9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061)
  • doc.libpq.18.6 (SHA-256 a91ce8f29dde162245d2f35f839e8b7192f62a57e01020b80564af65edd09440) · official documentation

128 - 25P03 — idle_in_transaction_session_timeout

PostgreSQL SQLSTATE 25P03: diagnosing and recovering from server termination of a session idle inside an open transaction.

25P03 — idle_in_transaction_session_timeout

At a glance

25P03 is a FATAL session-termination condition. It fires when a session is waiting for the next client query inside an open transaction longer than the effective idle_in_transaction_session_timeout. The selected case uses 300 ms as a harness trigger, not as a production recommendation.

Field Value
SQLSTATE 25P03
Condition idle_in_transaction_session_timeout
Status active
Known present by 9.6.0
Locked snapshots 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT
Aliases

Meaning

This timeout protects the server from sessions that keep an open transaction while waiting for the client; it can retain locks and delay cleanup. It applies while the session is idle in the transaction, including the idle in transaction and idle in transaction (aborted) states, not while an active statement is running. statement_timeout cancels a statement, while transaction_timeout covers the total transaction lifetime on versions that support it. The selected run covers the non-aborted INTRANS case only.

Diagnosis

Before the session disappears, capture its effective SHOW idle_in_transaction_session_timeout (or the matching pg_settings row) on that timed session itself. A control connection’s SHOW or pg_settings describes the observer backend and cannot establish another session’s effective SET value. From the control connection, inspect pg_stat_activity fields such as pid, usename, application_name, client_addr, state, xact_start, state_change, query_start, and query for state IN ('idle in transaction', 'idle in transaction (aborted)'). If the state is already aborted, preserve the earlier root error and 25P02 as separate diagnostics; the selected run is the non-aborted INTRANS path. These identify the pool or application path and how long it has been idle; permissions can limit what an observer sees. Correlate the FATAL record by backend PID, SQLSTATE, error_severity = FATAL, and exact message. The selected psycopg/libpq stack surfaced 25P03 in the driver diagnostic and CSV; PG18 also supplied JSON. The original connection is closed, so its transaction status cannot be repaired with ROLLBACK.

Response

Treat the session as gone: discard it from the pool and reconnect before retrying idempotent work. Prevent recurrence by committing or rolling back before returning a connection to the pool, and by fixing the application path that leaves a transaction open. Do not lower this timeout to suppress the error; a shorter value makes termination more likely. Choose an effective value above legitimate idle periods, or set it to 0 only when the deployment deliberately accepts the lock and cleanup risk. When the server closes this session, it rolls back the open incomplete transaction before exiting; the dead connection cannot accept a later ROLLBACK. A known uncommitted transaction on this terminated session cannot be recovered through that connection. If a separate network failure occurred after a COMMIT may have been sent, reconcile the business result from a fresh connection before retrying; that uncertainty is not implied by every 25P03 FATAL.

FATAL message

The server source emits terminating connection due to idle-in-transaction timeout at FATAL severity; the original connection is terminated.

Observed diagnostics

18.6 (Homebrew) / latest: FATAL SQLSTATE 25P03; primary terminating connection due to idle-in-transaction timeout; backend PID 26447; original connection closed True; collector CSV 25P03; collector JSON 25P03; fresh probe 1. 10.21 (Debian 10.21-1.pgdg90+1) / pg10: FATAL SQLSTATE 25P03; primary terminating connection due to idle-in-transaction timeout; backend PID 81; original connection closed True; collector CSV 25P03; collector JSON not applicable; fresh probe 1.

Representative case

The SQL excerpt below is not a paste-all script: run the setting, PID, and BEGIN on a test connection, then stop sending it queries while a separate observer or log collector waits for FATAL; after the old connection is terminated, open a fresh owner connection for the final probe. The runner reads these statements from the shared registry; complete assertions, collector correlation, environment, and cleanup are in case export.

-- set_timeout
SET idle_in_transaction_session_timeout = '300ms';
-- backend_pid
SELECT pg_backend_pid();
-- begin
BEGIN;
-- probe
SELECT 1;

The SQLSTATE, diagnostics, states, and repair assertions for this excerpt come from the shared registry (SHA-256 95fd079c8bca77c6e3ffc398e404a218e4f810e5fa36e30127cbc6470a6d6eb2); structured evidence.

Authored evidence IDs: identity, timeout-path, runtime. Selected runtime records: runtime.25P03-batch2c-latest-20260909.latest, runtime.25P03-batch2c-pg10-20260909.pg10.

Versions and limits

The selected 300 ms termination case passes on PostgreSQL 18.6 and 10.21. PG18 has CSV and JSON collector records; PG10 has CSV only under its configured logging target. Both fresh owner connections run SELECT 1 successfully. The timeout value is deployment-specific; the case does not prescribe it.

25P04 transaction timeout, 25006 read-only SQL transaction, 57014 query canceled.

Sources

129 - 25P04 — transaction_timeout

PostgreSQL SQLSTATE 25P04: session termination when an explicit or implicit transaction exceeds transaction_timeout.

25P04 — transaction_timeout

At a glance

25P04 is a FATAL condition emitted by transaction_timeout, which covers both an explicit BEGIN transaction and an implicitly started single-statement transaction. The selected 18.6 case uses 300 ms; PG10 is a source/version preflight skip because the setting is unavailable there, so it does not probe an unknown setting. A separate PG16.15/PG17.11 boundary comparison records unavailable-setting 42704 on PG16 and natural FATAL 25P04 on PG17; it is separate from the selected base case.

Field Value
SQLSTATE 25P04
Condition transaction_timeout
Status active
Known present by 17.0
Locked snapshots 17.11, 18.6, 19beta3
Macros ERRCODE_TRANSACTION_TIMEOUT
Aliases

Meaning

transaction_timeout limits the lifetime of an explicit or implicit transaction, including time spent executing or waiting while that transaction is open. When it fires, PostgreSQL emits terminating connection due to transaction timeout and terminates the session. It is different from statement_timeout, which aborts one statement, and from idle_in_transaction_session_timeout, which covers only client-idle time inside an open transaction. If transaction_timeout is shorter than or equal to either of those settings, the longer timeout is ignored; prepared transactions are not subject to it.

Diagnosis

On a supported server, capture the effective SHOW transaction_timeout, SHOW statement_timeout, and SHOW idle_in_transaction_session_timeout values on the timed session itself. A control connection’s SHOW or pg_settings describes the observer backend and cannot establish another session’s effective SET values. From the control connection inspect pg_stat_activity fields such as pid, application_name, state, xact_start, state_change, query_start, and query to identify the owning application or pool and whether the transaction is active or idle. Match the collector record by backend PID, SQLSTATE 25P04, error_severity = FATAL, and the exact message. In the selected 18.6 run the driver also exposed 25P04 and the original connection was closed; a fresh owner connection successfully ran SELECT 1. PG10 is skipped by the minimum-version preflight before SET transaction_timeout is sent.

Response

Discard the terminated session and reconnect. Keep legitimate transactions within the chosen budget by shortening work, splitting a long unit of work, or raising the effective timeout; do not lower it to hide the error. Set it to 0 only when the deployment deliberately accepts the absence of this guard. When the server closes the terminated session, it rolls back the open incomplete transaction before exiting; the dead connection cannot accept a later ROLLBACK. A known transaction that had not committed on that session cannot be recovered through that connection. If a separate network failure left it uncertain whether COMMIT reached the server, reconcile the business result from a fresh connection before retrying; the selected case sent no commit and does not establish that uncertainty. PG10 has no compatible setting in this batch.

FATAL message

The server source emits terminating connection due to transaction timeout at FATAL severity; the original connection is terminated.

Observed diagnostics

18.6 (Homebrew) / latest: FATAL SQLSTATE 25P04; primary terminating connection due to transaction timeout; backend PID 30576; original connection closed True; collector CSV 25P04; collector JSON 25P04; fresh probe 1. 10.21 (Debian 10.21-1.pgdg90+1) / pg10: case not_applicable (minimum-version preflight; the unsupported setting was not probed).

Separate boundary comparison: 16.15 / pg16 returned 42704 for unavailable transaction_timeout and remained IDLE, so it is not 25P04 coverage. 17.11 / pg17 produced FATAL 25P04 after 300 ms with backend PID 73; CSV and JSON both recorded FATAL 25P04, the original connection closed, and a fresh connection was IDLE. These records are outside the selected base case.

Representative case

The SQL excerpt below is not a paste-all script: run the setting, PID, and BEGIN on a test connection, then stop sending it queries while a separate observer or log collector waits for FATAL; after the old connection is terminated, open a fresh owner connection for the final probe. The runner reads these statements from the shared registry; complete assertions, collector correlation, environment, and cleanup are in case export.

-- set_timeout
SET transaction_timeout = '300ms';
-- backend_pid
SELECT pg_backend_pid();
-- begin
BEGIN;
-- probe
SELECT 1;

The SQLSTATE, diagnostics, states, and repair assertions for this excerpt come from the shared registry (SHA-256 d05a26e56716c5c8c178f741843e6b14be87423ec9d1eb1a026ff67a57ce4658); structured evidence.

Authored evidence IDs: identity, timeout-path, runtime, runtime.version-boundary. Selected base runtime record: runtime.25P04-batch2c-latest-20260909.latest. Separate boundary records: runtime.25P04-boundary-pg16-20260909.pg16 and runtime.25P04-boundary-pg17-20260909.pg17.

The separate boundary comparison has already recorded the availability check: PG16 returned 42704 and PG17 continued to a natural FATAL 25P04. This boundary block is branched, not a paste-all script. On PG16, run SHOW transaction_timeout; after the expected 42704, use the same still-healthy connection for SELECT 1 if you need to prove recovery, then stop and skip SET transaction_timeout, BEGIN, and the timeout wait. On PG17 or later, after SHOW succeeds, run SET transaction_timeout, capture the PID, and run BEGIN; then stop sending queries and let the observer or collector wait for the old connection’s FATAL and closure. Open a fresh connection only for the final probe. The boundary records are diagnostic comparisons and do not add to the selected base case count.

-- availability_probe
SHOW transaction_timeout;
-- set_timeout
SET transaction_timeout = '300ms';
-- backend_pid
SELECT pg_backend_pid();
-- begin
BEGIN;
-- probe
SELECT 1;

Versions and limits

The locked catalogue first observes transaction_timeout in 17.0. The selected 18.6 case passes with CSV/JSON collector evidence and a fresh-connection probe. The separate PG17.11 boundary case independently records natural FATAL 25P04, while PG16.15 records unavailable-setting 42704; neither replaces the selected base run. The PG10 case is a real not_applicable minimum-version preflight skip: the handler does not send or probe the unknown setting, so this is not evidence of an earlier boundary.

25P03 idle-in-transaction timeout, 40001 serialization failure, 57014 query canceled.

Sources

130 - 26000 — invalid_sql_statement_name

PostgreSQL SQLSTATE 26000: named prepared statement lookup, session affinity, and recovery.

26000 — invalid_sql_statement_name

At a glance

26000 means that PostgreSQL was asked to use a named prepared statement that does not exist in the current backend session. It is a session-resource lookup failure, so first check session affinity and statement lifecycle before changing the SQL text.

Field Value
SQLSTATE 26000
Condition invalid_sql_statement_name
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_SQL_STATEMENT_NAME, ERRCODE_UNDEFINED_PSTATEMENT
Aliases ERRCODE_UNDEFINED_PSTATEMENT

Meaning

PREPARE registers a named statement in one PostgreSQL session. EXECUTE and DEALLOCATE resolve that name in the same session; a pool checkout can silently move the next command to another backend. The core prepare.c path reports the dynamic name with prepared statement "%s" does not exist. The fixed extended-query path in postgres.c separately reports unnamed prepared statement does not exist when the unnamed statement is absent.

Diagnosis

Read the driver exception’s SQLSTATE and primary message, then log the backend PID or an equivalent connection identity around PREPARE and EXECUTE. On that same connection, pg_prepared_statements can show whether the named entry exists; querying it on a different pooled connection is not evidence about the failing session. Distinguish a deallocation, a connection replacement, and an unnamed statement path from a malformed PREPARE statement.

Response

If the operation is inside an explicit transaction, roll back the failed block before issuing more commands. Recreate the statement on the session that will execute it, and keep the statement definition and parameter types under the same application or pool checkout. A missing statement has not itself applied the intended operation, but the application should still use its normal request identity and side-effect checks before repeating a larger workflow.

Messages

The fixed core templates include prepared statement "%s" does not exist from prepare.c and unnamed prepared statement does not exist from the extended-query path in postgres.c. The selected case reports source_file = prepare.c and source_function = FetchPreparedStatement; only the named template has a server-side name substitution. Do not parse either message as a stable error string; branch on SQLSTATE and structured diagnostics.

Representative case

The runner reads this sequence from verify/cases/26000/snippets.json (SHA-256 b9fdbb48371e0d9902cb9e055ececc4878c38422773a8a1571651d9952809032) and keeps every statement on one connection. The complete executable record is the public case export, with structured evidence.

PREPARE statement_name(integer) AS SELECT $1 + 1;
EXECUTE statement_name(1);
DEALLOCATE statement_name;
EXECUTE statement_name(1);

statement_name is a page-level placeholder. The runner substitutes a unique identifier, deallocates it, asserts 26000 and IDLE, then repeats the registry’s same three statements—PREPARE, EXECUTE, and DEALLOCATE—to repair the session. The recovery sequence is therefore: PREPARE the named statement again, EXECUTE it on that same connection, and DEALLOCATE it when the checkout is finished; these are the existing prepare, execute, and deallocate registry statements, not a second SQL definition.

The selected runner case observed 26000 on PostgreSQL 18.6 and 10.21. It deallocated a named statement, observed the dynamic missing-name diagnostic with the connection IDLE, then recreated and executed the statement on that same session.

Versions

The locked catalogue reports this condition from the early historical boundary through the current formal snapshots. The fixed 18.6 source has both named and unnamed prepared-statement paths; the runtime comparison covers one named path on 18.6 and 10.21. The message wording and source line can vary by release, while the SQLSTATE identity remains 26000 in the selected targets.

34000 invalid cursor name and 25P02 failed transaction are useful when a pool/session boundary or surrounding transaction is involved.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.prepare.18.6 (SHA-256 e37fbd5f7618e5554561d9293d8c3af7cf3190c62c5c6bbceb3fe8b97be17956)
  • src.postgres.18.6 (SHA-256 9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061)
  • PREPARE documentation · local call scan src.calls.REL_18_6 (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

131 - 27000 — triggered_data_change_violation

Source-backed reference for PostgreSQL SQLSTATE 27000, with explicit mechanism boundaries.

27000 — triggered_data_change_violation

At a glance

27000 is a source-confirmed trigger-protection condition. PostgreSQL raises it when a row has already been changed by an operation triggered by the current command; the fixed 18.6 source hint points toward using an AFTER trigger when the intent is to propagate changes to other rows. A naive self-updating BEFORE trigger can recurse or alter the trigger semantics, so this entry does not present it as a safe generic reproduction.

Field Value
SQLSTATE 27000
Condition triggered_data_change_violation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION
Aliases

Meaning

27000 is the trigger data change violation raised by the executor when a tuple has already been modified by an operation triggered by the current command. The fixed trigger.c path is specifically a same-command, same-tuple guard for a trigger-driven change; it is not a label for every trigger exception or recursive trigger.

Diagnosis

Start with the target relation, the statement’s affected row, and the BEFORE row triggers that can update that row. The fixed primary template is tuple to be updated was already modified by an operation triggered by the current command, with a hint to consider an AFTER trigger for propagating changes to other rows. A self-update test that merely recurses is a different failure and does not establish this path. This batch has no natural runtime observation, so record the actual transaction state from the client if a real trigger error occurs.

Response

If the trigger is propagating a change to another row, an AFTER trigger or one set-based statement may fit the intended semantics; redesign the trigger when the same tuple is legitimately targeted twice. Do not respond with a generic retry or CASCADE, and do not claim that rolling back a fabricated self-update reproduces 27000. Roll back a genuinely failed explicit transaction before issuing repair SQL.

Versions

The locked facts table records catalogue presence across the project snapshot range. The fixed source evidence is limited to the path stated below; no exact behavioral introduction or broader runtime coverage is inferred from the definition alone.

Compare 44000 WITH CHECK OPTION violation for a view invariant and 23514 check violation for a table constraint.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • source path (SHA-256 0a539af85b0de1a04779f92202e7bfc77d85ae6da1747ea32527c67f39084fbd)

132 - 28000 — invalid_authorization_specification

PostgreSQL SQLSTATE 28000: invalid_authorization_specification, source-backed diagnosis and recovery guidance.

28000

At a glance

SQLSTATE 28000 is invalid_authorization_specification in Class 28. 28000 is the authorization-specification class for rejected startup or authorization context. The selected missing-role startup path sends C=28000, S=FATAL, and role "<generated>" does not exist before a session is established; other fixed authentication paths use this class for concrete certificate, pg_hba, and LOGIN eligibility failures.

Field Value
SQLSTATE 28000
Condition invalid_authorization_specification
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION
Aliases

Meaning

This class covers authorization context rejected while a connection is being established or authenticated. The selected branch is the startup role lookup: the server cannot create a session for the requested role and sends a FATAL ErrorResponse. Certificate, pg_hba, and LOGIN-eligibility paths remain separate producers under the same class.

The selected role lookup happens before a backend can enter a normal session. That explains both the FATAL severity and the absence of session-level transaction state. Do not merge it with 28P01 (password authentication failure), 42501 (permission denied after a session exists), or 3D000 (database selection); the startup phase and the server fields identify which branch you are looking at.

Startup branch guide

What to inspect Selected missing-role branch Other Class 28 possibilities
Server field C=28000, S=FATAL, M=role "%s" does not exist Preserve the server’s own code and primary; class membership alone is not enough.
Session state No usable session and no transaction exists on the failed attempt A later authorization check may occur after a session exists and has a different recovery boundary.
Repair Create/rename the role as intended, or correct the startup user, then connect afresh Correct the certificate, pg_hba.conf, LOGIN attribute, or mapping named by the actual diagnostic.

Diagnosis

Use the server ErrorResponse or authentication log as SQLSTATE authority and classify the phase: role lookup, pg_hba rule, certificate, or LOGIN permission. The selected collector is a raw server ErrorResponse record, not csvlog/jsonlog; raw startup and psycopg are separate attempts. In the selected runs psycopg reports driver SQLSTATE null, the failed connection has no transaction, and two independent fresh known-role probes can still run SELECT 1; this is not a collector correlation claim.

For a missing role, compare the requested startup user with the role catalog from a separate administrative session and check for quoting or case-folding differences. Preserve the raw C, S, and M fields: psycopg’s null is a property of its independent failed startup attempt, not evidence that the server omitted SQLSTATE. A fresh probe must use a separate connection and cannot turn the failed attempt into a transaction that can be rolled back.

Response

Correct the role, LOGIN/mapping, certificate, or pg_hba rule identified by the server, then establish a fresh connection. There is no failed session on which to issue ROLLBACK; do not infer 28000 from a client exception without its server field, and do not replay non-idempotent startup work blindly.

After a role or authentication change, reconnect with the exact intended user and database and verify the resulting identity from the new session. If the application had already sent work on another connection, reconcile that work separately; the pre-session FATAL itself does not establish a business transaction to retry.

Observed diagnostics

The selected startup role branch emits FATAL with primary role "%s" does not exist; the role name is dynamic. Other authorization failures in Class 28 can use different primary text. Treat the server ErrorResponse as authoritative because the client never receives a usable session SQLSTATE.

The selected server record is role "u28000_missing_fbc912bb7e6f" does not exist; the generated role name is run-specific. The raw ErrorResponse and the psycopg null belong to separate startup attempts, so they must not be combined as if they were two views of one session.

Representative case

The registry contains the probe used after the startup ErrorResponse. The trigger uses a generated role on a fresh startup connection, so no SQL statement can reproduce that pre-session failure.

SELECT 1;

The selected 18.6 server ErrorResponse is C=28000, S=FATAL, role "u28000_missing_fbc912bb7e6f" does not exist. The driver startup diagnostic has SQLSTATE null; the failed connection has no transaction, while the known-good probe returned 1 and IDLE.

The downloadable case and evidence projections are 28000 case JSON and authored evidence. The runner manifest is verify/cases/28000/cases.json; the page SQL is checked against its shared registry before publication.

Versions

The generated facts table records the locked catalogue snapshots and earliest observed definition. The selected natural runtime scope is PostgreSQL 18.6 and 10.21; this does not infer behavior for every intermediate release.

Sources

  • src.miscinit-missing-role.18.6src/backend/utils/init/miscinit.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 54bdb859c143a6c70d86067ccf2e124f59aa0852e5705bb653652e41a60af39a (source).
  • src.miscinit-missing-role.10.23src/backend/utils/init/miscinit.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 c4d2e234f96644d43aad9e9a6728df693e7f75175f05a550701413ceee70fb82 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed local call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.

133 - 28P01 — invalid_password

PostgreSQL reports SQLSTATE 28P01 when password authentication fails during connection startup. Check the matched pg_hba.conf rule and role secret, then prove recovery with a fresh connection.

At a glance

28P01 is PostgreSQL’s invalid_password condition in Class 28, invalid_authorization_specification. It identifies a password authentication failure while a client is establishing a session. The authentication method, the matched pg_hba.conf rule, and the role’s stored secret determine the precise path.

This failure occurs before SQL execution. The rejected session has no transaction to roll back. In the final runs, psycopg reported the startup exception text but exposed sqlstate=None; the PostgreSQL collector recorded the server’s FATAL SQLSTATE 28P01. A driver-side exception without a code must not be described as if the client received the collector field.

The case wrong_password_authentication enabled a disposable md5 rule, tried a wrong password, verified that the known password could open a new session and run SELECT 1, restored the exact HBA configuration, and verified a fresh management connection. It passed on PostgreSQL 18.6 and isolated PostgreSQL 10.21. The run IDs and assertions are retained in the public evidence JSON.

Field Value
SQLSTATE 28P01
Condition invalid_password
Status active
Known present by 9.0.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_PASSWORD
Aliases

Meaning and trigger paths

The server selects an authentication method from the first matching pg_hba.conf rule. For password, MD5, and SCRAM paths that reject the supplied secret, auth.c selects ERRCODE_INVALID_PASSWORD and reports a FATAL message. The primary template is password authentication failed for user "%s"; the server can add HBA matching information to its log detail.

28P01 does not distinguish a wrong password from every other authentication configuration problem. A missing role, a role that cannot log in, a certificate failure, or an HBA rule that selects another method can use a different SQLSTATE or message. The matched rule and the authentication method are part of the diagnosis.

The failure is at connection startup, before a backend can accept SQL. A pool should discard the rejected connection attempt and obtain a new one after the secret or HBA configuration is repaired. Existing owner or administration connections are useful for restoring a temporary rule, but reusing one of them does not prove that the affected role can authenticate.

Messages and diagnostics

The SQL statements below are the same password setup and probe statements used by the runner. known_user and example-known-secret are replaced by disposable values during the run. Editing pg_hba.conf and opening the wrong-password connection are startup operations, so they are described between the SQL statements rather than represented by a fake RAISE or SQL error.

ALTER ROLE known_user PASSWORD 'example-known-secret';
-- Put a temporary first pg_hba.conf rule for host all all 0.0.0.0/0 md5.
-- Connect as known_user with a wrong password: startup returns FATAL 28P01.
-- Connect again with the known password and run:
SELECT 1;
-- Restore the original pg_hba.conf, open a fresh management connection, and run:
SELECT 1;

The latest target’s collector record was:

SQLSTATE: 28P01
severity: FATAL
message_primary: password authentication failed for user "<generated-role>"
detail (collector): Connection matched file "<pg_hba.conf path>" line 1: "host all all 0.0.0.0/0 md5"
source: auth.c / auth_failed / line 320
driver startup sqlstate: null
transaction: none opened
repair: known-password SELECT 1 -> 1; restore HBA; fresh owner SELECT 1 -> 1

PostgreSQL 10.21 emitted the same primary message and SQLSTATE in its collector, with auth.c:329 as the source location; its collector detail uses the older pg_hba.conf line wording and also includes a password-mismatch line. In both targets the known password authenticated under the temporary rule, the original HBA configuration was reloaded, and a new management connection then returned 1. The driver text and collector fields are separate evidence channels; libpq/psycopg did not expose the startup SQLSTATE in this run.

Diagnosis

Record the user, database, connection source, authentication method, server version, and the first matching HBA rule without recording passwords. Correlate the failed attempt with a verbose collector record. The collector detail can identify the HBA line, while the client startup exception may contain only a FATAL text string.

Check that the intended role exists and can log in, that its password was set for the selected method, and that no earlier HBA rule intercepts the connection. A correct password under the wrong HBA method is not proof of a correct deployment. Avoid treating a password rotation as complete until a new connection succeeds.

There is no transaction state to recover for the rejected session. Keep a controlled administration connection while changing HBA rules, reload the configuration, and test with a fresh client. Restore the prior rule exactly when the test is complete and verify that a new owner connection still works.

Response and repair

  • Use the intended secret and authentication method for the role, and rotate it through a channel that does not expose the value in logs or command history.
  • Inspect the first matching pg_hba.conf rule, correct its database, user, address, and method fields, then reload it.
  • Test the affected role with a new connection and a real harmless query such as SELECT 1.
  • Keep existing administration access until the new path is proven, then close stale pool connections so they do not retain old credentials.

The representative repair includes both a known-password connection and a fresh post-restore management connection. A successful pg_reload_conf() alone is not an authentication proof, and reusing the connection that performed the reload does not test the repaired login path.

Versions and boundaries

The catalogue contains 28P01 in the first scanned definition (9.0.0 or earlier), every listed formal snapshot through PostgreSQL 18.6, and the PostgreSQL 19 Beta 3 preview. No condition definition change is recorded in the scanned range; the pre-9.0 introduction point remains outside the scan.

The wrong-password case passed on PostgreSQL 18.6 and 10.21. The source line differs between releases, and the driver/collector SQLSTATE split is a property of this startup path. Certificate, GSSAPI, PAM, LDAP, peer, and HBA syntax failures are separate authentication paths and are not covered by this evidence.

53300too_many_connections is a capacity failure during connection startup. 57014query_canceled occurs while a connected backend is executing a statement. 42501insufficient_privilege is a privilege check after authentication, not a password diagnostic.

Sources

Structured evidence is recorded in the public evidence JSON. Source records are fixed to PostgreSQL commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; runtime records retain the collector output, driver observation, HBA restoration, both target IDs, and structured observations.

134 - 2B000 — dependent_privilege_descriptors_still_exist

Source-backed reference for PostgreSQL SQLSTATE 2B000, with explicit mechanism boundaries.

2B000 — dependent_privilege_descriptors_still_exist

At a glance

2B000 is a catalogue-defined condition for dependent privilege descriptors. The fixed source scan did not resolve a distinct core 2B000 ereport path in this batch, so the page records the definition boundary and does not label a role, REVOKE, or DROP result as 2B000. For ordinary object dependencies, see 2BP01.

Field Value
SQLSTATE 2B000
Condition dependent_privilege_descriptors_still_exist
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST
Aliases

Meaning

2B000 names the Class 2B dependent privilege descriptors condition. The fixed PostgreSQL 18.6 call scan did not resolve a distinct core ereport for this code. It must therefore remain separate from 2BP01 (dependent objects still exist) and from concrete authorization or grant-operation errors such as 42501 and 0LP01.

Diagnosis

When this code is reported by an extension or a version-specific path, preserve the object/privilege descriptor named by that component and collect its primary, DETAIL, and HINT fields. Do not infer 2B000 from a failed DROP or GRANT: the fixed core scan has no selected natural trigger, and the ordinary dependency walker uses 2BP01 for the representative dependent-object path.

Response

Do not apply DROP ... CASCADE, revoke privileges, or retry solely from the class name. Identify the component that owns the descriptor, use its documented repair, and verify the resulting ACL/dependency state. Until a resolved server path is established, treat this page as a source/definition boundary rather than a promise that a generic SQL transaction can produce 2B000.

Versions

The locked facts table records catalogue presence across the project snapshot range. The fixed source evidence is limited to the path stated below; no exact behavioral introduction or broader runtime coverage is inferred from the definition alone.

Compare 2BP01 dependent objects for object dependencies; the two codes are distinct source categories.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6 fixed call scan (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

135 - 2BP01 — dependent_objects_still_exist

PostgreSQL SQLSTATE 2BP01: dependency-aware DROP diagnostics and repair.

2BP01 — dependent_objects_still_exist

At a glance

2BP01 means a DROP or related catalog operation would remove an object that other database objects still require. The useful repair is dependency-aware: identify the dependent object, decide whether it should be removed or retained, and only then retry the original operation.

Field Value
SQLSTATE 2BP01
Condition dependent_objects_still_exist
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST
Aliases

Meaning

The dependency walker emits 2BP01 for a blocked object operation. In the representative path, a view depends on a table, so DROP TABLE cannot proceed. The primary message, DETAIL, and CASCADE hint are dynamically assembled from object descriptions and the dependency graph. 2BP01 is about dependent objects; 2B000 is a separate dependent-privilege-descriptor condition.

Diagnosis

Capture SQLSTATE, primary message, DETAIL, and HINT together. The DETAIL identifies the dependent view in the selected path. Inspect the view definition and dependency metadata before choosing a repair; pg_depend and pg_get_viewdef() help explain why the object is retained. In the selected explicit BEGIN block, this ERROR puts the connection in INERROR until ROLLBACK; an autocommit statement has no surrounding block to preserve. Catalog queries issued through the failed explicit block will not provide a clean diagnosis.

Response

Rollback the failed explicit transaction. If the view is intentionally disposable, drop that view first and then the table; if it is part of the schema contract, preserve it and choose a different migration. CASCADE is a deliberate request to remove dependent objects and can exceed the intended change, so the HINT is not an instruction to apply it automatically. After a dependency-aware repair, rerun the complete DDL plan and verify the surviving objects.

Messages

The selected source branch uses cannot drop %s because other objects depend on it, a dynamic internal DETAIL, and Use DROP ... CASCADE to drop the dependent objects too. The object descriptions and dependency list are runtime values; do not treat the DETAIL as a stable single-object template or assume every 2BP01 path has this exact wording.

Representative case

The runner reads this dependency sequence from verify/cases/2BP01/snippets.json (SHA-256 899e4fd9fb002fc293bd9efee0204e4f2622968c6d9460ad05eb9a0ebd3bac69). It uses an explicit BEGIN/ROLLBACK for the failed DROP and then removes the known view before its table, without CASCADE. See the public case export and structured evidence.

CREATE TABLE base_items(id integer PRIMARY KEY, payload text NOT NULL);
CREATE VIEW dependent_view AS SELECT id, payload FROM base_items;
BEGIN;
DROP TABLE base_items;
ROLLBACK;
DROP VIEW dependent_view;
DROP TABLE base_items;
SELECT to_regclass('base_items'), to_regclass('dependent_view');

The registry names are qualified by the runner inside a private schema. The final to_regclass check returns two nulls, proving that the intended objects were removed rather than silently cascading through an unknown graph.

The selected case observed 2BP01 on PostgreSQL 18.6 and 10.21. DROP TABLE reported the dependent view in DETAIL and suggested CASCADE; the explicit block was INERROR, ROLLBACK restored IDLE, and intentionally dropping the view first allowed the table to be removed.

Versions

The catalogue records this condition from the early historical boundary through the formal snapshots. The fixed 18.6 source includes dependency, shared-dependency, role, privilege, typed-table, and tablespace branches; the runtime case covers one ordinary view-to-table dependency on 18.6 and 10.21. Do not infer that a CASCADE hint is equally safe for all branches.

Compare 2B000 dependent privilege descriptors and 42P01 undefined table when a DROP or dependency report names the wrong layer.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.dependency.18.6 (SHA-256 1878f848dae03e08424a47a09508f3443227ad67c4bc5e0aba3ec9655d015b74)
  • DROP TABLE documentation · local call scan src.calls.REL_18_6 (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

136 - 2D000 — invalid_transaction_termination

Source-backed reference for PostgreSQL SQLSTATE 2D000, with explicit mechanism boundaries.

2D000 — invalid_transaction_termination

At a glance

2D000 is the SPI guard used when a procedure or subtransaction context attempts an invalid transaction termination. The fixed 18.6 path distinguishes invalid termination from a normal explicit COMMIT; this batch does not claim that every procedure-level transaction error is 2D000, and it does not fabricate a RAISE-based SQL example.

Field Value
SQLSTATE 2D000
Condition invalid_transaction_termination
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_TRANSACTION_TERMINATION
Aliases

Meaning

2D000 is the SPI invalid transaction termination condition. In the fixed spi.c path, SPI_commit and SPI_rollback reject termination in an atomic SPI context; they also reject commit or rollback while a subtransaction is active. The source comments tie that restriction to procedural languages that use subtransactions for exception blocks.

Diagnosis

Locate the routine and SPI caller that attempted transaction control. Distinguish a top-level CALL that is allowed to control a transaction from a function or exception block whose SPI context is atomic, and check whether a nested subtransaction is active. The fixed source templates are invalid transaction termination, cannot commit while a subtransaction is active, and cannot roll back while a subtransaction is active; an ordinary client COMMIT error is not enough to classify this path.

Response

Move transaction control to an allowed procedure boundary, or let the surrounding procedure/exception block finish its subtransaction before terminating the top-level transaction. Do not issue COMMIT or ROLLBACK again inside the same forbidden SPI context, and do not apply a generic retry recipe. This batch records the source path only; no artificial RAISE or unfaithful SQL reproduction is used.

Versions

The locked facts table records catalogue presence across the project snapshot range. The fixed source evidence is limited to the path stated below; no exact behavioral introduction or broader runtime coverage is inferred from the definition alone.

Compare 25P01 no active SQL transaction and 24000 invalid cursor state before changing procedure or transaction boundaries.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • source path (SHA-256 7244b45f632583c72530832df901b788fe403c8857425dd13edb49d9f84b0c78)

137 - 2F000 — sql_routine_exception

Source-bounded reference for PostgreSQL SQLSTATE 2F000.

2F000

At a glance

SQLSTATE 2F000 is the SQL Routine Exception category. The definition is present in the locked catalogue, but the resolved PostgreSQL 18.6 core/contrib call scan did not identify a native 2F000 report group. The class should therefore organize routine-related investigation; it does not identify a particular function declaration, PL/pgSQL statement, or retry rule.

Field Value
SQLSTATE 2F000
Condition sql_routine_exception
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SQL_ROUTINE_EXCEPTION
Aliases

Meaning

2F000 is a category code. Its member 2F002 names one standard routine data-access restriction, but a member path must be confirmed separately. PostgreSQL can report other routine errors with different SQLSTATEs; retain the returned member, message, routine, and server version instead of replacing them with the category.

Messages

No fixed PostgreSQL message variant was adopted for this condition because the bounded scan did not resolve a native emitting call.

Diagnosis

Record whether the failure occurred while creating, invoking, or executing a routine, and identify the owner (backend, extension, ECPG, driver, or remote server). Search the fixed implementation for the exact member and message. A category-only observation is insufficient to infer whether a data-access rule, argument error, or routine body caused it.

Response

Apply the repair documented by the producing routine implementation and its member SQLSTATE. If a remote or client layer produced the condition, repair that owner’s declaration or call contract. Do not retry a routine category without knowing whether execution began or completed.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The release definitions cover the published snapshots listed in the facts block; source-path status is limited to the fixed PostgreSQL 18.6 context cited below.

2F002, 0Z000

Sources

The fixed errcodes definition establishes the category and the SQLSTATE appendix lists its members. No resolved native 2F000 report group was found in the locked core/contrib call scan. See the structured evidence record for fixed source paths, scan scope, and unresolved runtime boundaries.

138 - 2F002 — modifying_sql_data_not_permitted

Source-bounded reference for PostgreSQL SQLSTATE 2F002.

2F002

At a glance

SQLSTATE 2F002 names the standard SQL Routine Exception member for modifying SQL data when the routine’s declared data-access contract does not permit it. The locked PostgreSQL 18.6 definition contains the member, but its resolved core/contrib call scan has no native report group. Do not infer that PostgreSQL VOLATILE, STABLE, or IMMUTABLE alone maps to this SQLSTATE.

Field Value
SQLSTATE 2F002
Condition modifying_sql_data_not_permitted
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED
Aliases

Meaning

The condition is about a routine data-access restriction in an implementation that enforces that contract. The PostgreSQL catalogue row supplies identity and the macro; it does not establish a backend enforcement path or a particular routine language. An extension, embedded-SQL implementation, driver, or remote server may use the standard member independently.

Messages

No fixed PostgreSQL message variant was adopted for this condition because the bounded scan did not resolve a native emitting call.

Diagnosis

First preserve the actual SQLSTATE and inspect the routine declaration and the owner that enforced it. Determine whether the attempted statement modified data, whether the routine was declared with a restrictive data-access characteristic, and whether the code came from a remote or client implementation. If the server returned another code, follow that code rather than treating 2F002 as a synonym for a PostgreSQL function volatility error.

Response

Change the routine’s data-access declaration only when the producing implementation documents that as the supported repair, or move the data-modifying work to an allowed routine boundary. Otherwise correct the caller or remote contract. Do not add a generic retry: a rejected data change did not by itself establish whether surrounding work was committed.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The release definitions cover the published snapshots listed in the facts block; source-path status is limited to the fixed PostgreSQL 18.6 context cited below.

2F000, 0A000

Sources

The fixed errcodes definition establishes the member and macro; the SQLSTATE appendix identifies the standard condition. The locked core/contrib scan found no resolved native 2F002 report group. See the structured evidence record for fixed source paths, scan scope, and unresolved runtime boundaries.

139 - 2F003 — prohibited_sql_statement_attempted

Source-backed reference for PostgreSQL SQLSTATE 2F003.

2F003

At a glance

The fixed scan confirms this ERROR in both dblink and postgres_fdw connection paths. dblink also reports it when a command would return rows where the dblink API expects no result. The authentication variants are wrapper/connection policy paths, not proof that every prohibited SQL statement uses this code.

Field Value
SQLSTATE 2F003
Condition prohibited_sql_statement_attempted
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED
Aliases

Meaning

The confirmed messages include statement returning results not allowed, and authentication variants such as password or GSSAPI delegated credentials required with a detail and sometimes a hint. postgres_fdw adds detail about the user mapping and may hint at password_required=false; dblink has its own credential wording. Keep the producer because the same SQLSTATE covers separate APIs.

Messages

Confirmed messages include statement returning results not allowed, plus password or GSSAPI delegated credentials required, which carries detail and may also carry a hint depending on the path. postgres_fdw identifies the user mapping in its detail and one path mentions password_required=false in the hint; dblink uses its own credential wording. Because the same SQLSTATE covers separate APIs, retain the actual producer.

Diagnosis

For dblink, identify whether the local call is a row-returning command used through a no-result API or a connection credential check. For postgres_fdw, inspect the foreign-server connection, user mapping, authentication method, and the server’s password_required policy when the message names them. Preserve the fixed detail/hint and do not collapse dblink and postgres_fdw into one generic wrapper.

Response

Correct the command/API pairing or the named connection credentials and user mapping, then verify the remote operation. A remote connection attempt may not have completed; preserve the remote/local boundary before retrying. Do not change transaction policy merely because dblink or postgres_fdw reported 2F003.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The facts block lists the published snapshots; source-path status is limited to the fixed PostgreSQL 18.6 evidence below.

2F000, 38003

Sources

Read the fixed dblink.c and postgres_fdw connection.c paths alongside the structured evidence record.

140 - 2F004 — reading_sql_data_not_permitted

Source-backed reference for PostgreSQL SQLSTATE 2F004.

2F004

At a glance

The catalogue defines this standard member, but the resolved PostgreSQL 18.6 core/contrib scan found no native report group. Do not infer a PostgreSQL function volatility or language rule from the condition name.

Field Value
SQLSTATE 2F004
Condition reading_sql_data_not_permitted
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_S_R_E_READING_SQL_DATA_NOT_PERMITTED
Aliases

Meaning

2F004 describes a routine data-access restriction only when the producing implementation enforces it. A client, extension, ECPG layer, or remote routine engine may use the member independently.

Messages

No fixed PostgreSQL message variant was adopted because the bounded scan did not resolve a native report group.

Diagnosis

Record the routine owner, invocation phase, actual SQLSTATE, and declaration that limited reads. If the backend returned a different code, follow that code and its source path; the fixed catalogue row is not a fallback diagnosis.

Response

Apply only the producing implementation’s documented declaration or caller repair. No native PostgreSQL reporting path or generic retry boundary was confirmed for 2F004.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The facts block lists the published snapshots; source-path status is limited to the fixed PostgreSQL 18.6 evidence below.

2F000, 38004

Sources

See the fixed source links and message limits in the structured evidence record.

141 - 2F005 — function_executed_no_return_statement

Source-backed reference for PostgreSQL SQLSTATE 2F005.

2F005

At a glance

PL/pgSQL reports 2F005 at ERROR level when a function or trigger procedure reaches the end without the required RETURN. The fixed 18.6 paths distinguish an ordinary function from a trigger procedure in their messages.

Field Value
SQLSTATE 2F005
Condition function_executed_no_return_statement
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT
Aliases

Meaning

The confirmed messages are control reached end of function without RETURN and control reached end of trigger procedure without RETURN. The return requirement depends on the routine kind and declared return behavior; it is not a generic “function returned NULL” message.

Messages

The confirmed messages are control reached end of function without RETURN and control reached end of trigger procedure without RETURN. The return requirement depends on the routine kind and declared return behavior; this is not a generic “function returned NULL” message.

Diagnosis

Read the routine signature and the control-flow paths that can reach the end. For a trigger procedure, inspect each branch that should return the trigger row or NULL according to the trigger contract; for a value-returning function, inspect every branch for a compatible RETURN.

Response

Add the required return path and validate the routine definition before rerunning the operation. This is a routine control-flow repair; retry only after considering whether the enclosing operation performed any visible work.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The facts block lists the published snapshots; source-path status is limited to the fixed PostgreSQL 18.6 evidence below.

2F000, 38000

Sources

See the fixed source links and message limits in the structured evidence record.

142 - 34000 — invalid_cursor_name

PostgreSQL SQLSTATE 34000: cursor lifecycle, session affinity, and recovery.

34000 — invalid_cursor_name

At a glance

34000 means that a cursor or portal name cannot be resolved in the current backend session. A cursor that was closed, declared on another pooled connection, or ended with its transaction is not the same resource as a cursor with a bad position (24000).

Field Value
SQLSTATE 34000
Condition invalid_cursor_name
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_CURSOR_NAME, ERRCODE_UNDEFINED_CURSOR
Aliases ERRCODE_UNDEFINED_CURSOR

Meaning

The executor’s portal path reports cursor "%s" does not exist when FETCH cannot find the named portal. Cursor names are tied to a backend session, and ordinary cursors are tied to a transaction unless declared with an appropriate hold option. A pool checkout therefore must keep declaration and use on the same connection and within the intended transaction boundary.

Diagnosis

Record SQLSTATE, the dynamic cursor name, backend PID, and transaction status. Check the application path for an earlier CLOSE, an implicit commit, a connection return to the pool, or a different session. pg_cursors and the server-side session identity can help when the diagnosis runs on the same backend; a new connection cannot inspect or fetch a cursor owned by the old one.

Response

For an explicit block, rollback after the failed FETCH before issuing more commands. Re-declare the cursor on the same session, or deliberately redesign the workflow to materialize keys/results when work must cross pool checkouts. Use a holdable cursor only when its commit-survival semantics are intended; it does not make a cursor portable between sessions.

Messages

The selected core path uses cursor "%s" does not exist; protocol and PL/pgSQL paths can use portal "%s" or the same cursor wording. The name is dynamic, so use the SQLSTATE and diagnostic fields rather than a full-message equality check across versions and callers.

Representative case

The shared registry in verify/cases/34000/snippets.json (SHA-256 ad5b519e8ca30fd2636b1d0bace32dc18558cccc7b9d360081c27b12a1405f08) declares and closes a cursor, proves the missing-FETCH error, rolls back, and recreates it in the same session. See the public case export and structured evidence.

BEGIN;
DECLARE cursor_name CURSOR FOR SELECT 1;
CLOSE cursor_name;
FETCH cursor_name;
ROLLBACK;
BEGIN;
DECLARE cursor_name CURSOR FOR SELECT 1;
FETCH cursor_name;
CLOSE cursor_name;
COMMIT;

The runner substitutes a unique cursor name. The first FETCH is intentionally after CLOSE; the second FETCH occurs after a new BEGIN and declaration, so the successful row proves lifecycle repair rather than a client-side mock.

The selected case observed 34000 on PostgreSQL 18.6 and 10.21 after closing a named cursor and attempting FETCH. The failed block reached INERROR; rollback followed by a new declaration, fetch, close, and commit returned the session to IDLE.

Versions

The locked catalogue records this condition across the formal snapshots. 18.6 and 10.23 source scans both contain the portal and PL/pgSQL paths; the selected runtime case observes the same SQLSTATE on 18.6 and 10.21, while exact source line and caller wording vary.

Compare 24000 invalid cursor state for a cursor that exists but is not positioned, and 26000 invalid prepared statement name for another session-local resource.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.portalcmds.18.6 (SHA-256 e71c5bdb2da67771fb5f42f18b823e8af3ee6c31d5314e97a47ad18f7788bf35)
  • DECLARE documentation · local call scan src.calls.REL_18_6 (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

143 - 38000 — external_routine_exception

Source-backed reference for PostgreSQL SQLSTATE 38000.

38000

At a glance

Class 38 is broad. Fixed PostgreSQL 18.6 paths include external command failures in COPY ... PROGRAM and basebackup_to_shell, UUID library failures, and exceptions propagated from PL/Perl, PL/Python, and PL/Tcl. These are separate implementations under one category.

Field Value
SQLSTATE 38000
Condition external_routine_exception
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_EXTERNAL_ROUTINE_EXCEPTION
Aliases

Meaning

Representative messages include program "%s" failed and shell command "%s" failed, each with an internal wait-status detail; OSSP uuid library failure: %s, OSSP uuid library failure: error code %d, uuid library failure: %d, and the UUID version-mismatch message; PL/Perl reports such as didn't get a return item from function, PL/Python forwards %s with optional detail/context/hint, and PL/Tcl reports could not parse function return value: %s or a context-bearing %s. Keep the dynamic fields and the actual producer; this category has no single fixed message.

Messages

Representative messages include program "%s" failed and shell command "%s" failed, each with an internal wait-status detail; OSSP uuid library failure: %s, OSSP uuid library failure: error code %d, uuid library failure: %d, and the UUID version-mismatch message; PL/Perl reports such as didn't get a return item from function, PL/Python forwards %s with optional detail/context/hint, and PL/Tcl reports could not parse function return value: %s or a context-bearing %s. Keep the dynamic fields and the actual producer; this category has no single fixed message.

Diagnosis

Use the message and context to identify the external boundary: program path and wait result, UUID library operation, or PL language and routine. Inspect the relevant server configuration and handler logs, preserving dynamic %s values and any internal detail.

Response

Repair the named external command, library, or language routine and verify that boundary independently. A failed external action may have side effects; do not replay it until completion and idempotency are known.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The facts block lists the published snapshots; source-path status is limited to the fixed PostgreSQL 18.6 evidence below.

38001, 2F000

Sources

Read the fixed basebackup_to_shell.c, copyto.c, uuid-ossp.c, plperl.c, and pltcl.c paths alongside the structured evidence record.

144 - 38001 — containing_sql_not_permitted

Source-backed reference for PostgreSQL SQLSTATE 38001.

38001

At a glance

The fixed definition records this Class 38 member, but the resolved PostgreSQL 18.6 core/contrib scan found no report group for it. It is a standard routine boundary condition, not a confirmed PostgreSQL message.

Field Value
SQLSTATE 38001
Condition containing_sql_not_permitted
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED
Aliases

Meaning

The member concerns SQL contained in an external routine when the owning implementation forbids it. The producer may be an external routine engine, extension, ECPG layer, driver, or remote server.

Messages

No fixed PostgreSQL message variant was adopted because the bounded scan did not resolve a native report group.

Diagnosis

Keep the exact member message, routine owner, language, and phase. Do not derive a prohibition from PostgreSQL VOLATILE/STABLE or from a routine name.

Response

Follow the enforcing implementation’s declaration or caller contract. No native PostgreSQL retry or repair mechanism was established by the locked scan.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The facts block lists the published snapshots; source-path status is limited to the fixed PostgreSQL 18.6 evidence below.

38000, 2F000

Sources

See the fixed source links and message limits in the structured evidence record.

145 - 38002 — modifying_sql_data_not_permitted

Source-backed reference for PostgreSQL SQLSTATE 38002.

38002

At a glance

This Class 38 member names a modifying-data restriction. The fixed PostgreSQL 18.6 core/contrib scan found no resolved report group for it, so it must not be conflated with the separately named 2F002 member.

Field Value
SQLSTATE 38002
Condition modifying_sql_data_not_permitted
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_E_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED
Aliases

Meaning

The distinction is the SQLSTATE and the routine standard class, not a guessed PostgreSQL function-volatility rule. Preserve whether the routine was external, remote, or client-owned.

Messages

No fixed PostgreSQL message variant was adopted because the bounded scan did not resolve a native report group.

Diagnosis

Inspect the routine declaration and the implementation that enforced it; determine whether the attempted operation modified SQL data and which boundary supplied the error.

Response

Change the declared data-access contract only when its owner documents that repair, or move the write to an allowed boundary. Do not infer a generic retry.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The facts block lists the published snapshots; source-path status is limited to the fixed PostgreSQL 18.6 evidence below.

38000, 2F000

Sources

See the fixed source links and message limits in the structured evidence record.

146 - 38003 — prohibited_sql_statement_attempted

Source-backed reference for PostgreSQL SQLSTATE 38003.

38003

At a glance

The Class 38 member is defined, but no resolved PostgreSQL 18.6 core/contrib report group was found. It is distinct from Class 2F member 2F003 even though the condition names match.

Field Value
SQLSTATE 38003
Condition prohibited_sql_statement_attempted
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_E_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED
Aliases

Meaning

The external-routine class identifies the standard context; the actual prohibited statement, routine language, and owner remain unknown until a source path or message is found.

Messages

No fixed PostgreSQL message variant was adopted because the bounded scan did not resolve a native report group.

Diagnosis

Preserve the returned class/member code and inspect the external routine contract. Do not import dblink or postgres_fdw 2F003 messages into 38003.

Response

Repair the owner’s routine or call contract according to its fixed documentation; no PostgreSQL-native repair was confirmed.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The facts block lists the published snapshots; source-path status is limited to the fixed PostgreSQL 18.6 evidence below.

38000, 2F000

Sources

See the fixed source links and message limits in the structured evidence record.

147 - 38004 — reading_sql_data_not_permitted

Source-backed reference for PostgreSQL SQLSTATE 38004.

38004

At a glance

The Class 38 member is a standard reading-data restriction, but the bounded PostgreSQL 18.6 core/contrib scan found no resolved report group. It should remain separate from 2F004.

Field Value
SQLSTATE 38004
Condition reading_sql_data_not_permitted
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_E_R_E_READING_SQL_DATA_NOT_PERMITTED
Aliases

Meaning

Only the enforcing external routine implementation can identify the declaration, read operation, and message fields. The catalogue identity does not prove a backend language rule.

Messages

No fixed PostgreSQL message variant was adopted because the bounded scan did not resolve a native report group.

Diagnosis

Record the routine owner and access declaration, then read its fixed source or protocol mapping. If the server returned 2F004 instead, follow that member and its owner.

Response

Adjust the external routine contract or call only as documented. Do not add a blanket retry for a rejected read.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The facts block lists the published snapshots; source-path status is limited to the fixed PostgreSQL 18.6 evidence below.

38000, 2F000

Sources

See the fixed source links and message limits in the structured evidence record.

148 - 39000 — external_routine_invocation_exception

Source-backed reference for PostgreSQL SQLSTATE 39000.

39000

At a glance

Fixed PostgreSQL 18.6 paths in contrib/pgcrypto report this ERROR for cryptographic library failures and invalid input lengths. The category can also carry other external routine invocation errors, so the exact library function and dynamic error text matter.

Field Value
SQLSTATE 39000
Condition external_routine_invocation_exception
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION
Aliases

Meaning

Representative messages are crypt(3) returned NULL, encrypt error: %s, decrypt error: %s, encrypt_iv error: %s, decrypt_iv error: %s, and Length not in range. Several primary messages interpolate the dynamic library text returned by px_strerror(err); it is part of the primary message, not a separate DETAIL field.

Messages

Representative messages include crypt(3) returned NULL, encrypt error: %s, decrypt error: %s, encrypt_iv error: %s, decrypt_iv error: %s, and Length not in range. Several variants put the dynamic library text from px_strerror(err) directly in the primary message; it is not a separate DETAIL field.

Diagnosis

Identify the pgcrypto function and operation (crypt, encrypt/decrypt, IV form, or length validation). Preserve the dynamic error string and check input lengths, key/IV parameters, and library boundary; do not merge a library error with a SQLSTATE from a remote routine.

Response

Correct the named input or library/configuration problem and validate the same pgcrypto operation. Retry only when the operation is safe and no externally visible work was completed; a failed encryption call does not justify replaying a surrounding write.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The facts block lists the published snapshots; source-path status is limited to the fixed PostgreSQL 18.6 evidence below.

39001, 2F000

Sources

Read the fixed pgcrypto.c, pgp-cfb.c, and px.c paths alongside the structured evidence record.

149 - 39001 — invalid_sqlstate_returned

Source-backed reference for PostgreSQL SQLSTATE 39001.

39001

At a glance

The fixed definition contains this member, but the resolved PostgreSQL 18.6 core/contrib scan found no report group. The name describes an external routine returning an invalid SQLSTATE; it does not identify a current PostgreSQL handler path.

Field Value
SQLSTATE 39001
Condition invalid_sqlstate_returned
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_E_R_I_E_INVALID_SQLSTATE_RETURNED
Aliases

Meaning

Keep the returned text, external language, routine, and wrapper that rejected it. Do not replace the member with XX000 or infer the bad value from a routine name.

Messages

No fixed PostgreSQL message variant was adopted because the bounded scan did not resolve a native report group.

Diagnosis

Find the fixed external routine handler or driver validator and inspect the five-character value and message. The bounded scan leaves the native source boundary unresolved.

Response

Repair the routine’s returned SQLSTATE or the interface contract according to its owner. Do not retry until the invalid return and completion state are understood.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The facts block lists the published snapshots; source-path status is limited to the fixed PostgreSQL 18.6 evidence below.

39000, 2F000

Sources

See the fixed source links and message limits in the structured evidence record.

150 - 39004 — null_value_not_allowed

Source-backed reference for PostgreSQL SQLSTATE 39004.

39004

At a glance

39004 is null_value_not_allowed. The fixed definition is present, but the bounded PostgreSQL 18.6 call archive has no resolved report group for this code; diagnose the actual routine or extension boundary before assigning an operation.

Field Value
SQLSTATE 39004
Condition null_value_not_allowed
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_E_R_I_E_NULL_VALUE_NOT_ALLOWED
Aliases

Meaning

It identifies a routine-level NULL contract failure, but the fixed source scan does not identify which routine or wrapper emits it. The condition name alone cannot distinguish an argument, return, trigger, or extension boundary.

Diagnosis

Use the full diagnostics to locate the actual routine or extension, then inspect the deployed implementation for this SQLSTATE. The bounded archive is not an absence proof.

Response

Fix the NULL contract identified by the actual routine or wrapper, then recheck the operation. Without a confirmed emitting path, avoid code-specific transaction or retry claims.

Versions

The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

39000, 39P01

Sources

See the fixed source links, message templates, and scope limits in the structured evidence record.

151 - 39P01 — trigger_protocol_violated

Source-backed reference for PostgreSQL SQLSTATE 39P01.

39P01

At a glance

39P01 is trigger_protocol_violated. Fixed PostgreSQL 18.6 paths cover the core trigger manager, contrib/tcn checks, and PL/Perl trigger return handling, with path-specific messages and severity.

Field Value
SQLSTATE 39P01
Condition trigger_protocol_violated
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED
Aliases

Meaning

The code marks a trigger protocol mismatch. Core trigger-manager messages include trigger function %u returned null value and BEFORE STATEMENT trigger cannot return a value. contrib/tcn checks trigger timing, level, argument count, and primary-key setup; PL/Perl has a DELETE-row WARNING and a separate ERROR for an invalid trigger return.

Diagnosis

Use the exact message to identify the path. For the trigger manager, check the isnull flag and BEFORE STATEMENT return contract; for tcn, check AFTER timing, row level, argument count, and primary key; for PL/Perl, check whether the return is undef, SKIP, or MODIFY. The DELETE-row WARNING means a modification was ignored, while the invalid-return message is an ERROR.

Response

Correct the timing, level, event, arguments, or return value for the identified path. For PL/Perl, decide whether the ignored DELETE-row modification is acceptable before writing again; retry only after the contract is fixed and the original operation is known not to have completed.

Versions

The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

39P02, 39P03, 2F005

Sources

See the fixed trigger.c, tcn.c, and plperl.c paths alongside the structured evidence record.

152 - 39P02 — srf_protocol_violated

Source-backed reference for PostgreSQL SQLSTATE 39P02.

39P02

At a glance

39P02 is srf_protocol_violated. The fixed executor path checks value-per-call and materialize set-returning-function contracts and reports the exact violated return mode.

Field Value
SQLSTATE 39P02
Condition srf_protocol_violated
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED
Aliases

Meaning

The executor received a set-returning function state that violated the selected protocol: table-function protocol for value-per-call mode was not followed, table-function protocol for materialize mode was not followed, or unrecognized table-function returnMode: %d.

Diagnosis

Inspect the C or extension function that sets ReturnSetInfo fields, especially returnMode, isDone, and returnSet. This is an SRF protocol issue, not a row-count result.

Response

Repair the SRF value-per-call or materialize implementation and its ReturnSetInfo state; changing LIMIT or transaction policy does not repair the executor contract.

Versions

The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

39P01, 39P03, 2F002

Sources

See the fixed execSRF.c and materialize path (lines 665-686) alongside the structured evidence record.

153 - 39P03 — event_trigger_protocol_violated

Source-backed reference for PostgreSQL SQLSTATE 39P03.

39P03

At a glance

39P03 is event_trigger_protocol_violated. Fixed event-trigger helpers reject calls outside their required sql_drop, table_rewrite, or event-trigger function context.

Field Value
SQLSTATE 39P03
Condition event_trigger_protocol_violated
Status active
Known present by 9.5.0
Locked snapshots 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_E_R_I_E_EVENT_TRIGGER_PROTOCOL_VIOLATED
Aliases

Meaning

An event-trigger helper was called without the state it requires. The fixed messages identify sql_drop, table_rewrite, or a general event-trigger function context, so this is a call-context violation rather than an object-existence error.

Diagnosis

Identify the helper and required event context from the message. Check whether the call belongs in a sql_drop, table_rewrite, or other event-trigger function.

Response

Move the helper into the required event-trigger context or remove the invalid call; replaying the same DDL does not change that context.

Versions

The locked catalogue records this condition from 9.5.0 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

39P01, 39P02, P0004

Sources

See the fixed event_trigger.c helper paths alongside the structured evidence record.

154 - 3B000 — savepoint_exception

Source-backed reference for PostgreSQL SQLSTATE 3B000, with explicit mechanism boundaries.

3B000 — savepoint_exception

At a glance

3B000 is the savepoint-exception class definition. The fixed core call scan resolves the more specific 3B001 missing-savepoint path rather than a separate generic 3B000 throw site. Use the concrete server SQLSTATE when diagnosing a savepoint failure; this entry does not invent a class-level RAISE case.

Field Value
SQLSTATE 3B000
Condition savepoint_exception
Status active
Known present by 8.0.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SAVEPOINT_EXCEPTION
Aliases

Meaning

3B000 is the Class 3B savepoint exception condition. The fixed scan resolves the concrete missing-savepoint code 3B001, but no separate generic core throw site for the class code. A savepoint name that cannot be found should therefore be diagnosed as the concrete 3B001 path when the server provides it.

Diagnosis

Record the requested savepoint name, whether an explicit transaction exists, and whether the marker was released or belongs to another nested level. Check the server’s concrete SQLSTATE before using the class label: ROLLBACK TO SAVEPOINT outside a transaction is 25P01, while a missing marker in an explicit block is represented by 3B001 in the selected sources. This page has no natural runtime case of its own.

Response

Use the concrete error to choose the boundary: begin a transaction before creating a savepoint, or roll back the failed explicit block before establishing a new marker. Do not invent a class-level 3B000 retry or use CASCADE; keep 3B000 as the definition boundary and follow the 3B001 source-backed path for a missing name.

Versions

The locked facts table records catalogue presence across the project snapshot range. The fixed source evidence is limited to the path stated below; no exact behavioral introduction or broader runtime coverage is inferred from the definition alone.

See 3B001 invalid savepoint specification for the concrete missing-savepoint path.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6 fixed call scan (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

155 - 3B001 — invalid_savepoint_specification

PostgreSQL SQLSTATE 3B001: missing savepoints, transaction state, and recovery.

3B001 — invalid_savepoint_specification

At a glance

3B001 means that a savepoint operation named a savepoint that is absent at the current transaction level. It is different from 25P01, which means there is no active transaction block at all.

Field Value
SQLSTATE 3B001
Condition invalid_savepoint_specification
Status active
Known present by 8.0.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_S_E_INVALID_SPECIFICATION
Aliases

Meaning

The transaction manager raises 3B001 when ROLLBACK TO SAVEPOINT or a related savepoint operation cannot find the requested name in the current savepoint stack. PostgreSQL 18’s source template includes the name; the PG10 source uses the older no such savepoint wording. The missing name is a transaction-structure problem, not a table-data conflict.

Diagnosis

Capture SQLSTATE, primary message, transaction status, and the exact savepoint sequence. Check spelling, whether a savepoint was released, and whether a nested procedure or subtransaction changed the current savepoint level. After an ERROR inside an explicit block, the connection is INERROR; do not issue catalog or repair SQL there before rollback.

Response

Rollback the failed block, begin a new explicit transaction, and establish a savepoint whose name and nesting are known. If partial work should survive, use a correctly named savepoint before the risky statement and ROLLBACK TO that existing marker; a missing marker cannot be reconstructed after the error. Treat a retry as a new transaction plan and preserve the application’s normal idempotency checks.

Messages

18.6’s fixed source has savepoint "%s" does not exist and a related current-level variant. The selected PG10 output is no such savepoint. These are source-confirmed version/call differences; branch on 3B001 and transaction state rather than a single English message.

Representative case

verify/cases/3B001/snippets.json (SHA-256 595ce7692e34d36cc31df94c65c7040ee9bc4558fa887c23b56ba3187d235deb) contains an explicit BEGIN, an existing present savepoint, a ROLLBACK TO SAVEPOINT missing, and a rollback/repaired sequence. See the public case export and structured evidence.

BEGIN;
SAVEPOINT present;
ROLLBACK TO SAVEPOINT missing;
ROLLBACK;
BEGIN;
SAVEPOINT present;
RELEASE SAVEPOINT present;
COMMIT;

The runner uses autocommit only to make each registry BEGIN/ROLLBACK/COMMIT boundary explicit. It asserts INERROR after the missing marker and IDLE after the recovery commit.

The selected case observed 3B001 on PostgreSQL 18.6 and 10.21. PostgreSQL 18 reported savepoint "missing" does not exist; PostgreSQL 10 reported no such savepoint. Both left the explicit block INERROR until ROLLBACK, after which a valid savepoint sequence committed.

Versions

The catalogue records 3B001 from its 8.0.0-or-earlier boundary through the formal snapshots. The selected 18.6 and 10.21 runs demonstrate the SQLSTATE and recovery boundary, while the primary message changed from the older generic wording to a named-savepoint template.

See 3B000 savepoint exception for the class definition and 25P01 no active transaction when no transaction block exists.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.xact.18.6 (SHA-256 75b012c0b047d1dc905a30975c244beec366e45eac0dbf109fd21bcd611a8e39)
  • src.xact.10.23 (SHA-256 9120bd418bd0f18e3f1065a3772c92ff68f3be54e1a8c6d415043197f6daa47c)
  • SAVEPOINT documentation · local call scan src.calls.REL_18_6 (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

156 - 3D000 — invalid_catalog_name

PostgreSQL SQLSTATE 3D000: invalid_catalog_name, source-backed diagnosis and recovery guidance.

3D000

At a glance

SQLSTATE 3D000 is invalid_catalog_name in Class 3D. 3D000 identifies an invalid database/catalog name. It can occur before startup completes when a requested database is absent, and fixed dbcommands.c paths also emit it while a SQL command resolves a missing database/template. The selected startup case reports C=3D000, S=FATAL, database "<generated>" does not exist; that is one phase, not the whole class.

Field Value
SQLSTATE 3D000
Condition invalid_catalog_name
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_CATALOG_NAME, ERRCODE_UNDEFINED_DATABASE
Aliases ERRCODE_UNDEFINED_DATABASE

Meaning

The code covers database/catalog resolution in more than one phase. postinit.c emits the selected startup FATAL when the requested database does not exist, while dbcommands.c uses the same condition for SQL commands that resolve a missing database or template. The startup record is therefore one concrete producer, not a universal description of every 3D000.

Treat the phase as part of the diagnosis. A startup DSN for a missing database produces a server FATAL and no session-level transaction; a SQL command such as an administrative database/template lookup can produce an ERROR inside an existing session, where normal rollback or savepoint recovery applies. The code alone does not tell you which phase failed.

Phase guide

Phase Fixed producer Recovery boundary
Startup database selection postinit.c reports database "%s" does not exist as FATAL. Fix the DSN or create/rename the database from a control database, then make a fresh connection. There is no session to roll back.
SQL command or template lookup dbcommands.c uses 3D000 while handling an administrative command. Inspect the command and its transaction; an ERROR inside an explicit transaction requires ROLLBACK or an intentional savepoint before unrelated work.

Diagnosis

Check the database name, whether it was renamed or dropped, the command phase, and which control database is available. The selected collector is a raw server ErrorResponse record, not csvlog/jsonlog; raw startup and psycopg are independent attempts. The selected runs use independent startup attempts: psycopg reports driver SQLSTATE null and no transaction, while the raw server ErrorResponse and a fresh known-database probe establish the server code and recovery path. Do not confuse a missing database with 3F000 schema lookup.

For startup failures, compare the exact database parameter after client-side defaults, URL decoding, and environment expansion; then inspect the raw server C, S, and M fields. For an already-connected SQL command, capture the command text and transaction state separately. The successful control-database probe proves only that a new session can be established, not that the original missing-database attempt had a transaction.

Response

Use an existing control database to inspect or create the intended database, or correct the DSN/command target, then establish a new connection. A pre-session failure has no session-level ROLLBACK; SQL command paths must be repaired in their owning administrative transaction and rechecked against the intended catalog.

If the database was intentionally removed, repair the application target or migration rather than retrying the same startup request. If an administrative command failed after a session existed, recover that transaction before issuing catalog changes. Reconcile any work sent by another connection before repeating it; the startup failure itself did not execute SQL in the missing database.

Observed diagnostics

The selected startup branch emits FATAL with primary database "%s" does not exist; the database name is dynamic. Fixed SQL-command paths use the same SQLSTATE but can have different surrounding operation and transaction boundaries. A client-side startup exception without the server ErrorResponse is insufficient.

The selected name c3d000_missing_cff0e8d38be4 is generated by the run. The server ErrorResponse is C=3D000, S=FATAL; psycopg’s startup sqlstate=null and the known-database probe are separate attempts, not additional views of one session.

Representative case

The registry contains the probe used after the startup ErrorResponse. The trigger uses a generated database name on a fresh startup connection, so no SQL statement can reproduce that pre-session failure.

SELECT 1;

The selected 18.6 server ErrorResponse is C=3D000, S=FATAL, database "c3d000_missing_cff0e8d38be4" does not exist. The driver startup diagnostic has SQLSTATE null; the failed connection has no transaction, while the known-good probe returned 1 and IDLE.

The downloadable case and evidence projections are 3D000 case JSON and authored evidence. The runner manifest is verify/cases/3D000/cases.json; the page SQL is checked against its shared registry before publication.

Versions

The generated facts table records the locked catalogue snapshots and earliest observed definition. The selected natural runtime scope is PostgreSQL 18.6 and 10.21; this does not infer behavior for every intermediate release.

Sources

  • src.postinit-missing-db.18.6src/backend/utils/init/postinit.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 abcf80637b153d3aa6f0d2b600943af0a2b4d9a393d05a844db91f8b6b66d0d7 (source).
  • src.postinit-missing-db.10.23src/backend/utils/init/postinit.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 be912628b29f34afc7b7fbc9d2f480c5ac9cb6ce013a1d992fc7415a311a95ed (source).
  • src.dbcommands-missing-database.18.6src/backend/commands/dbcommands.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 64b77d2197dce16eb1ad19d8168382459d621a03df0b00be157f7db39ca22acf (source).
  • src.dbcommands-missing-database.10.23src/backend/commands/dbcommands.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 cf9e069415deb7d50ef931048616ae7f9a459d6db64e3d54a0062e8334970ce6 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed local call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.

157 - 3F000 — invalid_schema_name

PostgreSQL SQLSTATE 3F000: invalid_schema_name, source-backed diagnosis and recovery guidance.

3F000

At a glance

SQLSTATE 3F000 is invalid_schema_name in Class 3F. 3F000 means a schema name cannot be resolved in an established session. The selected qualified-table path receives schema "<generated>" does not exist, while fixed namespace and schema-command paths cover resolution during object creation and other SQL commands; it is not simply a search_path hint.

Field Value
SQLSTATE 3F000
Condition invalid_schema_name
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_SCHEMA_NAME, ERRCODE_UNDEFINED_SCHEMA
Aliases ERRCODE_UNDEFINED_SCHEMA

Meaning

The namespace lookup raises this condition when a schema name itself cannot be resolved. A qualified reference to an absent schema uses schema "%s" does not exist; an unqualified CREATE path with no usable creation namespace uses no schema has been selected to create in. Both are schema-resolution branches. An ordinary unqualified relation lookup that finds no relation is 42P01, even when the reason is an unsuitable search_path; a privilege denial follows 42501.

The first question is whether the failing name is a schema or a relation. A qualified reference such as missing_schema.repaired_table asks the namespace code for that exact schema and can produce 3F000. A CREATE with no explicit schema can produce 3F000 when no schema is selected for creation. By contrast, SELECT * FROM missing_table is an unqualified relation lookup and normally produces 42P01; search_path helps explain which relations are searched but does not change that SQLSTATE into 3F000. A role that lacks the required privilege follows 42501. These are different repairs even when the application reports them as “schema not found”.

Diagnosis

Distinguish an explicitly missing schema, a CREATE with no selected creation schema, an unqualified relation lookup, and 42501 privilege denial. The selected autocommit session is IDLE after the ERROR; the owner creates the intended schema and table, inserts one row, and verifies it under the explicit namespace. Check the same role and database used by the failing command.

Inspect the failing identifier with the same role and database, for example by checking current_schemas(true) and whether the intended schema resolves in the catalog. Then verify the command’s qualification: the selected case deliberately uses a missing qualified schema. If the statement is CREATE without a schema, inspect whether search_path has any usable creation target; if it is an unqualified relation read, classify a missing relation as 42P01 rather than 3F000. In an explicit transaction, the selected ERROR can leave the transaction in INERROR; the autocommit IDLE observation is not a universal recovery result.

Response

Use the migration or owner-controlled CREATE SCHEMA, set or qualify the intended namespace, and verify the object under the same role. For no schema has been selected to create in, choose an allowed creation schema or qualify the CREATE statement. For an unqualified missing relation, repair the relation name or its intended search_path and expect 42P01 until the relation resolves. Keep schema creation separate from adding unrelated entries to search_path; if the name was intentionally removed, repair the migration or target rather than retrying unchanged.

After creating or exposing the schema, rerun the exact qualified statement and verify the resulting object with the same role. If the failed statement is inside an explicit transaction, roll back or return to a planned savepoint before issuing unrelated DDL. Do not grant broad schema privileges as a substitute for checking whether the application used the right database or identifier.

Observed diagnostics

The fixed namespace paths emit ERROR with primary schema "%s" does not exist for an explicitly missing schema and no schema has been selected to create in when an unqualified CREATE has no active creation namespace. The selected qualified-table case has no fixed DETAIL or HINT. An unqualified relation miss is the separate 42P01 relation "%s" does not exist path, while a role’s lack of privilege is 42501.

The selected dynamic name is c3f000_invalid_schema_name_missing, and the error occurred after session establishment with no fixed DETAIL or HINT. This is distinct from the source-defined schema-command paths and from a client startup failure.

Representative case

The SQL block qualifies a missing schema, creates the schema and table, inserts one row, verifies it, and drops the disposable schema.

CREATE TABLE missing_schema.repaired_table (id integer);
CREATE SCHEMA missing_schema;
CREATE TABLE missing_schema.repaired_table (id integer);
INSERT INTO missing_schema.repaired_table VALUES (1);
SELECT count(*) FROM missing_schema.repaired_table;
DROP SCHEMA missing_schema CASCADE;

The selected 18.6 run reports SQLSTATE 3F000, primary schema "c3f000_invalid_schema_name_missing" does not exist, and the asserted recovery state is IDLE before the final probe/repair. Every assertion and cleanup passed on 18.6 and 10.21.

The downloadable case and evidence projections are 3F000 case JSON and authored evidence. The runner manifest is verify/cases/3F000/cases.json; the page SQL is checked against its shared registry before publication.

Versions

The generated facts table records the locked catalogue snapshots and earliest observed definition. The selected natural runtime scope is PostgreSQL 18.6 and 10.21; this does not infer behavior for every intermediate release.

Sources

  • src.namespace-missing-schema.18.6src/backend/catalog/namespace.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 8c9e6a99e84fa2cec8a9b1de2ecbe3966a13f4ad68c6ccfbfb8134a754d73e56 (source).
  • src.namespace-missing-schema.10.23src/backend/catalog/namespace.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 74833354740d0e5679507d07b3c6e41aea01c2cb30adcd1e238bed3ebf96ddc6 (source).
  • src.namespace-creation-no-schema.10.23src/backend/catalog/namespace.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 74833354740d0e5679507d07b3c6e41aea01c2cb30adcd1e238bed3ebf96ddc6 (source).
  • src.parse-relation-undefined-table.10.23src/backend/parser/parse_relation.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 a34f40fc93fa5df0015fe5af5ee7761ccba2d16a791cda69ae07848ed27616b5 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed local call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.

158 - 40000 — transaction_rollback

Source-backed reference for PostgreSQL SQLSTATE 40000, with explicit mechanism boundaries.

40000 — transaction_rollback

At a glance

40000 is an umbrella transaction-rollback condition. The fixed 18.6 source contains an internal system-catalog-scan path with transaction aborted during system catalog scan; reproducing that path would require an internal fault or visibility condition outside a safe SQL-only case. Do not turn a serialization failure, deadlock, or arbitrary client cancellation into 40000.

Field Value
SQLSTATE 40000
Condition transaction_rollback
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_TRANSACTION_ROLLBACK
Aliases

Meaning

40000 is the broad transaction rollback condition. The resolved core path in genam.c is a defensive internal error: a transaction aborted during a system catalog scan. It is not the normal client-visible retry path represented by 40001, and it is not a deadlock report.

Diagnosis

For a real 40000, preserve the server log, backend PID, operation, and source diagnostics; the fixed primary template is transaction aborted during system catalog scan. Check whether the log points to an internal catalog/index visibility failure or a server fault. A client-side ROLLBACK, serialization failure, or canceled statement is insufficient evidence for this code, and the selected scan has no safe SQL-only reproduction.

Response

Let the failed transaction end as the server requires, then investigate the catalog/index and server health before retrying. Reconnect only when the session is unusable, and verify durable state before repeating a write. Do not turn 40001/40P01 or a generic rollback into 40000; this page records the internal source boundary only.

Versions

The locked facts table records catalogue presence across the project snapshot range. The fixed source evidence is limited to the path stated below; no exact behavioral introduction or broader runtime coverage is inferred from the definition alone.

Compare 40001 serialization failure and 40P01 deadlock detected for retryable transaction rollback mechanisms with concrete SQL paths.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • source path (SHA-256 11897b1d8b1ae1f4a1bef9a72e740da7aa83579abf84e4ca5ebacd6530874c28)

159 - 40001 — serialization_failure

PostgreSQL reports SQLSTATE 40001 when a serializable transaction cannot be committed consistently with a concurrent update. Roll back and retry the complete transaction from a fresh snapshot.

At a glance

40001 is PostgreSQL’s serialization_failure condition in Class 40, transaction_rollback. It tells the client that the transaction’s observed ordering cannot be serialized with a concurrent transaction. PostgreSQL aborts the conflicting transaction so the client can retry.

The representative case starts two SERIALIZABLE transactions that read the same value. The first updates and commits. The stale transaction then receives could not serialize access due to concurrent update, enters INERROR, and returns to IDLE only after ROLLBACK. A new serializable transaction reads the committed value, applies the registry’s fixed SET value = 2 operation, commits, and produces the final result; this is a transaction-boundary proof, not a test of an application business calculation.

Run 40001-manual-boundary-final-20260909 passed on PostgreSQL 18.6 and isolated PostgreSQL 10.21. The per-target assertions and structured observations are retained in the public evidence JSON.

Field Value
SQLSTATE 40001
Condition serialization_failure
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_T_R_SERIALIZATION_FAILURE
Aliases

Meaning and trigger paths

At SERIALIZABLE isolation PostgreSQL uses predicate and tuple-conflict tracking to reject a transaction when its result would depend on an order that cannot be made serial. A concurrent update of a row read by a stale transaction is one concrete path. The SQLSTATE describes the transaction outcome; it does not identify the business operation that should be retried.

The executor’s update path reports ERRCODE_T_R_SERIALIZATION_FAILURE with the source message could not serialize access due to concurrent update. Other serialization conflicts can use a different message or a recovery-conflict detail while retaining the class’s transaction-rollback meaning. Preserve the complete diagnostic and the transaction’s read/write set in application logs.

40001 differs from 23505: a duplicate requested by the user is not automatically a serialization failure, even though some concurrent key-selection designs can surface a unique violation that the application treats as retryable. Decide the retry policy from the operation’s semantics and the complete transaction history.

Messages and diagnostics

The case schedule below must use two sessions for the two initial snapshots. The final block is a new connection and a new serializable snapshot; it is the required complete retry.

CREATE TABLE serial_rows(id integer PRIMARY KEY, value integer NOT NULL);
INSERT INTO serial_rows VALUES (1, 0);

-- Open both serializable snapshots before the first commit.
BEGIN ISOLATION LEVEL SERIALIZABLE;
BEGIN ISOLATION LEVEL SERIALIZABLE;

-- Session first reads 0; session stale reads the same 0.
SELECT value FROM serial_rows WHERE id = 1;
SELECT value FROM serial_rows WHERE id = 1;

-- Session first writes 1 and commits; the stale session then writes from its old snapshot.
UPDATE serial_rows SET value = 1 WHERE id = 1;
COMMIT;
UPDATE serial_rows SET value = 2 WHERE id = 1;
-- The UPDATE reports 40001 and the transaction becomes INERROR.
ROLLBACK;

-- New retry transaction: read the fresh value, apply the operation, and commit.
BEGIN ISOLATION LEVEL SERIALIZABLE;
SELECT value FROM serial_rows WHERE id = 1;
UPDATE serial_rows SET value = 2 WHERE id = 1;
COMMIT;
SELECT value FROM serial_rows WHERE id = 1;

PostgreSQL 18.6 returned:

SQLSTATE: 40001
severity: ERROR
message_primary: could not serialize access due to concurrent update
message_detail: <none>
source: nodeModifyTable.c / ExecUpdate / line 2604

PostgreSQL 10.21 produced the same primary message with its version-specific nodeModifyTable.c line. message_detail is absent in this path; other conflict origins may attach additional fields. The SQLSTATE and the aborted transaction state are the stable retry signals.

Diagnosis

Capture SQLSTATE, severity, primary message, detail, hint, context, isolation level, the statements that formed the snapshot, and transaction status. Determine which transaction committed first and which reads became stale. The runner asserted both initial reads were 0, the first commit returned IDLE, and the stale transaction was INERROR before rollback.

Do not issue a follow-up query on the failed transaction. Roll it back, start a new transaction, and repeat the complete read/decision/write sequence. Replaying only the last UPDATE can apply a decision based on a snapshot that is no longer valid.

Response and repair

Treat 40001 as a transaction retry signal when the operation is designed for it:

  • Roll back the entire failed transaction and release its locks.
  • Begin a new transaction at the required isolation level and re-read all values used by the business decision.
  • Apply the operation again, with a bounded backoff and a maximum retry count.
  • Make the operation idempotent and verify the final business result after commit.

The representative retry read 1, wrote 2, committed with status IDLE, and a separate read observed final value 2. A fixed assignment in this disposable case does not prove that an arbitrary production calculation is safe to replay; the application must recompute from the fresh snapshot.

Versions and boundaries

The catalogue has a definition-presence observation for 40001 at PostgreSQL 7.4 and through the locked 8.4.22 pre-9.0 definitions, then in every listed formal snapshot through PostgreSQL 18.6 and the PostgreSQL 19 Beta 3 preview. This is a definition-only presence boundary, not an exact implementation introduction or runtime-use claim. The class title observation between 9.0 and 9.1 is recorded in the catalogue; the condition has no other recorded definition change in the scanned range.

The stale-update case passed on PostgreSQL 18.6 and 10.21. Message source lines and conflict details vary by release and conflict type. This evidence covers a stale serializable update and its fresh complete retry; it does not claim that every 40001 source path has the same message or that every transaction can be retried safely.

40P01deadlock_detected also aborts a transaction and can require a complete retry, but its trigger is a lock cycle. 23505unique_violation is a distinct integrity condition and is not automatically retryable. 23503foreign_key_violation can be a permanent data relationship error. 25P02in_failed_sql_transaction is the follow-on state before a failed transaction is rolled back.

Sources

Structured evidence is recorded in the public evidence JSON. Source records use PostgreSQL commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; run records retain exact target IDs and structured observations.

160 - 40002 — transaction_integrity_constraint_violation

Source-backed reference for PostgreSQL SQLSTATE 40002, with explicit mechanism boundaries.

40002 — transaction_integrity_constraint_violation

At a glance

40002 is a catalogue-defined transaction-integrity condition. No distinct PostgreSQL core 40002 call site was resolved in the fixed scan used for this batch, so no foreign-key, unique, or other concrete constraint error is relabeled as this umbrella code. Capture the actual SQLSTATE emitted by the operation.

Field Value
SQLSTATE 40002
Condition transaction_integrity_constraint_violation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_T_R_INTEGRITY_CONSTRAINT_VIOLATION
Aliases

Meaning

40002 names transaction integrity constraint violation in Class 40, but the fixed PostgreSQL core scan did not resolve a distinct 40002 call site. PostgreSQL’s concrete integrity mechanisms normally report a specific Class 23 code, such as 23502, 23503, 23505, 23514, or 23P01.

Diagnosis

Read the actual SQLSTATE, constraint name, relation, column, and DETAIL from the error. If the server reports a concrete Class 23 code, diagnose that constraint and its transaction state; do not promote it to 40002 because the operation was transactional. This page has no selected natural runtime case or server-specific message template.

Response

Repair the concrete constraint violation and its transaction boundary, then verify the intended durable state. Do not add a generic retry or relabel a known 235xx/23P01 result as 40002; use this class definition only when a real component supplies that code and its own evidence.

Versions

The locked facts table records catalogue presence across the project snapshot range. The fixed source evidence is limited to the path stated below; no exact behavioral introduction or broader runtime coverage is inferred from the definition alone.

Use the concrete integrity code, such as 23503 foreign-key violation or 23505 unique violation, when the server provides one.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6 fixed call scan (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

161 - 40003 — statement_completion_unknown

Source-backed reference for PostgreSQL SQLSTATE 40003, with explicit mechanism boundaries.

40003 — statement_completion_unknown

At a glance

40003 describes uncertainty about statement completion, generally a reconciliation problem at a connection or protocol boundary. The fixed core scan did not provide a safe SQL-only natural trigger for this batch. A client timeout or a fabricated RAISE is not proof of uncertain server completion: reconcile durable business state before retrying.

Field Value
SQLSTATE 40003
Condition statement_completion_unknown
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_T_R_STATEMENT_COMPLETION_UNKNOWN
Aliases

Meaning

40003 means statement completion is unknown: after a connection or transport failure, the client cannot tell whether the server completed the statement. It is an outcome-knowledge boundary, not proof that the statement failed and not an instruction to roll back blindly.

Diagnosis

Correlate the request or idempotency key with server logs, backend activity, commit records, and durable business state. A socket exception commonly has no server SQLSTATE, and the fixed scan has no safe core SQL-only 40003 trigger. Treat a client timeout, broken connection, or ROLLBACK on a new session as separate facts rather than evidence that the original statement was undone.

Response

Reconcile before retrying: query authoritative durable state on a new healthy session, use an idempotency key only after matching the original request and business result, and ask the application whether the operation is safe to repeat. Do not claim that a generic retry or rollback resolves an unknown completion, and do not manufacture 40003 with RAISE or a local timeout.

Versions

The locked facts table records catalogue presence across the project snapshot range. The fixed source evidence is limited to the path stated below; no exact behavioral introduction or broader runtime coverage is inferred from the definition alone.

Compare 40001 serialization failure for a server-confirmed retryable outcome; 40003 requires reconciliation because completion is uncertain.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6 fixed call scan (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

162 - 40P01 — deadlock_detected

PostgreSQL reports SQLSTATE 40P01 when transactions form a lock cycle. Roll back the victim, keep lock order consistent, and retry the complete operation only when its business semantics permit it.

At a glance

40P01 is PostgreSQL’s deadlock_detected condition in Class 40, transaction_rollback. It means that the lock manager found a cycle in which transactions are waiting for one another, so PostgreSQL chose a victim and aborted its transaction.

The primary message is deadlock detected. The server may add a dynamically assembled wait graph in DETAIL, a hint to consult the server log, and a context naming the statement that was interrupted. Process IDs, transaction IDs, and the exact wait graph are run-specific; branch on SQLSTATE and retain the structured fields rather than matching those values.

The representative case first lets two sessions hold opposite row locks, then uses a threading.Barrier to release both cross-row requests while an independent observer samples pg_stat_activity for wait_event_type=Lock. The observer does not release the requests. After one session receives 40P01, its transaction is INERROR; the surviving session completes, and both sessions are then IDLE. A fresh transaction takes both row locks in order and commits the complete retry.

Run 40P01-manual-boundary-final-20260909 passed on PostgreSQL 18.6 and isolated PostgreSQL 10.21. Per-target assertions and structured observations are retained in the public evidence JSON.

Field Value
SQLSTATE 40P01
Condition deadlock_detected
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_T_R_DEADLOCK_DETECTED
Aliases

Meaning and trigger paths

A deadlock requires a cycle in the wait-for graph. A common form is session A locking row 1 and requesting row 2 while session B locks row 2 and requests row 1. PostgreSQL’s deadlock detector examines the lock graph after the configured deadlock timeout and reports the condition from DeadLockReport.

The error identifies a transaction coordination failure, not a damaged row. The victim’s whole transaction is aborted. The other transaction may continue after the detector breaks the cycle, but its successful outcome does not automatically mean the victim’s intended work was applied.

40P01 is distinct from a lock wait that eventually succeeds and from 57014 caused by a statement timeout. The observed pg_stat_activity wait is evidence of the cycle’s setup; the server’s deadlock detected response is the decisive condition.

Messages and diagnostics

The following schedule is the representative operation. Run the session A and B sections on separate connections; each session first holds one row, the barrier then releases both cross-row requests, and an independent observer samples both backends while the requests wait. The observer is not the release condition.

CREATE TABLE locks(id integer PRIMARY KEY, marker text NOT NULL);
INSERT INTO locks VALUES (1, 'seed-1'), (2, 'seed-2');

-- Session A: begin, set deadlock_timeout, and lock id = 1.
BEGIN;
SET deadlock_timeout = '100ms';
UPDATE locks SET marker = 'first-1' WHERE id = 1;

-- Session B: begin, set deadlock_timeout, and lock id = 2.
BEGIN;
SET deadlock_timeout = '100ms';
UPDATE locks SET marker = 'second-2' WHERE id = 2;

-- An explicit barrier releases both requests into the lock cycle.
UPDATE locks SET marker = 'first-2' WHERE id = 2;
UPDATE locks SET marker = 'second-1' WHERE id = 1;

-- The victim must ROLLBACK; the survivor can COMMIT.
ROLLBACK;
COMMIT;

-- Fresh retry connection: take locks in the same order and verify both rows.
BEGIN;
UPDATE locks SET marker = 'retry-1' WHERE id = 1;
UPDATE locks SET marker = 'retry-2' WHERE id = 2;
COMMIT;
SELECT id, marker FROM locks ORDER BY id;

PostgreSQL 18.6 returned this shape for the victim:

SQLSTATE: 40P01
severity: ERROR
message_primary: deadlock detected
message_detail: Process <pid-a> waits for ShareLock on transaction <xid-b>; blocked by process <pid-b>.
Process <pid-b> waits for ShareLock on transaction <xid-a>; blocked by process <pid-a>.
message_hint: See server log for query details.
context: while updating tuple (0,2) in relation "locks"
source: deadlock.c / DeadLockReport / line 1138

The PG10 run produced the same primary message and fields, with a version-specific source line. The detail is assembled from the live wait graph, so its process and transaction identifiers are intentionally represented as run-specific values here. The hint is not a claim that the client always receives a server log entry; it directs investigation to that log when configured.

Diagnosis

Record SQLSTATE, severity, primary message, detail, hint, context, the failed statement, backend PIDs, and transaction status. Inspect pg_stat_activity and relevant lock views while the wait is active. A useful observation includes wait_event_type=Lock, the wait event, the current query, and the participating PIDs; a sleep by itself cannot establish a deadlock.

Build the lock order from the actual application code and all paths that can touch the same rows or advisory locks. Check whether a trigger, foreign key, index, or background worker acquired an additional lock. deadlock_timeout controls when PostgreSQL runs detection; increasing it changes detection latency and does not remove the cycle.

After the error, the victim connection is not ready for unrelated commands: it is INERROR until ROLLBACK. The survivor may be INTRANS until its commit. The runner observed both return to IDLE after explicit cleanup and verified the rows before a retry.

Response and repair

Rollback the victim transaction and release its locks. Then choose a complete repair:

  • Make every code path acquire the same set of locks in a consistent order, preferably by ordering keys explicitly.
  • Keep the transaction short and avoid waiting for external work while holding database locks.
  • Retry the whole transaction, including reads and lock acquisition, only when the operation is safe to repeat and its result is idempotent.
  • Verify the committed business result after the retry; a survivor’s partial update is not proof that the victim’s work succeeded.

The representative repair took row 1 and row 2 in order, committed retry-1 and retry-2, and read both rows with the connection IDLE. A bounded retry budget and an application-level idempotency key are still needed in production; the SQLSTATE alone cannot decide whether repeating an operation is safe.

Versions and boundaries

The catalogue has a definition-presence observation for 40P01 at PostgreSQL 7.4 and through the locked 8.4.22 pre-9.0 definitions, then in every listed formal snapshot through PostgreSQL 18.6 and the PostgreSQL 19 Beta 3 preview. This is a definition-only presence boundary, not an exact implementation introduction or runtime-use claim. The class title changed between the 9.0 header view and the 9.1 text definition; that catalogue observation does not establish a code introduction date. The condition row itself has no recorded definition change in the scanned range.

The two-session case passed on PostgreSQL 18.6 and 10.21. Detector timing, lock types, and detail text depend on the workload and settings; the compatibility contract used here is SQLSTATE plus the transaction rollback requirement, not a fixed process-ID detail string.

40001serialization_failure also requires a complete transaction retry from a fresh snapshot. 57014query_canceled reports cancellation rather than a lock cycle. 23503foreign_key_violation and 23505unique_violation are integrity conditions that can occur inside a transaction whose lock ordering needs review. 25P02in_failed_sql_transaction is the follow-on state after the victim’s transaction is left aborted.

Sources

Structured evidence is recorded in the public evidence JSON. All source records use PostgreSQL commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; run records retain exact target IDs and structured observations.

163 - 42000 — syntax_error_or_access_rule_violation

PostgreSQL SQLSTATE 42000: syntax_error_or_access_rule_violation, source-backed diagnosis and recovery guidance.

42000

At a glance

SQLSTATE 42000 is syntax_error_or_access_rule_violation in Class 42. 42000 is the broad syntax-error-or-access-rule umbrella. This batch keeps it as a definition boundary because fixed PostgreSQL paths report concrete child codes such as 42501 and 42601.

Field Value
SQLSTATE 42000
Condition syntax_error_or_access_rule_violation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION
Aliases

Meaning

42000 is the broad syntax-error-or-access-rule umbrella. This batch keeps it as a definition boundary because fixed PostgreSQL paths report concrete child codes such as 42501 and 42601.

Diagnosis

First classify the server SQLSTATE and command phase. A client parser error or a locally raised exception does not prove the umbrella code, and a concrete child should not be widened to 42000.

Response

Repair the concrete syntax or access rule named by the diagnostic and retry only that command. Preserve the child code in logs and metrics.

Messages

This page has no selected natural emitter or fixed child message for the umbrella code. Concrete backend paths in this batch report child SQLSTATEs such as 42501 or 42601; a client exception without a server SQLSTATE is not sufficient to claim 42000.

Representative case

This page has no selected natural SQL run. The fixed source boundary is recorded without a synthetic trigger.

Versions

No natural SQL run is selected here. The fixed REL_18_6/REL_10_23 source boundary does not establish behavior for every intermediate release.

Sources

  • src.errcodes.18.6 — fixed errcodes.txt definition at commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.

164 - 42501 — insufficient_privilege

PostgreSQL SQLSTATE 42501: insufficient_privilege, source-backed diagnosis and recovery guidance.

42501

At a glance

SQLSTATE 42501 is insufficient_privilege in Class 42. 42501 is insufficient privilege. The selected natural path calls nextval on a runner-owned sequence from a separate role that has schema USAGE but no sequence USAGE; PostgreSQL reports permission denied for sequence %s.

Field Value
SQLSTATE 42501
Condition insufficient_privilege
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INSUFFICIENT_PRIVILEGE
Aliases

Meaning

42501 is insufficient privilege. In the selected path, nextval reaches nextval_internal, which checks sequence access for the effective GetUserId() before advancing the sequence. Schema USAGE lets the restricted role resolve objects in the schema; it does not grant the sequence privilege needed by this call. The server therefore emits the ERROR primary permission denied for sequence %s, with the sequence name supplied dynamically.

The ownership boundary matters: an owner or administrative connection prepares the disposable schema and sequence, while a separate restricted role runs nextval. The successful repair is a narrow GRANT USAGE ON SEQUENCE ... made by the owner/admin connection, followed by nextval again as the same restricted role; it is not evidence that the restricted role may grant itself access.

The same SQLSTATE also covers other privilege boundaries. The generic ACL checker can report permission denied for relation %s, permission denied for schema %s, or a column-specific form, while owner-only operations use must be owner of relation %s or the corresponding object kind. Row-level security is a separate executor check: a table ACL can pass while an INSERT or UPDATE row violates a policy and raises a new row violates row-level security policy ... error. These are source-confirmed producer branches, not additional observations from the selected sequence run.

Diagnosis

Check current_user and session_user, any SET ROLE, the database, schema, exact relation or column, and the relevant ACL. Keep the setup/grant connection separate from the probe connection: replace runner_host, runner_port, runner_db, and runner_user with the real disposable target and owner/admin credential, then connect separately as the generated restricted role (for example, syntax_role). A pool can otherwise make an ACL change appear to affect a different backend. If the primary names a relation, schema, or column, inspect that object’s privilege rather than assuming sequence USAGE; must be owner requires checking the object’s owner and effective role; an RLS primary requires inspecting the policy’s USING/WITH CHECK path and the role it applies to. The error is an ERROR on the selected autocommit probe, so that same probe session remains IDLE; an explicit transaction would need its normal error-state handling before more work. Distinguish this object-privilege failure from 28000 startup authorization and 0A000 unsupported features.

Response

Have the owner/admin connection grant only the required privilege on the exact object (the selected case needs sequence USAGE), or use the intended owner/security-definer or RLS policy when that is the application design. Re-run nextval on the same restricted-role session after the ACL change and verify the returned value and session state. A superuser would bypass ACL checks, but do not raise a role to superuser as a substitute for targeted least-privilege grants; schema USAGE, table privileges, and sequence privileges are separate checks. For an owner-only failure, use the owning/migration role or change ownership deliberately rather than treating an ACL grant as an owner transfer. Inspect the effective role if membership or SET ROLE is involved.

Messages

The selected sequence source path raises an explicit ERROR with SQLSTATE 42501 and primary permission denied for sequence %s. %s is the resolved sequence relation name; this path has no DETAIL or HINT. Other fixed ACL branches use permission denied for relation %s, permission denied for schema %s, and permission denied for column "%s" of relation "%s"; owner-only checks use must be owner of relation %s or the matching object kind. RLS WITH CHECK branches use new row violates row-level security policy ... primaries. A client exception without the server SQLSTATE and the primary for the specific branch is not sufficient to identify that 42501 producer.

Representative case

The page uses the same statements as the runner registry. The owner/admin connection creates the sequence and grants schema USAGE; the restricted-role connection runs both nextval probes. Generated names such as syntax_schema and syntax_role are replaced by disposable runner values when executed, and connection placeholders such as runner_host, runner_port, runner_db, and runner_user must be replaced with the actual target rather than copied literally.

CREATE SEQUENCE syntax_schema.syntax_sequence START WITH 1;
GRANT USAGE ON SCHEMA syntax_schema TO syntax_role;
SELECT nextval('syntax_schema.syntax_sequence');
GRANT USAGE ON SEQUENCE syntax_schema.syntax_sequence TO syntax_role;
SELECT nextval('syntax_schema.syntax_sequence');

The selected 18.6 run reports the structured diagnostic and passes the repair assertions; the 10.21 run passes the same case-specific checks. The downloadable case and evidence projections are 42501 case JSON and authored evidence. The runner manifest is verify/cases/42501/cases.json, and the page SQL is checked against its shared registry.

Versions

The selected natural runtime scope is PostgreSQL 18.6 and 10.21; it does not infer behavior for every intermediate release.

Sources

  • src.errcodes.18.6 — fixed errcodes.txt definition at commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.sequence-permission.18.6src/backend/commands/sequence.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 3e5afe17d5a84862fae502a5481211220368f1d639e9d07ba6f96ee8be92a8d8 (source).
  • src.sequence-permission.10.23src/backend/commands/sequence.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 5510e1266e8d8c548a4318d753392e92e689d348f3353a2aa53d8dea871c44ab (source).
  • src.aclcheck-errors.18.6 / src.aclcheck-errors.10.23 — fixed src/backend/catalog/aclchk.c ACL-kind tables map no-privilege and not-owner results to relation/schema/column messages; blob SHA-256 9700258318959b47c42edb423418fb511dd3a008023e732f601eecf4c80868f8 / 3a4330bd55ea8c0ec12324d7046ec31d64c920f99196235b84612d6cd1a4b26c (18.6 source, 10.23 source).
  • src.rls-errors.18.6 / src.rls-errors.10.23 — fixed src/backend/executor/execMain.c row-level security WITH CHECK errors; blob SHA-256 33b97337fa23a649c5e7a092e1bd405a54e8503529236c62c9d5bb93a1774a8d / 386d09f7e964ebc426a554cf51ac7cb505c67cc95b971ee7acad1a6e0a9d0c1a (18.6 source, 10.23 source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.

165 - 42601 — syntax_error

PostgreSQL SQLSTATE 42601: syntax_error, source-backed diagnosis and recovery guidance.

42601

At a glance

SQLSTATE 42601 is syntax_error in Class 42. 42601 is a syntax error. The selected parser path rejects LIMIT 1, 2 with primary LIMIT #,# syntax is not supported and hint Use separate LIMIT and OFFSET clauses.

Field Value
SQLSTATE 42601
Condition syntax_error
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SYNTAX_ERROR
Aliases

Meaning

42601 is a syntax error. In the selected gram.y action, the comma form is rejected during parsing with the ERROR primary LIMIT #,# syntax is not supported and hint Use separate LIMIT and OFFSET clauses. The comma form is therefore not a request for “offset 1, then take 2” in PostgreSQL; the two values must be written as separate clauses.

The scanner and grammar share a general 42601 path. scanner_yyerror sets the SQLSTATE and reports either syntax error at or near "%s" for the current token or syntax error at end of input when the scanner is at the buffer end, with a lexer position. Grammar actions can supply a more specific message through the same formatter. The selected LIMIT branch is one producer among these parser and scanner branches, not a requirement for every 42601.

Diagnosis

Capture the exact statement, parser position, server version, and hint. For at or near, inspect the token named by POSITION and the text immediately before it; for at end of input, check an unclosed quote, dollar-quote, parenthesis, comment, or generated clause. Preserve the exact bytes sent by the query builder, including delimiters and substituted fragments, and replay that statement through the server parser before changing semantics. The parser rejects this grammar before execution, so the selected autocommit session remains IDLE and no rows are produced by the failed statement. In an explicit transaction, the same statement-level ERROR leaves the transaction in its failed state until ROLLBACK or an appropriate savepoint action; that is a different session boundary from the selected autocommit observation. Do not confuse a grammar error with an undefined object or a feature recognized but unsupported in its context.

Response

Rewrite the statement using the grammar named by the hint. For the selected ordered three-row query, LIMIT 1, 2 becomes LIMIT 2 OFFSET 1 and returns rows [2, 3]; LIMIT 1 OFFSET 0 would be a different result and is not an equivalent repair. Keep query builders version-aware when they emit dialect-specific pagination.

For a generic scanner error, repair the missing or misplaced token, quote, comment delimiter, or query-builder fragment identified by the position, then parse the complete statement again. Do not apply the LIMIT rewrite to a different 42601 message merely because it shares the SQLSTATE.

Messages

The selected parser branch raises an explicit ERROR with primary LIMIT #,# syntax is not supported and HINT Use separate LIMIT and OFFSET clauses. The scanner’s generic fixed branches use syntax error at or near "%s" or syntax error at end of input, with the position generated from the lexer. The LIMIT primary/HINT identify the selected pagination subpath; a client exception without the server SQLSTATE and the diagnostics for the specific branch is not sufficient to identify that subpath, while other valid 42601 producers may have different primaries.

Representative case

The page uses the same statements as the runner registry. Generated names such as syntax_schema and syntax_role are replaced by disposable runner values when executed.

SELECT n FROM generate_series(1, 3) AS s(n) ORDER BY n LIMIT 1, 2;
SELECT n FROM generate_series(1, 3) AS s(n) ORDER BY n LIMIT 2 OFFSET 1;

The selected 18.6 run reports the structured diagnostic and passes the repair assertions; the 10.21 run passes the same case-specific checks. The downloadable case and evidence projections are 42601 case JSON and authored evidence. The runner manifest is verify/cases/42601/cases.json, and the page SQL is checked against its shared registry.

Versions

The selected natural runtime scope is PostgreSQL 18.6 and 10.21; it does not infer behavior for every intermediate release.

Sources

  • src.errcodes.18.6 — fixed errcodes.txt definition at commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.limit-comma.18.6src/backend/parser/gram.y at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 7e548b673a1e03eb3a56c5eb9ad92d8e11095fac76e14cb258ca851f58274724 (source).
  • src.limit-comma.10.23src/backend/parser/gram.y at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 cebad6a5a2bdf68e9e5a4d2e04fa7f5dbf37efac99f5edb73cc661dae1536bad (source).
  • src.scanner-syntax.18.6 / src.scanner-syntax.10.23 — fixed src/backend/parser/scan.l scanner_yyerror branches for at end of input and at or near; blob SHA-256 bf453f1ae3c22b84fea6f8e8bed4fda476b7cfa49b234efbf92ca228234d0293 / a006581a25c659d59b29837010617503ff431f881e3cf0b54a99aa1cc445fe6c (18.6 source, 10.23 source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.

166 - 42602 — invalid_name

PostgreSQL SQLSTATE 42602: invalid_name, source-backed diagnosis and recovery guidance.

42602

At a glance

SQLSTATE 42602 is invalid_name in Class 42. 42602 is an invalid name. The selected enum path rejects a 64-byte label with primary invalid enum label "%s" and a length detail; a short label can be added afterwards.

Field Value
SQLSTATE 42602
Condition invalid_name
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_NAME
Aliases

Meaning

42602 is an invalid name. In AddEnumLabel, PostgreSQL checks the incoming enum label against NAMEDATALEN - 1 before changing the catalog. The selected 64-byte label therefore raises an explicit ERROR with primary invalid enum label "%s" and a length DETAIL; a short label can be added afterwards. This is the enum-label path, not a claim that every invalid object name uses the same producer.

Diagnosis

Inspect the object kind and the exact length wording in the DETAIL. This batch observes the enum-label path on 18.6 and 10.21: the 18.6 source/runtime says Labels must be 63 bytes or less., while the 10.21 source/runtime says Labels must be 63 characters or less. That wording difference alone does not establish a changed length mechanism; both fixed guards compare the label against NAMEDATALEN - 1. The failed DDL is an ERROR on autocommit and leaves the selected session IDLE.

Response

Choose a label within the server limit or store the long user value as data. Preserve the enum type and add a valid short label only after the failed statement has returned; the selected repair leaves the type with ok and short. Do not silently truncate enum labels or treat this enum-specific path as every possible naming error.

Messages

The selected source path emits an explicit ERROR with primary invalid enum label "%s". Its DETAIL is Labels must be 63 bytes or less. on 18.6 and Labels must be 63 characters or less. on 10.21; the label text is dynamic. A client exception without the server SQLSTATE, primary, and length DETAIL is not sufficient to identify this selected enum-label subpath; other fixed producers can use the same SQLSTATE with different diagnostics.

Representative case

The page uses the same statements as the runner registry. Generated names such as syntax_schema and syntax_role are replaced by disposable runner values when executed.

CREATE TYPE syntax_schema.syntax_enum AS ENUM ('ok');
ALTER TYPE syntax_schema.syntax_enum ADD VALUE 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
ALTER TYPE syntax_schema.syntax_enum ADD VALUE 'short';
SELECT enum_range(NULL::syntax_schema.syntax_enum)::text[];

The selected 18.6 run reports the structured diagnostic and passes the repair assertions; the 10.21 run passes the same case-specific checks. The downloadable case and evidence projections are 42602 case JSON and authored evidence. The runner manifest is verify/cases/42602/cases.json, and the page SQL is checked against its shared registry.

Versions

The selected natural runtime scope is PostgreSQL 18.6 and 10.21; it does not infer behavior for every intermediate release.

Sources

  • src.errcodes.18.6 — fixed errcodes.txt definition at commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.enum-invalid-label.18.6src/backend/catalog/pg_enum.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 849793e92baf9c0e4e8950f8472e2772289c22c58a4ea93997ef0218d7e4b3fc (source).
  • src.enum-invalid-label.10.23src/backend/catalog/pg_enum.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 08076bbd661f4c400cf9741f4cfe89c5b0daf3383e4a3e6ac10f3f8f4bec16a6 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.

167 - 42611 — invalid_column_definition

PostgreSQL SQLSTATE 42611: invalid_column_definition, source-backed diagnosis and recovery guidance.

42611

At a glance

SQLSTATE 42611 is invalid_column_definition in Class 42. 42611 is an invalid column definition. Two inherited parents in the selected case define different defaults for id; the child definition fails with column "%s" inherits conflicting default values and the hint to specify a default explicitly.

Field Value
SQLSTATE 42611
Condition invalid_column_definition
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_COLUMN_DEFINITION
Aliases

Meaning

42611 is an invalid column definition. During MergeAttributes, PostgreSQL merges parent columns left to right. If equal-named inherited columns have non-equal default expressions, the merge marks the default as conflicting; unless the child overrides it, the final check raises ERROR column "%s" inherits conflicting default values with the hint to specify a default explicitly. Two inherited parents in the selected case define different defaults for id.

Diagnosis

Inspect every parent in the INHERITS list and compare the equal-named columns’ type, collation, nullability, and default expressions. A matching default can merge; a child-local default overrides the inherited conflict. The selected DDL ERROR leaves the autocommit session IDLE; this is the inherited-default branch, not a generic duplicate-column error or a type/collation conflict.

Response

Declare the intended child default explicitly, as the server hint says, then insert DEFAULT VALUES and verify the result. If the parent definitions are supposed to agree, repair the migration at the parents instead; if they intentionally differ, keep the child override visible in the DDL. The selected repair returns 1, but that value is case-specific and does not choose a universal policy.

Messages

The selected source branch emits an explicit ERROR with primary column "%s" inherits conflicting default values and HINT To resolve the conflict, specify a default explicitly. %s is the conflicting column name. A client exception without the server SQLSTATE, primary, and HINT is not sufficient to identify this selected inherited-default subpath; other fixed producers can use the same SQLSTATE with different diagnostics.

Representative case

The page uses the same statements as the runner registry. Generated names such as syntax_schema and syntax_role are replaced by disposable runner values when executed.

CREATE TABLE syntax_schema.parent_one (id integer DEFAULT 1);
CREATE TABLE syntax_schema.parent_two (id integer DEFAULT 2);
CREATE TABLE syntax_schema.child_bad () INHERITS (syntax_schema.parent_one, syntax_schema.parent_two);
CREATE TABLE syntax_schema.child_good (id integer DEFAULT 1) INHERITS (syntax_schema.parent_one, syntax_schema.parent_two);
INSERT INTO syntax_schema.child_good DEFAULT VALUES RETURNING id;

The selected 18.6 run reports the structured diagnostic and passes the repair assertions; the 10.21 run passes the same case-specific checks. The downloadable case and evidence projections are 42611 case JSON and authored evidence. The runner manifest is verify/cases/42611/cases.json, and the page SQL is checked against its shared registry.

Versions

The selected natural runtime scope is PostgreSQL 18.6 and 10.21; it does not infer behavior for every intermediate release.

Sources

  • src.errcodes.18.6 — fixed errcodes.txt definition at commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.inherited-conflicting-default.18.6src/backend/commands/tablecmds.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9 (source).
  • src.inherited-conflicting-default.10.23src/backend/commands/tablecmds.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 6de441c88496c6cf57a836898388085ec08bf69afd70d07acdafd6089b9b5f8c (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.

168 - 42622 — name_too_long

PostgreSQL SQLSTATE 42622: name_too_long, source-backed diagnosis and recovery guidance.

42622

At a glance

SQLSTATE 42622 is name_too_long in Class 42. 42622 is name_too_long. Fixed source paths include a scanner NOTICE for an overlong SQL identifier and a binary name receive ERROR; ordinary text input can truncate without either diagnostic.

Field Value
SQLSTATE 42622
Condition name_too_long
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NAME_TOO_LONG
Aliases

Meaning

42622 is name_too_long with more than one producer. The binary name receive function namerecv reads external text with pq_getmsgtext, compares the byte count with NAMEDATALEN, and raises ERROR identifier too long with a length DETAIL before copying the value. The parser’s truncate_identifier path handles an overlong SQL identifier differently: it clips to a multibyte boundary, then, when called with warn = true by the scanner, emits a NOTICE with SQLSTATE 42622 saying that the identifier will be truncated. Ordinary text input uses the separate namein path and can clip without that scanner NOTICE; it does not enter namerecv.

Diagnosis

First classify the boundary and severity. A binary type receive failure has the identifier too long primary and length DETAIL; a SQL identifier can produce a NOTICE with the original and truncated names; a text cast to name can silently truncate. Record the format code and type OID for binary input, or the exact SQL identifier and server NOTICE for scanner input. This batch deliberately has no selected natural runtime: a text cast to name truncates on the selected targets and would be false evidence for either source branch. The fixed guards do not make every long value or identifier an instance of the same observed path.

Response

Validate the relevant input boundary and keep long application values in text or another suitable type. If a binary client really sends an oversized name value, fix the encoder or application schema at that boundary; if the parser NOTICE is the problem, shorten or rename the SQL identifier and inspect the resulting catalog name. Do not manufacture this SQLSTATE with RAISE, turn silent text truncation into evidence, or relabel one severity/path as the other.

Messages

The fixed scanner branch emits an explicit NOTICE with SQLSTATE 42622. On REL_18_6 its raw primary template is identifier "%s" will be truncated to "%.*s"; on REL_10_23 it is identifier "%s" will be truncated to "%s". The fixed namerecv branch emits an explicit ERROR with primary identifier too long and DETAIL Identifier must be less than %d characters.; %d is NAMEDATALEN in that source path. Both are source-confirmed only here, and the text-input path can be silent. A client exception or notice without the server SQLSTATE and the relevant scanner/binary context is not sufficient to identify a 42622 path.

Representative case

This page has no selected natural SQL run. The fixed source boundary is recorded without a synthetic trigger.

Versions

No natural SQL run is selected here. The fixed REL_18_6/REL_10_23 source boundary does not establish behavior for every intermediate release.

Sources

  • src.errcodes.18.6 — fixed errcodes.txt definition at commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.name-recv-too-long.18.6src/backend/utils/adt/name.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 4c4b4dc71f55ba73dbc24dd94b3385986fdb3179702b3d100cbad7ab00db7762 (source).
  • src.name-recv-too-long.10.23src/backend/utils/adt/name.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 7c7da791e528aafdbf26930cd4bd34386806818c19d2ee4b78bbe138b93f4a84 (source).
  • src.identifier-truncate.18.6 / src.identifier-truncate.10.23 — fixed parser truncate_identifier NOTICE branches; blob SHA-256 99cc6839927c19a9f85a1e5fbc8e848b376a7073477a04a0bbfe106ecdb2273f / 3c59a33f3cb5eaa0c3932859eb15e927f459a5feb5f40ca96fef5ef74495d67c (18.6 source, 10.23 source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.

169 - 42701 — duplicate_column

PostgreSQL SQLSTATE 42701: duplicate_column, source-backed diagnosis and recovery guidance.

42701

At a glance

SQLSTATE 42701 is duplicate_column in Class 42. 42701 is duplicate_column. The selected CREATE TABLE path lists id twice and reports column "%s" specified more than once before a repaired table with distinct columns is created.

Field Value
SQLSTATE 42701
Condition duplicate_column
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DUPLICATE_COLUMN
Aliases

Meaning

42701 is duplicate_column. While processing a table definition, PostgreSQL compares the local ColumnDef names before merging inherited attributes. Listing the same name twice in one definition therefore reports ERROR column "%s" specified more than once before any repaired table is created. This local-name check is separate from inherited default, type, or collation conflicts, which can use other SQLSTATEs.

Diagnosis

Inspect the generated column list after expansion, including quoted identifiers and migration fragments that are concatenated into one CREATE TABLE. PostgreSQL compares the identifier spelling after normal name processing, so an accidental repeated unquoted name is still one column name. The selected DDL ERROR leaves the autocommit session IDLE; inside an explicit BEGIN, the same error leaves the transaction INERROR until ROLLBACK or a suitable savepoint rollback before retrying. Distinguish this local duplicate-name branch from 42611’s inherited-default conflict and from type/collation errors while merging inherited columns.

Response

Remove the repeated definition or give it an intentional distinct name, rerun the complete DDL, and inspect the resulting catalog. If the duplicate came from a migration that already ran, compare the existing table definition before choosing ALTER TABLE versus a new CREATE TABLE; do not assume a failed CREATE TABLE partially created the relation. The selected repair creates id and payload and confirms two columns.

Messages

The selected tablecmds.c branch emits an explicit ERROR with primary column "%s" specified more than once; %s is the repeated column name. This message is about duplicate local column definitions, while neighboring source branches can report different SQLSTATEs for inherited type/collation conflicts. A client exception without the server SQLSTATE and primary is not sufficient to claim 42701.

Representative case

The page uses the same statements as the runner registry. Generated names such as syntax_schema and syntax_role are replaced by disposable runner values when executed.

CREATE TABLE syntax_schema.duplicate_table (id integer, id text);
CREATE TABLE syntax_schema.repaired_table (id integer, payload text);
SELECT count(*) FROM information_schema.columns WHERE table_schema = 'syntax_schema_name' AND table_name = 'repaired_table_name';

The selected 18.6 run reports the structured diagnostic and passes the repair assertions; the 10.21 run passes the same case-specific checks. The downloadable case and evidence projections are 42701 case JSON and authored evidence. The runner manifest is verify/cases/42701/cases.json, and the page SQL is checked against its shared registry.

Versions

The selected natural runtime scope is PostgreSQL 18.6 and 10.21; it does not infer behavior for every intermediate release.

Sources

  • src.errcodes.18.6 — fixed errcodes.txt definition at commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.duplicate-column.18.6src/backend/commands/tablecmds.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9 (source).
  • src.duplicate-column.10.23src/backend/commands/tablecmds.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 6de441c88496c6cf57a836898388085ec08bf69afd70d07acdafd6089b9b5f8c (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.

170 - 42702 — ambiguous_column

PostgreSQL SQLSTATE 42702: ambiguous_column, source-backed diagnosis and recovery guidance.

42702

At a glance

SQLSTATE 42702 is ambiguous_column in Class 42. 42702 is ambiguous_column. The selected join exposes id from two real tables and an unqualified SELECT id reports column reference "%s" is ambiguous.

Field Value
SQLSTATE 42702
Condition ambiguous_column
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_AMBIGUOUS_COLUMN
Aliases

Meaning

42702 is ambiguous_column. In colNameToVar, PostgreSQL scans the visible namespace for an unqualified name. Once two visible range-table entries produce a match in the same lookup, the parser raises ERROR column reference "%s" is ambiguous; the selected join exposes id from both real tables. The branch is about name resolution, before execution or row values can disambiguate it.

Diagnosis

Inspect aliases, CTEs, join inputs, lateral visibility, and every relation contributing the name in the current query scope. An unqualified name can be ambiguous even when the two columns contain the same value; PostgreSQL must resolve the source before executing the query. This is parse-time name resolution, so the selected autocommit session remains IDLE; it is distinct from 42703 where no matching column exists. An explicit transaction still follows the usual statement-ERROR transaction-state rule.

Response

Qualify the intended column with a stable table alias (or remove the unintended relation from the scope), then verify the returned row. Do not solve the ambiguity by relying on join order or equal values. If generated SQL introduces aliases or CTEs, make the qualification part of the query-builder contract and test the selected source column.

Messages

The selected parse_relation.c branch emits an explicit ERROR with primary column reference "%s" is ambiguous; %s is the unresolved column name and parser position is contextual. A client exception without the server SQLSTATE and primary is not sufficient to claim 42702.

Representative case

The page uses the same statements as the runner registry. Generated names such as syntax_schema and syntax_role are replaced by disposable runner values when executed.

CREATE TABLE syntax_schema.left_table (id integer);
CREATE TABLE syntax_schema.right_table (id integer);
INSERT INTO syntax_schema.left_table VALUES (1);
INSERT INTO syntax_schema.right_table VALUES (1);
SELECT id FROM syntax_schema.left_table, syntax_schema.right_table;
SELECT syntax_schema.left_table.id FROM syntax_schema.left_table, syntax_schema.right_table;

The selected 18.6 run reports the structured diagnostic and passes the repair assertions; the 10.21 run passes the same case-specific checks. The downloadable case and evidence projections are 42702 case JSON and authored evidence. The runner manifest is verify/cases/42702/cases.json, and the page SQL is checked against its shared registry.

Versions

The selected natural runtime scope is PostgreSQL 18.6 and 10.21; it does not infer behavior for every intermediate release.

Sources

  • src.errcodes.18.6 — fixed errcodes.txt definition at commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.ambiguous-column.18.6src/backend/parser/parse_relation.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 0d9c88f4a8def4c2d982c33f13208590e21ecf5e6f8cd9d7faa223dc771c9a9a (source).
  • src.ambiguous-column.10.23src/backend/parser/parse_relation.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 a34f40fc93fa5df0015fe5af5ee7761ccba2d16a791cda69ae07848ed27616b5 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.

171 - 42703 — undefined_column

PostgreSQL SQLSTATE 42703: undefined_column, source-backed diagnosis and recovery guidance.

42703

At a glance

SQLSTATE 42703 is undefined_column in Class 42. 42703 is undefined_column. The selected query names missing_column on a real table and reports column "%s" does not exist; selecting the defined id then succeeds.

Field Value
SQLSTATE 42703
Condition undefined_column
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_UNDEFINED_COLUMN
Aliases

Meaning

42703 is undefined_column. When a relation has been found but a referenced column is absent from the visible query scope, errorMissingColumn searches the range table for useful suggestions and raises ERROR column "%s" does not exist (or a qualified form when the relation was named). The selected query names missing_column on a real table and succeeds after changing to its defined id column.

Diagnosis

Check the exact relation, alias, search scope, quoted spelling/case, and migration version. If the parser finds a close candidate it may add a HINT, but the selected path has no hint. The parser reports the error before execution and leaves the autocommit session IDLE; inside an explicit BEGIN, it leaves the transaction INERROR until ROLLBACK or a suitable savepoint rollback before retrying. Distinguish a missing column from 42P01 (the unqualified relation is absent), 3F000 (the schema/creation namespace is absent), and 42702 (more than one visible column matches).

Response

Correct the column or migration and rerun against the intended relation. If the application supports multiple schemas or versions, qualify the relation and deploy the matching migration before retrying. A quoted identifier with different case is a different name; use the catalog or an introspection query to confirm the deployed spelling before changing application SQL.

Messages

The selected errorMissingColumn branch emits an explicit ERROR with primary column "%s" does not exist; %s is the unresolved column, and other source branches may add a suggestion HINT or use a qualified relation form. A client exception without the server SQLSTATE and primary is not sufficient to claim 42703.

Representative case

The page uses the same statements as the runner registry. Generated names such as syntax_schema and syntax_role are replaced by disposable runner values when executed.

CREATE TABLE syntax_schema.column_table (id integer);
INSERT INTO syntax_schema.column_table VALUES (1);
SELECT missing_column FROM syntax_schema.column_table;
SELECT id FROM syntax_schema.column_table;

The selected 18.6 run reports the structured diagnostic and passes the repair assertions; the 10.21 run passes the same case-specific checks. The downloadable case and evidence projections are 42703 case JSON and authored evidence. The runner manifest is verify/cases/42703/cases.json, and the page SQL is checked against its shared registry.

Versions

The selected natural runtime scope is PostgreSQL 18.6 and 10.21; it does not infer behavior for every intermediate release.

Sources

  • src.errcodes.18.6 — fixed errcodes.txt definition at commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.undefined-column.18.6src/backend/parser/parse_relation.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 0d9c88f4a8def4c2d982c33f13208590e21ecf5e6f8cd9d7faa223dc771c9a9a (source).
  • src.undefined-column.10.23src/backend/parser/parse_relation.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 a34f40fc93fa5df0015fe5af5ee7761ccba2d16a791cda69ae07848ed27616b5 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.

172 - 42704 — undefined_object

PostgreSQL SQLSTATE 42704: undefined_object, source-backed diagnosis and recovery guidance.

42704

At a glance

SQLSTATE 42704 is undefined_object in Class 42. 42704 is undefined_object. The selected DROP TRIGGER path names a trigger absent from a real table and reports trigger "%s" for table "%s" does not exist; a real trigger can then be created and dropped.

Field Value
SQLSTATE 42704
Condition undefined_object
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_UNDEFINED_OBJECT
Aliases

Meaning

42704 is undefined_object. The object kind determines the lookup and the message: fixed branches include type "%s" does not exist after type-name resolution, role "%s" does not exist when a role lookup misses, constraint "%s" for table "%s" does not exist after scanning constraints for a relation OID, and operator class "%s" does not exist for access method "%s" after resolving a qualified or search-path opclass. The selected path is narrower: get_trigger_oid scans pg_trigger for the resolved relation OID and trigger name; when DROP TRIGGER requires an object and no row matches, it raises trigger "%s" for table "%s" does not exist, then the case creates and drops a real trigger as its repair lifecycle.

Diagnosis

Classify the primary before changing anything. For the selected trigger branch, inspect the schema-qualified relation resolved by the DDL, exact trigger name (including quoted case), and migration order; a trigger can exist on another table while remaining absent from this relation because the source lookup is keyed by relation OID and name. For a type or role message, inspect the exact qualified name and the type/role catalog; for a constraint message, inspect the relation OID/name pair and migration order; for an opclass message, inspect the access method and schema/search_path used by the opclass lookup. A missing schema or unqualified relation is a different namespace/undefined-relation diagnosis, and a privilege failure is 42501. The missing-object ERROR leaves the selected autocommit session IDLE; inside an explicit BEGIN, it leaves the transaction INERROR until ROLLBACK or a suitable savepoint rollback. Distinguish it from 08003, which concerns a dblink handle, and 26000, which concerns a prepared statement name.

Response

Repair the object category named by the message: correct the qualified name or search path, apply the prerequisite migration in dependency order, or create/rename the intended type, role, constraint, or operator class under its owning migration. For the selected trigger case only, operate on the intended relation explicitly, check owner, timing/event, row-level versus statement-level definition, and function, and then drop that exact trigger when the migration requires it. If an object is intentionally optional, choose an idempotent migration policy deliberately; do not use CASCADE, an unrelated object, or a generic create-then-drop sequence as a repair. After an explicit-transaction error, roll back the transaction or a suitable savepoint before retrying.

Messages

The selected get_trigger_oid branch emits an explicit ERROR with primary trigger "%s" for table "%s" does not exist; both trigger and table names are dynamic. Other fixed undefined-object branches emit type "%s" does not exist, role "%s" does not exist, constraint "%s" for table "%s" does not exist, or operator class "%s" does not exist for access method "%s". A client exception without the server SQLSTATE and the primary for its object category is not sufficient to identify 42704.

Representative case

The page uses the same statements as the runner registry. Generated names such as syntax_schema and syntax_role are replaced by disposable runner values when executed.

CREATE TABLE syntax_schema.trigger_table (id integer);
DROP TRIGGER missing_trigger ON syntax_schema.trigger_table;
CREATE FUNCTION syntax_schema.trigger_function() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN RETURN NEW; END $$;
CREATE TRIGGER valid_trigger BEFORE INSERT ON syntax_schema.trigger_table FOR EACH ROW EXECUTE PROCEDURE syntax_schema.trigger_function();
DROP TRIGGER valid_trigger ON syntax_schema.trigger_table;
SELECT count(*) FROM pg_trigger WHERE tgrelid = 'syntax_schema.trigger_table'::regclass AND NOT tgisinternal;

The selected 18.6 run reports the structured diagnostic and passes the repair assertions; the 10.21 run passes the same case-specific checks. The downloadable case and evidence projections are 42704 case JSON and authored evidence. The runner manifest is verify/cases/42704/cases.json, and the page SQL is checked against its shared registry.

Versions

The selected natural runtime scope is PostgreSQL 18.6 and 10.21; it does not infer behavior for every intermediate release.

Sources

  • src.errcodes.18.6 — fixed errcodes.txt definition at commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.missing-trigger.18.6src/backend/commands/trigger.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 0a539af85b0de1a04779f92202e7bfc77d85ae6da1747ea32527c67f39084fbd (source).
  • src.missing-trigger.10.23src/backend/commands/trigger.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 dac7cdcbe2df1a1bbc77daa23e808b0c81ba8891c9895f10e8b270a15316e225 (source).
  • src.undefined-type.18.6 / src.undefined-type.10.23 — fixed type-name lookup branches; blob SHA-256 fe4670d2401141761096077c6495dd1b7d6a0baf33c9b903f25baee2f88ffd1e / 729d30e50cea059ccfe13491fdc5f997ff98c227795693bf166a163925beb663 (18.6 source, 10.23 source).
  • src.undefined-role.18.6 / src.undefined-role.10.23 — fixed DROP ROLE lookup branches; blob SHA-256 aa8769a2577fff287301d6c82169262cca328515ae940d5a2be4b3e8c21617ed / 9fc68a5a18c4bb5388cc817d2f3f2fcdc64f2752eaa429f78f54b0b443fb59ec (18.6 source, 10.23 source).
  • src.undefined-constraint.18.6 / src.undefined-constraint.10.23 — fixed relation-constraint lookup branches; blob SHA-256 0aa324acd355da955f8eb6cec17f1a0138277a8bebd2c6e999cd2a603d3bfa01 / c90dff2d1d863e6b43102d762cec6e08b6c4ba40458045b525a14b49865d8a65 (18.6 source, 10.23 source).
  • src.undefined-opclass.18.6 / src.undefined-opclass.10.23 — fixed access-method/opclass lookup branches; blob SHA-256 f28ac0580c805553724dc623dd4e20f32de1a84db637e6ac3c6e3d296bd2fae5 / 85c646706908d13dc449bcffa6690d6ead8d326498051fef6b08f817347fa947 (18.6 source, 10.23 source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.

173 - 42710 — Duplicate object

PostgreSQL SQLSTATE 42710: Duplicate object (duplicate_object), source-backed diagnosis and recovery guidance.

42710 — Duplicate object

At a glance

42710 is duplicate_object: a definition collides with an occupied object name. The selected path is a second CREATE TYPE ... AS ENUM; the same SQLSTATE is reused by other object-definition paths, so first identify the object kind and schema.

Field Value
SQLSTATE 42710
Condition duplicate_object
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DUPLICATE_OBJECT
Aliases

Meaning

The DefineEnum path reports type "%s" already exists; this is a catalog-definition collision, not a row-level unique violation. CREATE OR REPLACE is not a universal repair. Inspect pg_type joined to pg_namespace, ownership, and migration order. The selected autocommit error leaves IDLE; an explicit transaction must be rolled back before more commands.

Diagnosis

Inspect the exact object kind and schema first. For a type, query pg_type joined to pg_namespace; for a relation use to_regclass, and for a routine inspect pg_proc and pg_get_function_identity_arguments. Check ownership and migration order.

Response

Choose an intentionally free name, or use an object-specific alter/replace operation only when the existing owner is yours. The case repairs by creating a distinct ENUM. A preflight check does not remove a concurrent-create race, and dropping an unknown object is unsafe. In an explicit transaction, the failed definition leaves INERROR; roll back or return to a suitable savepoint before retrying. The selected autocommit case remains IDLE.

Observed diagnostics

CREATE TYPE in this ENUM branch has explicit ERROR severity and no hint; other 42710 branches have different templates, including a heap.c relation/type hint that does not belong here.

Representative case

This disposable case creates an ENUM, repeats its definition, checks the code and state, then creates a distinct type and verifies both catalog entries.

CREATE TYPE syntax_schema.duplicate_object_type AS ENUM ('first');
CREATE TYPE syntax_schema.duplicate_object_type AS ENUM ('first');
CREATE TYPE syntax_schema.duplicate_object_type_repaired AS ENUM ('first');
SELECT count(*) FROM pg_type t JOIN pg_namespace n ON n.oid = t.typnamespace WHERE n.nspname = 'syntax_schema_name' AND t.typname IN ('duplicate_object_type', 'duplicate_object_type_repaired');

The selected 18.6 and 10.21 runs passed SQLSTATE, severity, state/recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence; private manifest and registry hashes are recorded there.

Versions

The locked catalogue contains this condition from the 7.4 presence bound through the listed snapshots. The selected natural case passed on PostgreSQL 18.6 and 10.21; that bounded result does not infer every intermediate release or every source branch.

Sources

  • src.errcodes.REL_18_6 — fixed definition at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.duplicate-enum.18.6src/backend/commands/typecmds.c lines 1219–1221 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 60d1e9754646e100f6b74aa367ad8c2c52386c400df721707423d329209c47eb (source).
  • src.duplicate-enum.10.23src/backend/commands/typecmds.c lines 1139–1141 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 fa1dfb766f7a3117eb677461ede774d5ba7c25324cbbd2a200435fa9c9c8e863 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.42710 / snippet-registry.42710 — hashes are recorded in evidence/42710.json and each runtime record.

174 - 42712 — Duplicate alias

PostgreSQL SQLSTATE 42712: Duplicate alias (duplicate_alias), source-backed diagnosis and recovery guidance.

42712 — Duplicate alias

At a glance

42712 is duplicate_alias: a query namespace assigns the same table alias more than once. The parser rejects two VALUES range-table entries named duplicate_alias.

Field Value
SQLSTATE 42712
Condition duplicate_alias
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DUPLICATE_ALIAS
Aliases

Meaning

Aliases are query names, so the second range-table entry is ambiguous before execution. This differs from a duplicate physical object (42710) and from repeated output column labels. Inspect every FROM/JOIN/CTE/subquery alias. The selected autocommit error leaves IDLE.

Diagnosis

Inspect every FROM, JOIN, CTE, and subquery alias, including aliases introduced by generated SQL. The duplicate is in the current query namespace, so search_path or renaming a base table is not the diagnosis.

Response

Give each range-table entry a distinct alias and qualify references. Renaming a base table or changing search_path does not repair the current query. In an explicit transaction, the failed parse leaves INERROR; roll back or return to a suitable savepoint before retrying. The selected autocommit path returns to IDLE.

Observed diagnostics

The fixed parser group is explicit ERROR with primary table name "%s" specified more than once and no detail or hint.

Representative case

The case uses two one-row VALUES relations with the same alias, then left_alias and right_alias, asserting both values.

SELECT * FROM (VALUES (1)) AS duplicate_alias(value), (VALUES (2)) AS duplicate_alias(value);
SELECT left_alias.value, right_alias.value FROM (VALUES (1)) AS left_alias(value), (VALUES (2)) AS right_alias(value);

The selected 18.6 and 10.21 runs passed SQLSTATE, severity, state/recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence; private manifest and registry hashes are recorded there.

Versions

The locked catalogue contains this condition from the 7.4 presence bound through the listed snapshots. The selected natural case passed on PostgreSQL 18.6 and 10.21; that bounded result does not infer every intermediate release or every source branch.

Sources

  • src.errcodes.REL_18_6 — fixed definition at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.duplicate-alias.18.6src/backend/parser/parse_relation.c lines 471–474 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 0d9c88f4a8def4c2d982c33f13208590e21ecf5e6f8cd9d7faa223dc771c9a9a (source).
  • src.duplicate-alias.10.23src/backend/parser/parse_relation.c lines 417–420 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 a34f40fc93fa5df0015fe5af5ee7761ccba2d16a791cda69ae07848ed27616b5 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.42712 / snippet-registry.42712 — hashes are recorded in evidence/42712.json and each runtime record.

175 - 42723 — Duplicate function

PostgreSQL SQLSTATE 42723: Duplicate function (duplicate_function), source-backed diagnosis and recovery guidance.

42723 — Duplicate function

At a glance

42723 is duplicate_function: a function definition repeats the same schema, name, and input argument types. Output types do not create another overload.

Field Value
SQLSTATE 42723
Condition duplicate_function
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DUPLICATE_FUNCTION
Aliases

Meaning

The fixed catalog path reports function "%s" already exists with same argument types. Inspect pg_proc, pg_get_function_identity_arguments, and the result contract. This is a definition collision, unlike 42725, which occurs when call resolution has multiple candidates; the selected autocommit error leaves IDLE.

Diagnosis

Inspect pg_proc with pg_get_function_identity_arguments and make the schema explicit. Decide whether the migration intends a new input signature or replacement of an owned function; output types do not disambiguate identity.

Response

Use a new input signature for a genuinely different API. Use CREATE OR REPLACE FUNCTION only when replacing the owned function is intentional and its return contract stays compatible; it is not a safe input-type migration. In an explicit transaction, the duplicate definition leaves INERROR; roll back or return to a suitable savepoint before retrying. The selected autocommit path returns to IDLE.

Observed diagnostics

The pg_proc.c group is explicit ERROR with the fixed primary template and no detail or hint.

Representative case

The runner creates duplicate_function(integer), repeats that signature, then deliberately uses CREATE OR REPLACE and verifies the result 2.

CREATE FUNCTION syntax_schema.duplicate_function(integer) RETURNS integer LANGUAGE SQL AS 'SELECT $1';
CREATE FUNCTION syntax_schema.duplicate_function(integer) RETURNS integer LANGUAGE SQL AS 'SELECT $1';
CREATE OR REPLACE FUNCTION syntax_schema.duplicate_function(integer) RETURNS integer LANGUAGE SQL AS 'SELECT $1 + 1';
SELECT syntax_schema.duplicate_function(1);

The selected 18.6 and 10.21 runs passed SQLSTATE, severity, state/recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence; private manifest and registry hashes are recorded there.

Versions

The locked catalogue contains this condition from the 7.4 presence bound through the listed snapshots. The selected natural case passed on PostgreSQL 18.6 and 10.21; that bounded result does not infer every intermediate release or every source branch.

Sources

  • src.errcodes.REL_18_6 — fixed definition at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.duplicate-function.18.6src/backend/catalog/pg_proc.c lines 400–403 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 77a883995e5fadf17fae68722043beb43115e685e8082b2b7256d92312528a5a (source).
  • src.duplicate-function.10.23src/backend/catalog/pg_proc.c lines 398–401 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 96ddd186536c24018d3e29fd7e8f7384543c89ede83c81f673dc013fdd23b0fe (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.42723 / snippet-registry.42723 — hashes are recorded in evidence/42723.json and each runtime record.

176 - 42725 — Ambiguous function

PostgreSQL SQLSTATE 42725: Ambiguous function (ambiguous_function), source-backed diagnosis and recovery guidance.

42725 — Ambiguous function

At a glance

42725 is ambiguous_function: lookup found multiple viable candidates but no best one. The case defines uuid and jsonb overloads and passes an unknown string literal.

Field Value
SQLSTATE 42725
Condition ambiguous_function
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_AMBIGUOUS_FUNCTION
Aliases

Meaning

Overload resolution considers literal type, casts, schema visibility, and signatures. With an unknown literal both candidates remain viable, so the parser reports function %s is not unique; this differs from 42723 (definition collision) and 42883 (no candidate). Inspect visible pg_proc rows and argument types.

Diagnosis

List visible candidates in pg_proc, including their identity arguments and input types, and inspect the inferred type of each literal. Schema qualification narrows visibility but does not choose between overloads.

Response

Cast to the type that matches the business meaning or remove an unintended overload. ::uuid selects the UUID overload here. Do not add casts merely to silence an error: they can change validation and overload behavior. In an explicit transaction, the ambiguity leaves INERROR; roll back or return to a suitable savepoint before retrying. The selected autocommit session remains IDLE.

Observed diagnostics

The fixed parser group is explicit ERROR: function %s is not unique, with the hint Could not choose a best candidate function. You might need to add explicit type casts.

Representative case

The registry creates both overloads, triggers with the unknown literal, then repeats the call with an explicit UUID cast and asserts the result.

CREATE FUNCTION syntax_schema.ambiguous_function(uuid) RETURNS text LANGUAGE SQL AS 'SELECT ''uuid''';
CREATE FUNCTION syntax_schema.ambiguous_function(jsonb) RETURNS text LANGUAGE SQL AS 'SELECT ''jsonb''';
SELECT syntax_schema.ambiguous_function('123e4567-e89b-12d3-a456-426614174000');
SELECT syntax_schema.ambiguous_function('123e4567-e89b-12d3-a456-426614174000'::uuid);

The selected 18.6 and 10.21 runs passed SQLSTATE, severity, state/recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence; private manifest and registry hashes are recorded there.

Versions

The locked catalogue contains this condition from the 7.4 presence bound through the listed snapshots. The selected natural case passed on PostgreSQL 18.6 and 10.21; that bounded result does not infer every intermediate release or every source branch.

Sources

  • src.errcodes.REL_18_6 — fixed definition at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.ambiguous-function.18.6src/backend/parser/parse_func.c lines 570–577 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 48314eab022297478ac4e49786afaff2621ab7b1d7b50e156668cf477961384f (source).
  • src.ambiguous-function.10.23src/backend/parser/parse_func.c lines 499–506 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 f1b4af88565ca01dbad2b244cd26b42f34764b3f1343b22a9231e271fb0742f2 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.42725 / snippet-registry.42725 — hashes are recorded in evidence/42725.json and each runtime record.

177 - 42803 — Grouping error

PostgreSQL SQLSTATE 42803: Grouping error (grouping_error), source-backed diagnosis and recovery guidance.

42803 — Grouping error

At a glance

42803 is grouping_error: a grouped query projects a value that is neither grouped nor aggregated. The case groups category while selecting label.

Field Value
SQLSTATE 42803
Condition grouping_error
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_GROUPING_ERROR
Aliases

Meaning

The analyzer must assign one value to each selected expression per group. The fixed message is column "%s.%s" must appear in the GROUP BY clause or be used in an aggregate function. PostgreSQL can allow an otherwise ungrouped column when the inspected relation is proven functionally dependent on the grouping columns; the fixed check_functional_grouping path requires the GROUP BY columns to contain every column of that table’s primary key, so this is not a blanket exception for any unique-looking expression. The selected VALUES relation has no such table constraint. Adding label therefore deliberately changes the report grain from one row per category to one row per (category,label), rather than being a semantics-neutral repair. The selected autocommit error leaves IDLE.

Diagnosis

Check every nonaggregate expression in SELECT, HAVING, and relevant ordering expressions. Inspect the relation’s constraints before relying on functional dependency, and decide whether the desired cardinality is one row per category or one row per category/label before editing GROUP BY. Ordered-set aggregate direct arguments have a separate grouped-column rule; the DETAIL for that branch is source-backed below, but it is not the selected ordinary query.

Response

Add the intended expression to GROUP BY or aggregate it with a deliberate rule, then check cardinality. The case repairs with GROUP BY category, label and returns two rows because the two labels are distinct groups. If the business result is one row per category, choose an aggregate or an explicit rule for which label to retain instead. In an explicit transaction, the failed statement leaves the transaction in INERROR; roll it back or use an appropriate savepoint before retrying. The selected autocommit path is the case that returns to IDLE.

Observed diagnostics

The fixed parse_agg.c group is explicit ERROR. The selected primary is column "%s.%s" must appear in the GROUP BY clause or be used in an aggregate function. When the ungrouped variable is an ordered-set aggregate’s direct argument, the same source branch adds the source-only DETAIL Direct arguments of an ordered-set aggregate must use only grouped columns.; that condition is guarded by context->in_agg_direct_args and was not produced by the selected ordinary grouped query.

Representative case

The registry uses two (category,label) values, triggers with only GROUP BY category, then repairs with GROUP BY category, label ORDER BY ... and asserts (1,a,1) and (1,b,1).

SELECT category, label, count(*) FROM (VALUES (1, 'a'), (1, 'b')) AS grouping_rows(category, label) GROUP BY category;
SELECT category, label, count(*) FROM (VALUES (1, 'a'), (1, 'b')) AS grouping_rows(category, label) GROUP BY category, label ORDER BY category, label;

The selected 18.6 and 10.21 runs passed SQLSTATE, severity, state/recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence; private manifest and registry hashes are recorded there.

Versions

The locked catalogue contains this condition from the 7.4 presence bound through the listed snapshots. The selected natural case passed on PostgreSQL 18.6 and 10.21; that bounded result does not infer every intermediate release or every source branch.

Sources

  • src.errcodes.REL_18_6 — fixed definition at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.grouping-error.18.6src/backend/parser/parse_agg.c lines 1552–1558 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 6e80a805fddbfc9c7e0f3047b348bf992a20c99f16ce7fee89c7067753027f72 (source).
  • src.grouping-error.10.23src/backend/parser/parse_agg.c lines 1356–1362 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 4c7e12bba2ffd465eb55d22c2adc593afa97e5a5f9a93045a882afab1401cb28 (source).
  • src.grouping-functional-dependency.18.6src/backend/catalog/pg_constraint.c lines 1728–1778 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 0aa324acd355da955f8eb6cec17f1a0138277a8bebd2c6e999cd2a603d3bfa01 (source).
  • src.grouping-functional-dependency.10.23src/backend/catalog/pg_constraint.c lines 1057–1107 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 c90dff2d1d863e6b43102d762cec6e08b6c4ba40458045b525a14b49865d8a65 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.42803 / snippet-registry.42803 — hashes are recorded in evidence/42803.json and each runtime record.

178 - 42804 — Datatype mismatch

PostgreSQL SQLSTATE 42804: Datatype mismatch (datatype_mismatch), source-backed diagnosis and recovery guidance.

42804 — Datatype mismatch

At a glance

42804 is datatype_mismatch: an expression or definition has a type different from its target context. The selected path rejects a text default for an integer column.

Field Value
SQLSTATE 42804
Condition datatype_mismatch
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DATATYPE_MISMATCH
Aliases

Meaning

The cookDefault path reports column "%s" is of type %s but default expression is of type %s, with a rewrite/cast hint. The same SQLSTATE also covers assignment coercion for INSERT/UPDATE targets (column "%s" is of type %s but expression is of type %s) and common-type selection in CASE/UNION (%s types %s and %s cannot be matched). This differs from 22P02 (the chosen type’s input parser rejects a value) and 42846 (a selected common target has no coercion path). Inspect pg_attribute.atttypid, pg_type, pg_get_expr, and the actual expression context; the failed autocommit CREATE leaves IDLE.

Diagnosis

Identify the target column or result type, then inspect pg_attribute.atttypid, pg_type, and pg_get_expr for stored defaults or generated expressions. For INSERT/UPDATE, compare the assigned expression’s type with the target column. For CASE/UNION, inspect every arm or input that participates in common-type selection. Read the expanded source and target types and the cursor position from the diagnostic before choosing a cast.

Response

Make the expression produce the target type or add a deliberate valid cast. For an assignment, fix the producer or cast it to the intended column type; for CASE/UNION, make the branches share an intended common type. Do not repair a 22P02 input failure by changing text and call that a type match, and do not treat a missing coercion path as 42804 when the source branch is 42846. The case uses DEFAULT 1, inserts DEFAULT VALUES, and reads back 1. In an explicit transaction, a failed definition or assignment leaves INERROR; roll back or use a suitable savepoint before retrying. The selected autocommit failure is the path that returns to IDLE.

Observed diagnostics

The fixed groups are explicit ERROR variants. The selected heap.c primary is column "%s" is of type %s but default expression is of type %s, with hint You will need to rewrite or cast the expression. The assignment path uses column "%s" is of type %s but expression is of type %s with the same hint. The common-type path uses %s types %s and %s cannot be matched for CASE/UNION-style contexts. A failed value input is 22P02; a later inability to coerce an expression to the selected common type is 42846.

Representative case

The registry first defines an integer column with an explicitly text default, then creates the matching definition, inserts a default row, and verifies it.

CREATE TABLE syntax_schema.mismatch_table (value integer DEFAULT 'x'::text);
CREATE TABLE syntax_schema.mismatch_table (value integer DEFAULT 1);
INSERT INTO syntax_schema.mismatch_table DEFAULT VALUES;
SELECT value FROM syntax_schema.mismatch_table;

The selected 18.6 and 10.21 runs passed SQLSTATE, severity, state/recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence; private manifest and registry hashes are recorded there.

Versions

The locked catalogue contains this condition from the 7.4 presence bound through the listed snapshots. The selected natural case passed on PostgreSQL 18.6 and 10.21; that bounded result does not infer every intermediate release or every source branch.

Sources

  • src.errcodes.REL_18_6 — fixed definition at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.datatype-default.18.6src/backend/catalog/heap.c lines 3413–3420 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 e720ee58279590793edd0985b3c910970ef56e7361b8ef92e245370587e02a0e (source).
  • src.datatype-default.10.23src/backend/catalog/heap.c lines 2679–2686 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 285e1e2f8024acb58497735bcbd8e605e7cfdd224e442becdee6a5b0e7ac7cf6 (source).
  • src.assignment-target.18.6src/backend/parser/parse_target.c lines 575–596 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 4f0cda351acc3e2854bf55514e69cf8b7de6ad82e1535045e4523581ca0d943c (source).
  • src.assignment-target.10.23src/backend/parser/parse_target.c lines 570–596 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 808bfadd7717d711bc71eb85b7ecd343c742ccc8f6f3087164ed20da098b6d7d (source).
  • src.common-type.18.6src/backend/parser/parse_coerce.c lines 1327–1425 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 6ac3ddab06edff28e9a694c64fb7f559315cf488bfa4392bc14c24e559f6bd2e (source).
  • src.common-type.10.23src/backend/parser/parse_coerce.c lines 1217–1311 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 ed778c872fe4f2b8742828795566c3eaa24e7af3ce747fbf844c374d673593d3 (source).
  • src.common-coerce.18.6src/backend/parser/parse_coerce.c lines 1564–1593 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 6ac3ddab06edff28e9a694c64fb7f559315cf488bfa4392bc14c24e559f6bd2e (source).
  • src.common-coerce.10.23src/backend/parser/parse_coerce.c lines 1349–1378 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 ed778c872fe4f2b8742828795566c3eaa24e7af3ce747fbf844c374d673593d3 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.42804 / snippet-registry.42804 — hashes are recorded in evidence/42804.json and each runtime record.

179 - 42809 — Wrong object type

PostgreSQL SQLSTATE 42809: Wrong object type (wrong_object_type), source-backed diagnosis and recovery guidance.

42809 — Wrong object type

At a glance

42809 is wrong_object_type: a command is valid in general but not for the selected object kind. The case tries a row-level BEFORE trigger on a view.

Field Value
SQLSTATE 42809
Condition wrong_object_type
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_WRONG_OBJECT_TYPE
Aliases

Meaning

The view-specific guard reports "%s" is a view, with DETAIL Views cannot have row-level BEFORE or AFTER triggers. Inspect pg_class.relkind, event, level, and timing. This is distinct from a missing relation and from a trigger-body error; the selected autocommit connection is IDLE after the failed definition.

Diagnosis

Inspect pg_class.relkind and the trigger event, level, and timing. Confirm whether the target is a view or table; a trigger-body error is a later stage and has a different diagnostic.

Response

Use the trigger form supported by the object: an INSTEAD OF row trigger on the view. If the business rule needs BEFORE/AFTER row timing, put it on a base table and keep view write semantics explicit. The selected run checks trigger definition success, not actual view DML behavior. In an explicit transaction, the rejected trigger definition leaves INERROR; roll back or return to a suitable savepoint before retrying. The selected autocommit path returns to IDLE.

Observed diagnostics

The source group is explicit ERROR with primary "%s" is a view and detail Views cannot have row-level BEFORE or AFTER triggers.

Representative case

The runner creates a view and function, attempts the forbidden trigger, then creates an INSTEAD OF trigger and verifies its catalog row.

CREATE VIEW syntax_schema.trigger_view AS SELECT 1 AS value;
CREATE FUNCTION syntax_schema.trigger_function() RETURNS trigger LANGUAGE plpgsql AS 'BEGIN RETURN NEW; END';
CREATE TRIGGER row_trigger BEFORE INSERT ON syntax_schema.trigger_view FOR EACH ROW EXECUTE PROCEDURE syntax_schema.trigger_function();
CREATE TRIGGER instead_trigger INSTEAD OF INSERT ON syntax_schema.trigger_view FOR EACH ROW EXECUTE PROCEDURE syntax_schema.trigger_function();
SELECT count(*) FROM pg_trigger t JOIN pg_class c ON c.oid = t.tgrelid JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = 'syntax_schema_name' AND c.relname = 'trigger_view' AND t.tgname = 'instead_trigger' AND NOT t.tgisinternal;

The selected 18.6 and 10.21 runs passed SQLSTATE, severity, state/recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence; private manifest and registry hashes are recorded there.

Versions

The locked catalogue contains this condition from the 7.4 presence bound through the listed snapshots. The selected natural case passed on PostgreSQL 18.6 and 10.21; that bounded result does not infer every intermediate release or every source branch.

Sources

  • src.errcodes.REL_18_6 — fixed definition at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.view-row-trigger.18.6src/backend/commands/trigger.c lines 274–278 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 0a539af85b0de1a04779f92202e7bfc77d85ae6da1747ea32527c67f39084fbd (source).
  • src.view-row-trigger.10.23src/backend/commands/trigger.c lines 208–212 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 dac7cdcbe2df1a1bbc77daa23e808b0c81ba8891c9895f10e8b270a15316e225 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.42809 / snippet-registry.42809 — hashes are recorded in evidence/42809.json and each runtime record.

180 - 42830 — Invalid foreign key

PostgreSQL SQLSTATE 42830: Invalid foreign key (invalid_foreign_key), source-backed diagnosis and recovery guidance.

42830 — Invalid foreign key

At a glance

42830 is invalid_foreign_key: an FK definition cannot find a qualifying unique key on referenced columns. The case references a parent integer column with no unique constraint.

Field Value
SQLSTATE 42830
Condition invalid_foreign_key
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_FOREIGN_KEY
Aliases

Meaning

Creation checks the parent key before any child row is inserted. The fixed primary is there is no unique constraint matching given keys for referenced table "%s". For an ordinary FK, the referenced column set may match an eligible unique index in a different physical order; the source matcher rejects duplicate referenced columns and requires the right count, uniqueness, validity, and no partial predicate or index expressions. A matching deferrable unique/primary index takes a separate source-only 55000 path. This is definition-time, unlike 23503, and the selected autocommit ALTER leaves IDLE.

Diagnosis

Compare the referenced column set with pg_constraint and pg_index. Check for duplicate references, the number of key columns, unique/primary status, validity, partial predicates, and expressions; physical index order need not equal the FK list order for the ordinary path. Also check indimmediate: a matching deferrable key is rejected with 55000, rather than the selected 42830. Matching data types alone do not make a referenced key eligible.

Response

Add or use an intentional non-deferrable unique key over the referenced column set, then create the FK. Check the business meaning of the parent table’s key and desired NULL/MATCH semantics; adding an overly broad unique constraint can change accepted data. Do not reorder a valid index merely to mirror the FK syntax, and do not mistake a partial or expression index for a qualifying key. The case adds UNIQUE (id) then creates one FK. In an explicit transaction, the rejected ALTER TABLE leaves INERROR; roll back or return to a suitable savepoint before retrying. The selected autocommit path returns to IDLE.

Observed diagnostics

The selected tablecmds.c group is explicit ERROR with primary there is no unique constraint matching given keys for referenced table "%s" and no detail or hint. The same matcher has a source-only 55000 (object_not_in_prerequisite_state) variant, cannot use a deferrable unique constraint for referenced table "%s", when the otherwise matching key is deferrable.

Representative case

The registry creates parent and child tables, attempts the FK, adds the parent unique key, creates the valid FK, and counts it.

CREATE TABLE syntax_schema.fk_parent (id integer);
CREATE TABLE syntax_schema.fk_child (parent_id integer);
ALTER TABLE syntax_schema.fk_child ADD CONSTRAINT fk_bad FOREIGN KEY (parent_id) REFERENCES syntax_schema.fk_parent (id);
ALTER TABLE syntax_schema.fk_parent ADD CONSTRAINT fk_parent_id_key UNIQUE (id);
ALTER TABLE syntax_schema.fk_child ADD CONSTRAINT fk_good FOREIGN KEY (parent_id) REFERENCES syntax_schema.fk_parent (id);
SELECT count(*) FROM pg_constraint c JOIN pg_namespace n ON n.oid = c.connamespace WHERE n.nspname = 'syntax_schema_name' AND c.conname = 'fk_good' AND c.contype = 'f';

The selected 18.6 and 10.21 runs passed SQLSTATE, severity, state/recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence; private manifest and registry hashes are recorded there.

Versions

The locked catalogue contains this condition from the 7.4 presence bound through the listed snapshots. The selected natural case passed on PostgreSQL 18.6 and 10.21; that bounded result does not infer every intermediate release or every source branch.

Sources

  • src.errcodes.REL_18_6 — fixed definition at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.invalid-fk.18.6src/backend/commands/tablecmds.c lines 13639–13642 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9 (source).
  • src.invalid-fk.10.23src/backend/commands/tablecmds.c lines 8133–8136 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 6de441c88496c6cf57a836898388085ec08bf69afd70d07acdafd6089b9b5f8c (source).
  • src.invalid-fk-guards.18.6 — complete transformFkeyCheckAttrs in src/backend/commands/tablecmds.c lines 13505–13642 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9 (source).
  • src.invalid-fk-guards.10.23 — complete transformFkeyCheckAttrs in src/backend/commands/tablecmds.c lines 8002–8136 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 6de441c88496c6cf57a836898388085ec08bf69afd70d07acdafd6089b9b5f8c (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.42830 / snippet-registry.42830 — hashes are recorded in evidence/42830.json and each runtime record.

181 - 42846 — Cannot coerce

PostgreSQL SQLSTATE 42846: Cannot coerce (cannot_coerce), source-backed diagnosis and recovery guidance.

42846 — Cannot coerce

At a glance

42846 is cannot_coerce: no applicable cast connects the source and target types. The selected expression asks for integer to date.

Field Value
SQLSTATE 42846
Condition cannot_coerce
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_CANNOT_COERCE
Aliases

Meaning

The fixed primary is cannot cast type %s to %s. It is not 22P02 (a bad value for a valid cast) or 42804 (an expression type mismatch in a target context). Inspect pg_cast and the expression context; the selected autocommit connection remains IDLE after the impossible cast.

Diagnosis

Read both source and target types from the diagnostic and inspect pg_cast and the expression context. Confirm whether the application needs a typed literal or a documented conversion function.

Response

Construct a value in the target type or use a documented conversion function. The case uses DATE '2026-01-01'; it does not invent an integer-to-date business mapping or hide input errors with NULLIF. In an explicit transaction, the failed cast leaves INERROR; roll back or return to a suitable savepoint before retrying. The selected autocommit path returns to IDLE.

Observed diagnostics

The selected parse_expr.c group is explicit ERROR with primary cannot cast type %s to %s and no detail or hint.

Representative case

The registry evaluates SELECT 1::integer::date, then a date-typed literal and asserts the exact returned date.

SELECT 1::integer::date;
SELECT DATE '2026-01-01';

The selected 18.6 and 10.21 runs passed SQLSTATE, severity, state/recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence; private manifest and registry hashes are recorded there.

Versions

The locked catalogue contains this condition from the 7.4 presence bound through the listed snapshots. The selected natural case passed on PostgreSQL 18.6 and 10.21; that bounded result does not infer every intermediate release or every source branch.

Sources

  • src.errcodes.REL_18_6 — fixed definition at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.cannot-coerce.18.6src/backend/parser/parse_expr.c lines 2782–2787 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 63c37770872a08978f931c31f801666a08e3bc8e51c2c65ff60151a1d139d55b (source).
  • src.cannot-coerce.10.23src/backend/parser/parse_expr.c lines 2739–2744 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 2700ba4a37d0715b66be76c900c7da7cf6a4d818eb71178e7b9a51e48e59e136 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.42846 / snippet-registry.42846 — hashes are recorded in evidence/42846.json and each runtime record.

182 - 42883 — Undefined function

PostgreSQL SQLSTATE 42883: Undefined function (undefined_function), source-backed diagnosis and recovery guidance.

42883 — Undefined function

At a glance

42883 is undefined_function: lookup found no compatible function for the requested name and input types. The same condition is also used by the parser’s undefined-operator branch. The case calls a schema-qualified integer function signature before it exists.

Field Value
SQLSTATE 42883
Condition undefined_function
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_UNDEFINED_FUNCTION
Aliases

Meaning

The parser resolves name, schema visibility, input types, and overloads together. The selected function group reports function %s does not exist and hints that no function matches the name and argument types; a sibling parse_oper.c branch reports operator does not exist: %s with the corresponding operator hint under the same SQLSTATE. Distinguish 42725 (candidates but ambiguous) and 42846 (a chosen expression cannot be cast). Inspect pg_proc/identity arguments for functions and pg_operator plus operand types for operators. An extension-provided routine or operator may simply be unavailable on this server or version, so availability is part of the diagnosis.

Diagnosis

Capture the fully rendered name and signature. Query pg_proc with pg_get_function_identity_arguments for functions, and inspect pg_operator and both operand types for operators. Verify current_schema and search_path without assuming a different path is correct; check whether the object is a function, procedure, operator, or extension-provided feature. For extension/version candidates, inspect installed extension metadata and server_version_num before changing SQL.

Response

Call the intended signature explicitly, or create that exact function in the intended schema when you own the API. If the missing object is supplied by an extension or newer server feature, install or enable the intended dependency only when it is part of the deployment contract; do not create a substitute merely because the lookup failed. Do not blindly alter search_path or add casts, since they can select another routine or operator. The case creates missing_function(integer) and returns 42. In an explicit transaction, the error leaves INERROR until rollback or a suitable savepoint; the selected autocommit error leaves IDLE.

Observed diagnostics

The selected parser function group is explicit ERROR: primary function %s does not exist, hint No function matches the given name and argument types. You might need to add explicit type casts. The source-only operator group is also ERROR: primary operator does not exist: %s; with two known operand types its hint is No operator matches the given name and argument types. You might need to add explicit type casts., while a missing operand uses the singular type form. These are distinct producers sharing 42883.

Representative case

The runner calls the missing schema-qualified function, checks the expanded signature and state, creates the exact integer signature, and repeats the call.

SELECT syntax_schema.missing_function(41);
CREATE FUNCTION syntax_schema.missing_function(integer) RETURNS integer LANGUAGE SQL AS 'SELECT $1 + 1';
SELECT syntax_schema.missing_function(41);

The selected 18.6 and 10.21 runs passed SQLSTATE, severity, state/recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence; private manifest and registry hashes are recorded there.

Versions

The locked catalogue contains this condition from the 7.4 presence bound through the listed snapshots. The selected natural case passed on PostgreSQL 18.6 and 10.21; that bounded result does not infer every intermediate release or every source branch.

Sources

  • src.errcodes.REL_18_6 — fixed definition at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.undefined-function.18.6src/backend/parser/parse_func.c lines 629–636 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 48314eab022297478ac4e49786afaff2621ab7b1d7b50e156668cf477961384f (source).
  • src.undefined-function.10.23src/backend/parser/parse_func.c lines 521–528 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 f1b4af88565ca01dbad2b244cd26b42f34764b3f1343b22a9231e271fb0742f2 (source).
  • src.undefined-operator.18.6src/backend/parser/parse_oper.c lines 619–644 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 3866ce3302c2a4bd22d0f1d113a4bbc627278a618d5e7b83660e36240cbdd0a8 (source).
  • src.undefined-operator.10.23src/backend/parser/parse_oper.c lines 706–728 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 5802db6d55bdb41f9cad4957384fa2c2ddbb4dc902c33f5f57e8a07760761d10 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.42883 / snippet-registry.42883 — hashes are recorded in evidence/42883.json and each runtime record.

183 - 428C9 — Generated-always column assignment

PostgreSQL SQLSTATE 428C9: Generated-always column assignment (generated_always), source-backed diagnosis and recovery guidance.

428C9 — Generated-always column assignment

At a glance

428C9 (generated_always) is a rewrite-stage ERROR when an INSERT or UPDATE supplies a value where PostgreSQL must generate it or receive DEFAULT. Identity columns and generated columns follow different assignment rules, so the operation and column metadata matter.

Field Value
SQLSTATE 428C9
Condition generated_always
Status active
Known present by 10.0
Locked snapshots 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_GENERATED_ALWAYS
Aliases

Meaning

The rewriter computes apply_default for an omitted INSERT target or an explicit DEFAULT. For an identity column marked GENERATED ALWAYS, a non-default INSERT is rejected unless OVERRIDING SYSTEM VALUE is present; OVERRIDING USER VALUE instead forces the default. An identity column marked BY DEFAULT accepts a supplied value, but OVERRIDING USER VALUE still forces generation. Generated columns take only DEFAULT, regardless of an OVERRIDING clause. The INSERT branches identify the column in DETAIL, and the identity-always branch adds HINT Use OVERRIDING SYSTEM VALUE to override.

For UPDATE, the guard covers identity GENERATED ALWAYS and every generated column when a non-default target entry is present; UPDATE has no OVERRIDING escape. After the guard, a virtual generated column gets a null target entry and a stored generated column is filled by the executor. This storage behavior is part of the 18.6 source path and does not turn the catalogue’s 10.0 SQLSTATE lower bound into a claim that every generated-column feature existed in 10.0.

Diagnosis

Inspect pg_attribute.attidentity (a for ALWAYS, d for BY DEFAULT) and attgenerated (s for stored, v for virtual), then record whether the command is INSERT or UPDATE and whether the target entry is omitted, DEFAULT, or a value. For an INSERT from VALUES, confirm whether the offending row item is actually DEFAULT; the rewriter has a separate all-default check. Read the primary, DETAIL, and HINT together: identity-always and generated-column INSERTs share a primary template but have different DETAIL/HINT contracts.

Response

For identity GENERATED ALWAYS, omit the value, use DEFAULT, or use OVERRIDING SYSTEM VALUE only when the application deliberately owns the identity value. For identity BY DEFAULT, leave the value in place when that is the contract; use OVERRIDING USER VALUE when the server must generate it. Remove assignments to generated columns and do not try to bypass the guard with a cast. If the ERROR occurred inside an explicit transaction, roll back to a suitable savepoint or roll back the transaction before issuing the corrected statement; this page has no runtime observation of that recovery.

Messages

The selected 18.6 groups are explicit ERRORs:

Operation Primary DETAIL HINT
identity GENERATED ALWAYS INSERT cannot insert a non-DEFAULT value into column "%s" Column "%s" is an identity column defined as GENERATED ALWAYS. Use OVERRIDING SYSTEM VALUE to override.
generated-column INSERT cannot insert a non-DEFAULT value into column "%s" Column "%s" is a generated column. none
identity GENERATED ALWAYS UPDATE column "%s" can only be updated to DEFAULT Column "%s" is an identity column defined as GENERATED ALWAYS. none
generated-column UPDATE column "%s" can only be updated to DEFAULT Column "%s" is a generated column. none

The fixed source also distinguishes virtual generated storage (null target entry) from stored generated storage (executor fill). Each %s is dynamic; no concrete placeholder value or runtime result is claimed.

Versions

The catalogue records the condition by 10.0 and locks snapshots through 18.6 and 19beta3. That is a definition lower bound, not a claim that identity, stored-generated, and virtual-generated features all share that introduction point. The selected mechanism is PostgreSQL 18.6 source; runtime was not run.

Sources

  • src.errcodes.428C9.18.6src/backend/utils/errcodes.txt line 355, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).

  • src.call.428C9.353c4cc772b5ae9adad09c67src/backend/rewrite/rewriteHandler.c lines 942-948, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 5a34bf31f424abbf46cd926da1fefcd9360c4d527a87d8a0ac9f653d67c2206a (source).

  • src.call.428C9.47aaa60ecb1566d462ffaa86src/backend/rewrite/rewriteHandler.c lines 981-986, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 5a34bf31f424abbf46cd926da1fefcd9360c4d527a87d8a0ac9f653d67c2206a (source).

  • src.call.428C9.8585d423db2446a6222cbf57src/backend/rewrite/rewriteHandler.c lines 1008-1013, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 5a34bf31f424abbf46cd926da1fefcd9360c4d527a87d8a0ac9f653d67c2206a (source).

  • src.call.428C9.generated-updatesrc/backend/rewrite/rewriteHandler.c lines 1015-1030, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 5a34bf31f424abbf46cd926da1fefcd9360c4d527a87d8a0ac9f653d67c2206a (source).

  • src.calls.REL_18_6.428C9 — resolved core call groups; SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf.

  • authored evidence — source claims, message roles, and runtime boundary.

184 - 42939 — Reserved name

PostgreSQL SQLSTATE 42939: Reserved name (reserved_name), source-backed diagnosis and recovery guidance.

42939 — Reserved name

At a glance

42939 (reserved_name) rejects a name under an object-specific PostgreSQL rule. The selected 18.6 paths cover schemas, tablespaces, role creation, and role-specification grammar; the object named in the message determines which rule fired.

Field Value
SQLSTATE 42939
Condition reserved_name
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_RESERVED_NAME
Aliases

Meaning

Schema creation rejects a reserved pg_ prefix with unacceptable schema name "%s" and a system-schema DETAIL. Tablespace creation has the parallel system-tablespace message. CREATE ROLE rejects the pg_ prefix with role name "%s" is reserved. Separately, the grammar’s RoleId conversion rejects public, none, SESSION_USER, CURRENT_USER, and CURRENT_ROLE in role-name positions: public and none use the reserved-role-name primary, while the three current/session tokens use %s cannot be used as a role name here. These grammar rules do not make those words reserved in every identifier position.

Diagnosis

Start with the exact primary and DETAIL. unacceptable schema name points to the schema prefix guard; unacceptable tablespace name points to the tablespace guard; role name ... is reserved can be a pg_ role or the grammar’s public/none path; and %s cannot be used as a role name here identifies a role-specification token. For a grammar failure, inspect the command’s role position rather than searching pg_namespace or pg_authid. Do not infer a role failure from a tablespace message.

Response

Choose an allowed object name after checking migration and ownership. For a role-specification error, replace the role token with an actual allowed role identifier in that grammar position; quoting or changing search_path is not a substitute for fixing the command. Do not rename or drop system objects to force success; update dependent grants and configuration deliberately. If an object-level ERROR occurred inside an explicit transaction, use a savepoint rollback or transaction rollback before retrying.

Messages

The selected paths are explicit ERRORs. Their exact primary/detail roles are:

  • schema: unacceptable schema name "%s" with The prefix "pg_" is reserved for system schemas.
  • tablespace: unacceptable tablespace name "%s" with The prefix "pg_" is reserved for system tablespaces.
  • role prefix: role name "%s" is reserved with Role names starting with "pg_" are reserved.
  • role grammar: role name "%s" is reserved for public/none, or %s cannot be used as a role name here for SESSION_USER, CURRENT_USER, and CURRENT_ROLE.

Versions

From the locked 7.4 lower bound through 18.6 and 19beta3; that catalogue range is a condition bound, not one introduction point for every object-specific rule. The selected mechanisms are source-only and runtime was not run.

Sources

  • src.errcodes.42939.18.6src/backend/utils/errcodes.txt line 349, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).

  • src.call.42939.baa3c4599e167695f281cfe8src/backend/commands/schemacmds.c lines 107-110, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 5fd5f43dce5f36f06ed390014c06f244564072227d25a22735f594d2170626b1 (source).

  • src.call.42939.aed179efd45a7ca409d59fd6src/backend/commands/tablespace.c lines 281-285, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 f0369bece6339d18cd7d4a29b5fa3010447c3b8ece235c64b0d4fbf5f96a5317 (source).

  • src.call.42939.419595a34cae2a69b2e21624src/backend/commands/user.c lines 352-356, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 aa8769a2577fff287301d6c82169262cca328515ae940d5a2be4b3e8c21617ed (source).

  • src.call.42939.role-grammarsrc/backend/parser/gram.y lines 17460-17542, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 7e548b673a1e03eb3a56c5eb9ad92d8e11095fac76e14cb258ca851f58274724 (source).

  • src.calls.REL_18_6.42939 — resolved core call groups; SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf.

  • authored evidence — source claims, message roles, and runtime boundary.

185 - 42P01 — undefined_table

PostgreSQL reports SQLSTATE 42P01 when a referenced relation cannot be resolved. Check schema qualification, search_path, quoting, and migrations before creating or renaming objects.

At a glance

42P01 is PostgreSQL’s undefined_table condition in Class 42, syntax_error_or_access_rule_violation. The name is historical: the failing reference can be a table, view, materialized view, foreign table, or another relation name that the parser cannot resolve in the current namespace.

The ordinary diagnostic is relation "%s" does not exist for an unqualified reference or relation "%s.%s" does not exist for a qualified reference. The parser reports the SQLSTATE before execution of the query; in an autocommit connection the error does not leave a failed transaction behind.

The representative case queries a schema-qualified relation that does not exist, then creates a valid relation and reads it. PostgreSQL 18.6 and the isolated PostgreSQL 10.21 target both returned 42P01, kept the connection IDLE, and accepted the corrected query. The run IDs and assertions are retained in the public evidence JSON.

Field Value
SQLSTATE 42P01
Condition undefined_table
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_UNDEFINED_TABLE
Aliases

Meaning and trigger paths

During parse analysis PostgreSQL resolves each relation through the active namespace and search_path. If a qualified name is absent, parse_relation.c emits the two-part message; if an unqualified name is absent, it emits the one-part form. A misspelled name, a migration that has not run, a wrong database, a changed search_path, or a quoted identifier with different case can all lead to this same SQLSTATE.

This is a name-resolution error, not proof that a physical table was deleted. A relation can exist in another schema or database, and a role can lack the privileges needed to see or use it. Conversely, creating a table with a guessed name can conceal a deployment or quoting error.

The parser also uses 42P01 for some invalid references to a FROM item and for a forward reference to a common-table expression, with different detail or hint text. Use the complete message and context to distinguish those forms from a missing relation.

Messages and diagnostics

The runner’s operation is a schema-qualified lookup followed by a corrected relation. The harness supplies the disposable schema name; the query shape is:

SELECT * FROM does_not_exist;
CREATE TABLE exists(id integer PRIMARY KEY);
SELECT count(*) FROM exists;

PostgreSQL 18.6 returned:

SQLSTATE: 42P01
severity: ERROR
message_primary: relation "c42p01_missing_relation.does_not_exist" does not exist
source: parse_relation.c / parserOpenTable / line 1480

The PG10 target used the same primary message with source line 1159. The qualified form preserves both schema and relation in the message. For an unqualified reference, the fixed source template is relation "%s" does not exist; a future CTE or invalid FROM reference can add detail or a hint.

Diagnosis

Record SQLSTATE, primary message, detail, hint, statement position, current database, role, and search_path. Check the exact spelling and quoting used by the application. Query pg_class/pg_namespace or to_regclass() through an administrative or appropriately privileged connection to determine where the relation exists.

Compare the deployed migration revision with the connection’s database and schema. A pooled connection can carry a different search_path from the session used during setup. If the object is intended to be temporary or session-local, confirm that the query runs in the same session that created it.

The representative error was autocommit and left the connection IDLE; the corrected query returned count 0 and remained IDLE. An explicit transaction can still become INERROR if the missing relation is referenced inside that transaction, so record status rather than assuming that all 42P01 cases are harmless to the surrounding work.

Response and repair

Repair the name-resolution cause in deployment or application configuration:

  • Select the intended schema explicitly or set and verify search_path for the session.
  • Apply the missing migration in the correct database before serving queries.
  • Preserve case-sensitive identifiers with exact double quoting, or rename them to a consistent convention after checking dependents.
  • Use to_regclass() or an equivalent preflight only when a missing object is an expected branch; do not silently create a replacement relation for an unexpected deployment failure.

After correcting the relation, run the original query again and verify its result and transaction status. A successful CREATE TABLE or a new connection alone does not prove that every application session resolves the same object.

Versions and boundaries

The catalogue has a definition-presence observation for 42P01 at PostgreSQL 7.4 and through the locked 8.4.22 pre-9.0 definitions, then in every listed formal snapshot through PostgreSQL 18.6 and the PostgreSQL 19 Beta 3 preview. This is a definition-only presence boundary, not an exact implementation introduction or runtime-use claim. No condition definition change is recorded in the scanned range.

The missing-relation case passed on PostgreSQL 18.6 and 10.21. Source line numbers and parser hints differ by release and reference form. This page covers a schema-qualified absent relation and a valid follow-up query, not every namespace or access-rule path that can use 42P01.

42P02undefined_parameter covers a missing query parameter. 3F000invalid_schema_name covers an invalid schema name. 42501insufficient_privilege is an access failure after name resolution. 57014query_canceled can interrupt a corrective query but has a different cause.

Sources

Structured evidence is recorded in the public evidence JSON. Source records are fixed to PostgreSQL commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; runtime records retain both target IDs and structured observations.

186 - 42P02 — Undefined parameter

PostgreSQL SQLSTATE 42P02: Undefined parameter (undefined_parameter), source-backed diagnosis and recovery guidance.

42P02 — Undefined parameter

At a glance

42P02 (undefined_parameter) is a parse-time ERROR because a positional marker such as $1 is outside the parameter set known to parse analysis. It differs from a Bind-message count violation (08P01) and from 42P08, where a known parameter cannot receive a consistent type.

Field Value
SQLSTATE 42P02
Condition undefined_parameter
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_UNDEFINED_PARAMETER
Aliases

Meaning

The fixed-parameter hook rejects a parameter number outside the declared array or with an invalid type. The variable-parameter hook can grow its array while parsing, but its resolution checks still reject an out-of-range parameter. The generic parser hook reports the same primary when no hook resolves the marker. All selected branches attach parser position and use the dynamic number in there is no parameter $%d; this is about SQL ParamRef markers, not a missing column or PL/pgSQL variable.

The extended-query boundary is separate: exec_bind_message checks the number of parameter formats and values against the prepared statement and reports 08P01 for a count mismatch, including bind message supplies %d parameters, but prepared statement "%s" requires %d. A value-count or format-count failure during Bind therefore should not be relabeled as 42P02.

Diagnosis

Capture the SQL text, parser position, parameter number, and protocol phase. During Parse/parse analysis, compare every $n with the declared fixed or variable parameter set. During extended-query Bind, compare the format count and value count with the prepared statement and route a mismatch to 08P01; a missing SQL marker mapping is a different problem. Keep 42P08 for a parameter that exists but receives incompatible type deductions.

Response

Fix the SQL placeholder numbering or the Parse parameter declaration. In the Bind phase, send exactly the prepared statement’s required parameter count and a compatible format-code count; do not try to cure a count mismatch with a cast. For a genuine missing marker, add the intended parameter or use a deliberate literal/default. If the ERROR occurred inside an explicit transaction, roll back to a suitable savepoint or roll back the transaction before retrying; no runtime recovery is claimed here.

Messages

The selected parser groups are explicit ERROR with there is no parameter $%d; %d is the dynamic referenced parameter number. The separate fixed 18.6 Bind guards are explicit 08P01, with bind message has %d parameter formats but %d parameters or bind message supplies %d parameters, but prepared statement "%s" requires %d.

Versions

From the locked 7.4 lower bound through 18.6 and 19beta3; that is a catalogue range, not a runtime comparison. The selected parser and Bind branches are fixed 18.6 source paths; no client bind case was run.

Sources

  • src.errcodes.42P02.18.6src/backend/utils/errcodes.txt line 375, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).

  • src.call.42P02.81f0048a16f439569ce3a4basrc/backend/parser/parse_expr.c lines 899-902, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 63c37770872a08978f931c31f801666a08e3bc8e51c2c65ff60151a1d139d55b (source).

  • src.call.42P02.73515542f469d69893fd5fb8src/backend/parser/parse_param.c lines 109-112, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 4aab2ecc770fcda619b26ac12beaf7e527542b56f55eb45879b72e92442e8a28 (source).

  • src.call.42P02.671f865f9d428e0ab2a78347src/backend/parser/parse_param.c lines 203-206, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 4aab2ecc770fcda619b26ac12beaf7e527542b56f55eb45879b72e92442e8a28 (source).

  • src.call.42P02.bind-contractsrc/backend/tcop/postgres.c lines 1718-1731, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061 (source).

  • src.calls.REL_18_6.42P02 — resolved core call groups; SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf.

  • authored evidence — source claims, message roles, and runtime boundary.

187 - 42P03 — Duplicate cursor

PostgreSQL SQLSTATE 42P03: Duplicate cursor (duplicate_cursor), source-backed diagnosis and recovery guidance.

42P03 — Duplicate cursor

At a glance

42P03 (duplicate_cursor) reports a cursor/portal name collision, but the same SQLSTATE covers an ERROR, a replacement WARNING, and a PL/pgSQL-specific active-cursor ERROR. The caller and the CreatePortal options determine which behavior occurred.

Field Value
SQLSTATE 42P03
Condition duplicate_cursor
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DUPLICATE_CURSOR
Aliases

Meaning

CreatePortal(name, allowDup, dupSilent) raises ERROR cursor "%s" already exists when allowDup is false. When allowDup is true, it can emit WARNING closing existing cursor "%s" unless dupSilent is set, then drops the old portal and creates the new one. PL/pgSQL takes a different branch: SPI_cursor_find detects an already active named cursor and raises ERROR cursor "%s" already in use.

Diagnosis

Record the exact name, source (SQL portal creation or PL/pgSQL OPEN), severity, and transaction state. For SQL, inspect portal creation/reuse and pg_cursors where that view exposes the portal; for PL/pgSQL, inspect the cursor variable and the OPEN/CLOSE flow. The allowDup replacement branch is not evidence that a user-level duplicate declaration always warns, and the PL/pgSQL branch is not the portal-manager replacement path.

Response

For an ERROR from a non-replacing portal path, close the old portal or choose a name whose transaction lifetime is correct. A WARNING replacement path already closes the old portal, so the application must verify that replacement is intended rather than treating the warning as a failed close. For PL/pgSQL, close the named cursor before reopening it or use a distinct cursor variable/name. Only ERROR paths require explicit-transaction recovery with a savepoint rollback or transaction rollback; reconnecting can hide pool ownership problems.

Messages

Representative 18.6 messages are:

Path Severity Primary
CreatePortal(..., allowDup=false, ...) ERROR cursor "%s" already exists
CreatePortal(..., allowDup=true, dupSilent=false) WARNING closing existing cursor "%s"
PL/pgSQL named cursor already found ERROR cursor "%s" already in use

The %s value is dynamic; no concrete cursor name is claimed.

Versions

From 7.4 through 18.6 and 19beta3; the catalogue range is not a precise introduction claim. The selected portal-manager and PL/pgSQL branches are fixed 18.6 source paths, and runtime was not run.

Sources

  • src.errcodes.42P03.18.6src/backend/utils/errcodes.txt line 378, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).

  • src.call.42P03.800a8278cf453417f5af6d6esrc/backend/utils/mmgr/portalmem.c lines 185-187, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 8e29a302a7837316765acc798f9ff6eb22a330e8098a02794cd4d683601d3b04 (source).

  • src.call.42P03.208bdd3b576b5021fb35916dsrc/backend/utils/mmgr/portalmem.c lines 189-192, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 8e29a302a7837316765acc798f9ff6eb22a330e8098a02794cd4d683601d3b04 (source).

  • src.call.42P03.06c0580b43488eece2de1973src/pl/plpgsql/src/pl_exec.c lines 2895-2897, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 0df3c70a6bccf6dddf443fb99e152a16a67009827c44a820597e98e585cb8b20 (source).

  • src.calls.REL_18_6.42P03 — resolved core call groups; SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf.

  • authored evidence — source claims, message roles, and runtime boundary.

188 - 42P04 — Duplicate database

PostgreSQL SQLSTATE 42P04: Duplicate database (duplicate_database), source-backed diagnosis and recovery guidance.

42P04 — Duplicate database

At a glance

42P04 (duplicate_database) means a database-management path found the requested name already in the cluster. It is a cluster-level name check, not a relation collision in the current database, and the CREATE and RENAME callers have different surrounding guards.

Field Value
SQLSTATE 42P04
Condition duplicate_database
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DUPLICATE_DATABASE
Aliases

Meaning

In createdb, get_database_oid(dbname, true) checks the proposed database name and raises ERROR database "%s" already exists. RenameDatabase performs the same check against newname, after looking up the old database, checking ownership, and checking the CREATEDB privilege. The %s therefore names the requested database in CREATE or the new name in RENAME.

The utility dispatcher calls PreventInTransactionBlock(isTopLevel, "CREATE DATABASE") before it enters createdb. A CREATE DATABASE attempted inside an explicit transaction is therefore a separate transaction-block failure, not evidence that 42P04 was emitted. The RENAME path has its own old-name, owner, privilege, and new-name checks.

Diagnosis

Verify the target cluster and exact name in pg_database, including identifier folding and the possibility that another migration won a race. For CREATE, inspect the proposed name and template/owner prerequisites separately. For RENAME, inspect both old and new names plus ownership and CREATEDB; do not diagnose a missing old database or a privilege failure as 42P04.

Response

If the existing database is intended, make orchestration idempotent and inspect it rather than repeating CREATE DATABASE. Otherwise choose an unused name. Run CREATE DATABASE at top level, outside an explicit transaction block. For RENAME, choose an unused new name only after verifying the old database, ownership, CREATEDB, active sessions, dependencies, and cluster identity. If a RENAME ERROR occurs inside an explicit transaction, issue ROLLBACK before the next command, or ROLLBACK TO a savepoint created before the rename when the outer transaction must be retained. Drop or rename is not a generic repair for every 42P04.

Messages

The selected groups are explicit ERROR with database "%s" already exists: createdb supplies the requested name and RenameDatabase supplies the new name. The dispatcher’s PreventInTransactionBlock guard is source evidence for CREATE DATABASE’s separate transaction restriction, not another 42P04 message.

Versions

From 7.4 through 18.6 and 19beta3; that catalogue range is not a precise introduction claim. The selected CREATE, RENAME, and dispatcher guards are fixed 18.6 source paths; no runtime case was run.

Sources

  • src.errcodes.42P04.18.6src/backend/utils/errcodes.txt line 379, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).

  • src.call.42P04.465a77b5605c341bc91f6990src/backend/commands/dbcommands.c lines 1393-1395, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 64b77d2197dce16eb1ad19d8168382459d621a03df0b00be157f7db39ca22acf (source).

  • src.call.42P04.b0d1644def83c14a7504fec4src/backend/commands/dbcommands.c lines 1949-1951, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 64b77d2197dce16eb1ad19d8168382459d621a03df0b00be157f7db39ca22acf (source).

  • src.call.42P04.create-tx-guardsrc/backend/tcop/utility.c lines 769-773, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 7aae5d07628b6debf8456d1d4ea96f28912232192e56ea25773b4c4b61235a00 (source).

  • src.calls.REL_18_6.42P04 — resolved core call groups; SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf.

  • authored evidence — source claims, message roles, and runtime boundary.

189 - 42P05 — Duplicate prepared statement

PostgreSQL SQLSTATE 42P05: Duplicate prepared statement (duplicate_prepared_statement), source-backed diagnosis and recovery guidance.

42P05 — Duplicate prepared statement

At a glance

42P05 (duplicate_prepared_statement) means the current backend/session already has a named prepared statement with that name. Pool reuse can expose this state from an earlier request, while a different connection can have a separate statement of the same name.

Field Value
SQLSTATE 42P05
Condition duplicate_prepared_statement
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DUPLICATE_PSTATEMENT
Aliases

Meaning

StorePreparedStatement keeps named statements in the backend’s prepared_queries hash. HASH_ENTER reports ERROR prepared statement "%s" already exists when the name is already present, before the new plan is saved. DEALLOCATE name removes one entry and DEALLOCATE ALL removes the current backend’s entries; these operations do not remove a statement owned by another connection.

Diagnosis

Check the physical connection/backend identity, pg_prepared_statements, pool checkout history, and the PREPARE path. Distinguish a named server statement from the unnamed protocol statement and from a driver-local cache key. If two requests used the same pool connection, inspect the exact name and parameter types before changing the SQL.

Response

Reuse the existing statement only when its SQL and parameter types match. Otherwise coordinate DEALLOCATE name with the owner of that connection, use a unique deterministic name, or reset the pool session under an explicit lifecycle policy. Do not issue DEALLOCATE on an unrelated connection and assume it cleared the collision. Recover an explicit transaction after this ERROR with a savepoint rollback or transaction rollback; reconnecting is a controlled reset, not a universal fix.

Messages

The confirmed 18.6 variant is explicit ERROR: prepared statement "%s" already exists. %s is the dynamic server-side name.

Versions

From 7.4 through 18.6 and 19beta3; that catalogue range is not a precise introduction claim. The selected 18.6 source covers insertion and current-backend deallocation, and runtime was not run.

Sources

  • src.errcodes.42P05.18.6src/backend/utils/errcodes.txt line 381, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).

  • src.call.42P05.b490336894ec11628c1766f2src/backend/commands/prepare.c lines 412-415, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 e37fbd5f7618e5554561d9293d8c3af7cf3190c62c5c6bbceb3fe8b97be17956 (source).

  • src.call.42P05.lifecyclesrc/backend/commands/prepare.c lines 401-423 and 504-511, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 e37fbd5f7618e5554561d9293d8c3af7cf3190c62c5c6bbceb3fe8b97be17956 (source).

  • src.calls.REL_18_6.42P05 — resolved core call groups; SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf.

  • authored evidence — source claims, message roles, and runtime boundary.

190 - 42P06 — Duplicate schema

PostgreSQL SQLSTATE 42P06: Duplicate schema (duplicate_schema), source-backed diagnosis and recovery guidance.

42P06 — Duplicate schema

At a glance

42P06 (duplicate_schema) is a schema-definition collision. Plain CREATE SCHEMA errors; IF NOT EXISTS can emit NOTICE and continue, but that conditional path only skips creation and does not reconcile the existing schema.

Field Value
SQLSTATE 42P06
Condition duplicate_schema
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DUPLICATE_SCHEMA
Aliases

Meaning

NamespaceCreate reports ERROR schema "%s" already exists when the pg_namespace name lookup finds a row. CREATE SCHEMA IF NOT EXISTS checks the same namespace and reports NOTICE schema "%s" already exists, skipping before creation. Both messages identify the schema itself, not a relation inside it. The fixed command path performs the creation-permission checks before the conditional skip; the NOTICE is not an ownership or definition comparison.

Diagnosis

Resolve the target database and schema, then inspect pg_namespace.nspname, owner/ACL, contents, and the exact migration statement. Preserve severity: NOTICE is conditional behavior and lets the command continue; plain CREATE’s ERROR aborts an explicit transaction. Do not infer that a NOTICE schema has the requested owner, grants, extensions, tables, or migration version.

Response

Reuse only when owner, privileges, and contents meet the application contract. IF NOT EXISTS does not verify or reconcile those properties; follow it with explicit ownership/grant or migration checks when required. Do not drop a schema merely to pass a migration. If plain CREATE produced an ERROR in an explicit transaction, roll back to a suitable savepoint or roll back the transaction before continuing.

Messages

The selected variants are schema "%s" already exists (explicit ERROR) and schema "%s" already exists, skipping (explicit NOTICE). %s is the dynamic schema name; neither message certifies the existing schema’s owner or definition.

Versions

From 7.4 through 18.6 and 19beta3; that catalogue range is not a precise introduction claim. The selected ERROR and NOTICE branches are fixed 18.6 source paths, and runtime was not run.

Sources

  • src.errcodes.42P06.18.6src/backend/utils/errcodes.txt line 382, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).

  • src.call.42P06.4d5505b63e38ef1b25836623src/backend/catalog/pg_namespace.c lines 62-64, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 89675ba1bb9c531ab4f43db8a6f7cac00956561b342e42ea6eaae6b8d0b50d78 (source).

  • src.call.42P06.373538bec86ad8eedfce8d7asrc/backend/commands/schemacmds.c lines 132-135, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 5fd5f43dce5f36f06ed390014c06f244564072227d25a22735f594d2170626b1 (source).

  • src.calls.REL_18_6.42P06 — resolved core call groups; SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf.

  • authored evidence — source claims, message roles, and runtime boundary.

191 - 42P07 — Duplicate table or relation definition

PostgreSQL SQLSTATE 42P07: Duplicate table or relation definition (duplicate_table), source-backed diagnosis and recovery guidance.

42P07 — Duplicate table or relation definition

At a glance

42P07 (duplicate_table) covers relation-name collisions, conditional skips, and inheritance graph checks. Identify the operation before repairing it.

Field Value
SQLSTATE 42P07
Condition duplicate_table
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DUPLICATE_TABLE
Aliases

Meaning

Core 18.6 paths report relation "%s" already exists for table, sequence, index, and CREATE TABLE AS. These object kinds share the pg_class relation namespace, so a same-name object of another relation kind can be the collision. The index path with IF NOT EXISTS reports NOTICE relation "%s" already exists, skipping and returns without checking that the existing index has the requested definition. Inheritance reuses the code for repeated parents and for circular inheritance not allowed with DETAIL "%s" is already a child of "%s".

Diagnosis

Capture message, severity, DETAIL, statement, schema, and relation kind. For a name collision, inspect pg_class joined to pg_namespace and include sequences, indexes, tables, views, and materialized views in the search. For an IF NOT EXISTS NOTICE, inspect the existing object’s owner, persistence, columns, indexes, and options before treating the migration as satisfied; the source guard is name-based. For inheritance messages, inspect pg_inherits, resolve the complete parent list, and distinguish a duplicate parent from a cycle.

Response

Use idempotent DDL only when the existing definition is acceptable; otherwise choose a deliberate name or an object-specific migration. A relation-name collision may require adopting the existing object or changing the intended name, while a repeated-parent error requires removing the duplicate parent entry. A cycle requires breaking the parent graph and then verifying pg_inherits; renaming alone cannot repair it. Recover an explicit-transaction ERROR with a savepoint rollback or transaction rollback before catalog checks; a NOTICE path does not require that recovery.

Messages

Representative variants are:

Path Severity Primary DETAIL
relation name collision ERROR relation "%s" already exists none
index IF NOT EXISTS collision NOTICE relation "%s" already exists, skipping none
repeated inheritance parent ERROR relation "%s" would be inherited from more than once none
circular inheritance ERROR circular inheritance not allowed "%s" is already a child of "%s".

Versions

From 7.4 through 18.6 and 19beta3; that catalogue range is not a precise introduction claim. The selected 18.6 paths cover relation-name lookup, index IF NOT EXISTS, repeated inheritance parents, and circularity; runtime was not run.

Sources

  • src.errcodes.42P07.18.6src/backend/utils/errcodes.txt line 383, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).

  • src.call.42P07.694fcfd426e95ce13263fb9asrc/backend/catalog/heap.c lines 1194-1196, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 e720ee58279590793edd0985b3c910970ef56e7361b8ef92e245370587e02a0e (source).

  • src.call.42P07.38d8697cf62c00c05657a6d4src/backend/catalog/index.c lines 898-901, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 98a4156a5c21ae856a3b583b633cdeb578a5b69910386c9f166d69fcb04ba2d0 (source).

  • src.call.42P07.30cb2a5359e1ec4bea60a466src/backend/commands/tablecmds.c lines 875-878, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9 (source).

  • src.call.42P07.19ee2522385544dc7ceb62bbsrc/backend/commands/tablecmds.c lines 17376-17381, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9 (source).

  • src.calls.REL_18_6.42P07 — resolved core call groups; SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf.

  • authored evidence — source claims, message roles, and runtime boundary.

192 - 42P08 — Ambiguous parameter type

PostgreSQL SQLSTATE 42P08: Ambiguous parameter type (ambiguous_parameter), source-backed diagnosis and recovery guidance.

42P08 — Ambiguous parameter type

At a glance

42P08 (ambiguous_parameter) means a parameter marker exists, but parse analysis cannot make its type consistent or specific enough. The exact SQLSTATE and parser branch matter because similar primary text can be emitted by a different condition.

Field Value
SQLSTATE 42P08
Condition ambiguous_parameter
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_AMBIGUOUS_PARAMETER
Aliases

Meaning

The variable-parameter coercion hook first records a target type for an unknown parameter. If a later context requests a different type, it raises ERROR inconsistent types deduced for parameter $%d with DETAIL %s versus %s. A later parameter-resolution walk raises ERROR could not determine data type of parameter $%d when the resolved parameter type does not match the externally supplied type array. These are two selected 42P08 guards, not one generic “bind failed” message.

The primary could not determine data type of parameter $%d also appears in the var-parameter completion check in postgres.c with ERRCODE_INDETERMINATE_DATATYPE (42P18). Read the SQLSTATE and source path together: 42P08 is the selected mismatch during parameter resolution, while 42P18 is an unresolved type after analysis; an out-of-range marker is 42P02.

Diagnosis

Record the parameter number, every expression context, and DETAIL. For the inconsistent-types branch, compare the two type names in DETAIL and find the contexts that imposed them. For the unresolved-type branch, inspect the PREPARE/extended-query parameter type array and the final inferred type. Keep missing markers (42P02), Bind count violations (08P01), and alias/column ambiguity separate from this type-resolution failure.

Response

Declare the parameter type in PREPARE or cast it at a deliberate expression boundary. If two contexts genuinely need different types, split the parameters; otherwise make the contexts agree. Do not cast to an arbitrary broad type: verify operators, indexes, null semantics, and serialization. If the ERROR occurred inside an explicit transaction, roll back to a suitable savepoint or roll back the transaction before retrying.

Messages

The selected 42P08 variants are explicit ERRORs:

Guard Primary DETAIL
conflicting inferred target types inconsistent types deduced for parameter $%d %s versus %s
final parameter type mismatch could not determine data type of parameter $%d none

The same second primary can carry 42P18 when emitted by the separate unresolved-type completion guard; the SQLSTATE is part of the message identity.

Versions

From 7.4 through 18.6 and 19beta3; that catalogue range is not a precise introduction claim. The selected two 42P08 guards and the nearby 42P18 boundary are fixed 18.6 source paths; no runtime parameter case was run.

Sources

  • src.errcodes.42P08.18.6src/backend/utils/errcodes.txt line 388, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).

  • src.call.42P08.c2cfa81ed9389a1bddf8ec41src/backend/parser/parse_param.c lines 220-227, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 4aab2ecc770fcda619b26ac12beaf7e527542b56f55eb45879b72e92442e8a28 (source).

  • src.call.42P08.18ba6576d169dfdf614df72dsrc/backend/parser/parse_param.c lines 308-312, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 4aab2ecc770fcda619b26ac12beaf7e527542b56f55eb45879b72e92442e8a28 (source).

  • src.call.42P08.unresolved-boundarysrc/backend/tcop/postgres.c lines 725-736, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061 (source).

  • src.calls.REL_18_6.42P08 — resolved core call groups; SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf.

  • authored evidence — source claims, message roles, and runtime boundary.

193 - 42P09 — Ambiguous table alias

PostgreSQL SQLSTATE 42P09: Ambiguous table alias (ambiguous_alias), source-backed diagnosis and recovery guidance.

42P09 — Ambiguous table alias

At a glance

42P09 (ambiguous_alias) is a parser ERROR when one visible table reference resolves to more than one relation namespace item. It occurs before execution and has separate named-alias and relation-OID paths.

Field Value
SQLSTATE 42P09
Condition ambiguous_alias
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_AMBIGUOUS_ALIAS
Aliases

Meaning

For a textual reference, scanNameSpaceForRefname compares visible namespace aliases and raises table reference "%s" is ambiguous when a second match is visible. Column-only items and lateral-only items outside an active LATERAL scope are excluded. A separate scanNameSpaceForRelid path matches unaliased relation RTEs by OID and raises table reference %u is ambiguous when the same relation appears more than once. Both include parser position and are distinct from column ambiguity.

Diagnosis

Inspect the FROM/JOIN tree, alias names, subquery/CTE visibility, and LATERAL scope. If the primary includes a quoted name, find repeated visible aliases; if it includes an OID, look for repeated unaliased RTEs of that relation. Check whether a join alias hides an inner namespace or whether a LATERAL subquery makes both aliases visible. search_path can affect earlier relation lookup, but changing it is not a generic repair for a duplicate item already present in the parse namespace.

Response

Give each visible relation a deliberate alias, qualify references through that alias, or remove the redundant relation from the query builder. Preserve intentional LATERAL scope and verify join cardinality after the change. Do not treat 42P09 as 42P01 (missing relation) or 42702 (ambiguous column), and do not repeatedly submit identical text. If the parser ERROR occurred inside an explicit transaction, roll back to a savepoint or roll back the transaction before continuing.

Messages

The selected variants are explicit ERRORs:

Parser path Primary
duplicate visible alias/name table reference "%s" is ambiguous
duplicate unaliased relation OID table reference %u is ambiguous

Both attach parser position; %s and %u are dynamic source fields.

Versions

From 7.4 through 18.6 and 19beta3; that catalogue range is not a precise introduction claim. The selected named-alias and internal-OID branches are fixed 18.6 source paths, and runtime was not run.

Sources

  • src.errcodes.42P09.18.6src/backend/utils/errcodes.txt line 389, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).

  • src.call.42P09.ed0c1b7f7e4bd90cb2068e17src/backend/parser/parse_relation.c lines 224-228, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 0d9c88f4a8def4c2d982c33f13208590e21ecf5e6f8cd9d7faa223dc771c9a9a (source).

  • src.call.42P09.171afa1503a4e198e620e1b5src/backend/parser/parse_relation.c lines 271-275, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 0d9c88f4a8def4c2d982c33f13208590e21ecf5e6f8cd9d7faa223dc771c9a9a (source).

  • src.calls.REL_18_6.42P09 — resolved core call groups; SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf.

  • authored evidence — source claims, message roles, and runtime boundary.

194 - 42P10 — Invalid column reference

Source-backed reference for PostgreSQL SQLSTATE 42P10.

42P10 — Invalid column reference

At a glance

42P10 (invalid_column_reference) Column references can be rejected by the operation that consumes them.

Field Value
SQLSTATE 42P10
Condition invalid_column_reference
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_COLUMN_REFERENCE
Aliases

Meaning

Several consumers use 42P10 for different column-reference contracts. In the selected 18.6 paths, cookConstraint permits only the table that owns a CHECK constraint, CopyGetAttnums rejects a generated column named in an explicit COPY list (the default list skips generated columns), and ON CONFLICT inference reports this code when no suitable arbiter index matches. The last path is an inference failure, not a generic missing-column error.

Diagnosis

Read the complete primary message and DETAIL, then identify the statement phase: CHECK constraint ownership, an explicit COPY column list, or ON CONFLICT arbiter inference. For COPY, distinguish a user-supplied list from the default list. For ON CONFLICT, inspect the action and the candidate index’s columns or expressions, predicate, collation, and operator class; DO UPDATE needs a matching unique arbiter, while an exclusion constraint is not a general substitute for that action. Do not diagnose this as a missing column without the phase-specific message.

Response

Repair the specific contract: define the CHECK on its owning table, omit generated columns from an explicit COPY list, or align ON CONFLICT with an existing suitable unique index/constraint and its inference details. For DO NOTHING, verify the action-specific arbiter rules before considering an exclusion constraint. Do not create an arbitrary constraint as a generic repair. If this ERROR occurs inside an explicit transaction, ROLLBACK before the next command or ROLLBACK TO a savepoint created before the statement, then retry only after checking the catalog.

Messages

Representative source messages include: message: only table "%s" can be referenced in check constraint; message: column "%s" is a generated column; DETAIL: Generated columns cannot be used in COPY.; message: there is no unique or exclusion constraint matching the ON CONFLICT specification. Placeholders are filled by the actual object, column, or parameter.

Versions

The locked catalogue shows this condition by PostgreSQL 7.4; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

195 - 42P11 — Invalid cursor definition

Source-backed reference for PostgreSQL SQLSTATE 42P11.

42P11 — Invalid cursor definition

At a glance

42P11 (invalid_cursor_definition) Cursor options and cursor plans have definition-time constraints.

Field Value
SQLSTATE 42P11
Condition invalid_cursor_definition
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_CURSOR_DEFINITION
Aliases

Meaning

A cursor declaration or SPI cursor request violates a definition-time rule. Core 18.6 has separate paths for an SPI plan with more than one query, conflicting SCROLL/NO SCROLL or ASENSITIVE/INSENSITIVE options, and an INSENSITIVE cursor combined with a row-locking clause; the latter also reports that insensitive cursors must be READ ONLY.

Diagnosis

Preserve the exact option named by the error. Check whether the source is DECLARE or an SPI caller, whether the SPI plan contains more than one statement, and whether the option pair is SCROLL/NO SCROLL or ASENSITIVE/INSENSITIVE. For INSENSITIVE, inspect row-locking clauses and the required READ ONLY contract; do not diagnose this as a missing cursor.

Response

Split a multi-query SPI plan before opening a cursor, remove only the conflicting option, and add READ ONLY or remove the row lock when the INSENSITIVE contract requires it. If the caller is SPI, fix plan construction rather than changing cursor fetch code. An ERROR inside an explicit transaction requires ROLLBACK or ROLLBACK TO a pre-error savepoint before another command; autocommit can issue the corrected cursor request after the failed statement returns to idle.

Messages

Representative source messages include: message: cannot open multi-query plan as cursor; message: DECLARE INSENSITIVE CURSOR ... %s is not valid; DETAIL: Insensitive cursors must be READ ONLY.; message: cannot specify both %s and %s. Placeholders are filled by the actual object, column, or parameter.

Versions

The locked catalogue shows this condition by PostgreSQL 7.4; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

196 - 42P12 — Invalid database definition

Source-backed reference for PostgreSQL SQLSTATE 42P12.

42P12 — Invalid database definition

At a glance

42P12 (invalid_database_definition) This condition names an invalid database definition, but its core emitter was not resolved in this scan.

Field Value
SQLSTATE 42P12
Condition invalid_database_definition
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_DATABASE_DEFINITION
Aliases

Meaning

The catalogue condition is defined as invalid_database_definition. The bounded 18.6 call scan did not resolve a core emitting group for this code, so this page gives the condition boundary without inventing a database-operation trigger.

Diagnosis

When it appears, retain the server message, database name, statement, and server log context. First determine whether the response came from PostgreSQL core, an extension, a client-side mapping, or a wrapper; the condition name alone does not identify the failing catalogue object.

Response

Use the resolved message and fixed-version source path to choose a repair. Check the affected database definition and dependencies only after the actual emitter is identified; this bounded scan does not support a more specific SQL recipe or a fixed severity. If the actual response is an ERROR inside an explicit transaction, apply the normal ROLLBACK or pre-error savepoint rule, but do not present that generic protocol recovery as a confirmed 42P12 emitter path.

Messages

No message variant is included because the bounded source scan did not resolve a core emitting group for this condition.

Versions

The locked catalogue shows this condition by PostgreSQL 7.4; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

197 - 42P13 — Invalid function definition

Source-backed reference for PostgreSQL SQLSTATE 42P13.

42P13 — Invalid function definition

At a glance

42P13 (invalid_function_definition) Function, aggregate, and trigger declarations can fail validation before execution.

Field Value
SQLSTATE 42P13
Condition invalid_function_definition
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_FUNCTION_DEFINITION
Aliases

Meaning

Function-definition validation uses this condition for incompatible declarations. Selected core paths cover a polymorphic aggregate transition type that cannot be determined (with a caller-generated internal DETAIL), a function return-type mismatch when the final statement is not a compatible SELECT or DML RETURNING, and trigger functions declaring arguments.

Diagnosis

Classify the message before editing the function: aggregate transition-type inference and its dynamic DETAIL, final statement/RETURNING result versus declared return type, or trigger argument declaration. Compare the stored signature and return type with the body and the trigger contract; a non-returning DML statement or utility command is a different final-statement failure from a bad scalar coercion.

Response

Correct the declaration or body that the message identifies. Supply a determinable aggregate transition type, make the final function statement return the declared type, and read trigger arguments through TG_NARGS/TG_ARGV instead of declaring them. Recreate or replace only after checking dependent callers. If an ERROR is raised inside an explicit transaction, ROLLBACK or ROLLBACK TO a pre-error savepoint before issuing another DDL command.

Messages

Representative source messages include: message: cannot determine transition data type; errdetail_internal: %s; message: return type mismatch in function declared to return %s; DETAIL: Function's final statement must be SELECT or INSERT/UPDATE/DELETE/MERGE RETURNING.; message: trigger functions cannot have declared arguments; HINT: The arguments of the trigger can be accessed through TG_NARGS and TG_ARGV instead.. Placeholders are filled by the actual object, column, or parameter.

Versions

The locked catalogue shows this condition by PostgreSQL 7.4; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

198 - 42P14 — Invalid prepared statement definition

Source-backed reference for PostgreSQL SQLSTATE 42P14.

42P14 — Invalid prepared statement definition

At a glance

42P14 (invalid_prepared_statement_definition) A PREPARE command can fail while defining the prepared statement itself.

Field Value
SQLSTATE 42P14
Condition invalid_prepared_statement_definition
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_PSTATEMENT_DEFINITION
Aliases

Meaning

The fixed 18.6 PrepareQuery path rejects a null or empty name for the SQL PREPARE command before the named prepared statement can be registered; the guard exists because the extended protocol has a separate unnamed statement slot. An empty name in a protocol Parse message is therefore not automatically 42P14, and an empty quoted SQL identifier can fail earlier in lexical or parse validation.

Diagnosis

Capture whether the client sent SQL PREPARE or an extended-protocol Parse, and preserve the exact statement name. Distinguish SQL PREPARE’s empty-name guard from a legal unnamed protocol statement, 26000 (prepared statement does not exist), and later parameter/type errors; an empty quoted identifier may fail before this guard is reached.

Response

For SQL PREPARE, send a non-empty, consistently quoted statement name. For extended protocol, retain the unnamed statement slot when that is intentional instead of translating it into SQL PREPARE. If a framework generates names, inspect that naming layer and verify the same session is used for later EXECUTE and DEALLOCATE. An ERROR inside an explicit transaction still requires ROLLBACK or ROLLBACK TO a pre-error savepoint before the next command.

Messages

Representative source message: invalid statement name: must not be empty (ERROR; it has no placeholders).

Versions

The locked catalogue shows this condition by PostgreSQL 7.4; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

199 - 42P15 — Invalid schema definition

Source-backed reference for PostgreSQL SQLSTATE 42P15.

42P15 — Invalid schema definition

At a glance

42P15 (invalid_schema_definition) CREATE SCHEMA can be rejected when its schema declarations disagree.

Field Value
SQLSTATE 42P15
Condition invalid_schema_definition
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_SCHEMA_DEFINITION
Aliases

Meaning

Schema-definition validation applies while transforming the objects contained by CREATE SCHEMA. The setSchemaName helper rejects a contained object’s explicitly specified schema when it differs from the one CREATE SCHEMA is currently creating. This is a contained-object declaration mismatch, not two independent top-level schemas or a missing-schema lookup.

Diagnosis

Read both schema identifiers from the message and the complete CREATE SCHEMA statement. Find which contained CREATE TABLE, sequence, view, or other object supplied the conflicting qualification. Check generated DDL and search_path separately; changing search_path cannot reconcile two names that the statement explicitly supplies.

Response

Generate CREATE SCHEMA with one intended name and keep each contained object’s explicit qualification under that name, or omit the qualification where the command supplies the context. Correct the migration generator or quoting. A failed CREATE SCHEMA does not by itself prove that a partial schema was committed; inspect the catalog only when cleanup or a prior transaction requires it. If this ERROR occurs inside an explicit transaction, ROLLBACK or ROLLBACK TO a pre-error savepoint before retrying.

Messages

Representative source messages include: message: CREATE specifies a schema (%s) different from the one being created (%s). Placeholders are filled by the actual object, column, or parameter.

Versions

The locked catalogue shows this condition by PostgreSQL 7.4; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

  • src/backend/parser/parse_utilcmd.c:4229-4233 (fixed source)

200 - 42P16 — Invalid table definition

Source-backed reference for PostgreSQL SQLSTATE 42P16.

42P16 — Invalid table definition

At a glance

42P16 (invalid_table_definition) A table definition can violate partition-key, collation, or primary-key rules.

Field Value
SQLSTATE 42P16
Condition invalid_table_definition
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_TABLE_DEFINITION
Aliases

Meaning

Table-definition checks use this condition for several relation-shape violations. Core 18.6 examples reject pseudo-types in partition keys, missing collation for a collatable partition key, and multiple primary keys.

Diagnosis

Use the exact message to identify the table and column. Inspect pg_attribute/pg_type for the partition key type, determine the collation explicitly for collatable types, and list existing primary constraints before changing DDL.

Response

Change only the conflicting table definition: use a supported concrete partition-key type, add an explicit COLLATE where the source requires it, or retain one intended primary key and remove the duplicate declaration from the migration. If this ERROR occurs inside an explicit transaction, ROLLBACK or ROLLBACK TO a pre-error savepoint before issuing the corrected DDL; do not keep sending table changes in the aborted transaction.

Messages

Representative source messages include: message: partition key column %s has pseudo-type %s; message: no collation was derived for partition key column %s with collatable type %s; HINT: Use the COLLATE clause to set the collation explicitly.; message: multiple primary keys for table "%s" are not allowed. Placeholders are filled by the actual object, column, or parameter.

Versions

The locked catalogue shows this condition by PostgreSQL 7.4; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

201 - 42P17 — Invalid object definition

Source-backed reference for PostgreSQL SQLSTATE 42P17.

42P17 — Invalid object definition

At a glance

42P17 (invalid_object_definition) Object definitions can conflict through inheritance, generated columns, or rewrite rules.

Field Value
SQLSTATE 42P17
Condition invalid_object_definition
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_OBJECT_DEFINITION
Aliases

Meaning

Object-definition validation covers object relationships and generated/rule definitions. Selected paths reject an inherited constraint conflict, a generated column referencing another generated column, and recursive rules.

Diagnosis

Classify the object named in the message: relation inheritance, generated-column expression, or rewrite rule. Inspect pg_inherits and constraint inheritance, the full generated expression, or pg_rewrite rules; these paths require different repairs.

Response

For an inherited-constraint conflict, compare the parent/child definitions and inheritance flags and align them with the intended inheritance contract; do not universally remove an inherited constraint. Make a generated expression depend only on permitted base columns, or break the rewrite-rule cycle. Recheck the resulting object graph before rerunning DDL; renaming alone does not repair a recursive rule. If an ERROR occurs inside an explicit transaction, ROLLBACK or ROLLBACK TO a pre-error savepoint before another DDL attempt.

Messages

Representative source messages include: message: constraint "%s" conflicts with non-inherited constraint on relation "%s"; message: cannot use generated column "%s" in column generation expression; DETAIL: A generated column cannot reference another generated column.; message: infinite recursion detected in rules for relation "%s". Placeholders are filled by the actual object, column, or parameter.

Versions

The locked catalogue shows this condition by PostgreSQL 7.4; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

202 - 42P18 — Indeterminate datatype

Source-backed reference for PostgreSQL SQLSTATE 42P18.

42P18 — Indeterminate datatype

At a glance

42P18 (indeterminate_datatype) Type inference fails when an expression or protocol parameter has no determinate type.

Field Value
SQLSTATE 42P18
Condition indeterminate_datatype
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INDETERMINATE_DATATYPE
Aliases

Meaning

The parser cannot assign a determinate type to an expression or protocol parameter. Core 18.6 explicitly reports empty ARRAY[], and pg_analyze_and_rewrite_varparams performs a final pass that rejects every parameter still InvalidOid or UNKNOWNOID, such as $1 with no constraining context. These are different from 42P08, where inputs imply incompatible types, and 42P02, where the parameter reference itself is missing.

Diagnosis

Use the exact location or parameter number in the response. For ARRAY[], inspect the surrounding expression and cast it to the intended element type; for $n, inspect the Parse/extended-query parameter types and every context that should constrain it, then confirm the final parameter-type pass can resolve the OID. A client that sends no type OID may leave this decision to the server. A conflicting deduction is 42P08; a reference to a parameter that was not declared is 42P02.

Response

Add an explicit, semantically correct cast or supply parameter type information, then verify operators and result columns still have the intended types. Do not silence the error by casting everything to text; that can change index use and function/operator selection. Retry the parse or statement only after the corrected definition is known. If the ERROR was raised inside an explicit transaction, ROLLBACK or ROLLBACK TO a pre-error savepoint before sending the corrected statement.

Messages

Representative source messages include: message: cannot determine type of empty array; HINT: Explicitly cast to the desired type, for example ARRAY[]::integer[].; message: could not determine data type of parameter $%d. Placeholders are filled by the actual object, column, or parameter.

Versions

The locked catalogue shows this condition by PostgreSQL 7.4; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

203 - 42P19 — Invalid recursion

Source-backed reference for PostgreSQL SQLSTATE 42P19.

42P19 — Invalid recursion

At a glance

42P19 (invalid_recursion) Recursive query structure is checked before the recursive term can run.

Field Value
SQLSTATE 42P19
Condition invalid_recursion
Status active
Known present by 8.4.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_RECURSION
Aliases

Meaning

Recursive-query validation rejects a recursive term whose structure cannot be evaluated safely. Core 18.6 checks aggregate use in the recursive term, the required non-recursive UNION [ALL] recursive form, and recursive-reference context and multiplicity. The selected aggregate guard is about aggregates (p_hasAggs); it does not justify saying that every window function is forbidden.

Diagnosis

Read the query shape rather than only the CTE name. Separate the anchor term from the recursive term, count references to the recursive query, and inspect whether a reference appears in a forbidden recursive context such as a subquery or the nullable side of an outer join: for LEFT JOIN that is the right side, for RIGHT JOIN the left side, and for FULL JOIN both sides; the preserved side of a one-sided outer join is not covered by that guard. Also check INTERSECT/EXCEPT contexts. Identify actual aggregates in the recursive term; do not classify every window expression as this error. This distinguishes structural recursion errors from 42P18 type inference failures.

Response

Rewrite the CTE into one non-recursive anchor followed by one UNION or UNION ALL recursive term, keep one recursive reference in an allowed context, and move aggregation outside the recursive step when needed. Validate termination and result cardinality before retrying. If this ERROR occurs inside an explicit transaction, ROLLBACK or ROLLBACK TO a pre-error savepoint before sending the rewritten query.

Messages

Representative source messages include: message: aggregate functions are not allowed in a recursive query's recursive term; message: recursive query "%s" does not have the form non-recursive-term UNION [ALL] recursive-term; message: recursive reference to query "%s" must not appear more than once. Placeholders are filled by the actual object, column, or parameter.

Versions

The locked catalogue shows this condition by PostgreSQL 8.4.0; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

204 - 42P20 — Windowing error

Source-backed reference for PostgreSQL SQLSTATE 42P20.

42P20 — Windowing error

At a glance

42P20 (windowing_error) Window definitions constrain both calls and frame boundaries.

Field Value
SQLSTATE 42P20
Condition windowing_error
Status active
Known present by 8.4.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_WINDOWING_ERROR
Aliases

Meaning

The fixed core uses 42P20 for window-function placement or nesting errors and for invalid window-definition structure. Parser grammar rejects impossible frame start/end combinations; parse analysis rejects a window function in a clause that cannot contain it or another window function; named-window transformation rejects conflicting inheritance. A legal frame can still be empty for a particular row, so an empty result is not by itself a 42P20 signal.

Diagnosis

Classify the primary message before changing SQL. A frame message points to UNBOUNDED direction or start/end ordering; RANGE with an offset requires exactly one ORDER BY column and GROUPS requires an ORDER BY clause. A placement message names a clause such as WHERE, GROUP BY, JOIN, RETURNING, or a window definition, while the nested-call message means a window expression appears inside another window expression. Named-window messages distinguish duplicate definitions, attempts to override copied PARTITION BY or ORDER BY, and copying a window that already has a frame; OVER foo and OVER (foo) therefore have different inheritance behavior. The executor separately reports negative ROWS or GROUPS frame offsets as SQLSTATE 22013 (invalid_preceding_or_following_size), and null offsets as 22004; those are not 42P20.

Response

Move a nested calculation to an outer query level, or move the window expression out of the named clause identified by the message. Repair only the relevant frame grammar, add the required ordering for RANGE/GROUPS, and define one named window without conflicting overrides. Do not change a valid frame merely because it produces no rows for one current row. If this ERROR occurs inside an explicit transaction, issue ROLLBACK or ROLLBACK TO a savepoint created before the statement before retrying; autocommit can submit the corrected query after the failed statement returns to idle.

Messages

Representative fixed-source messages include:

  • ERROR message: window function calls cannot be nested
  • ERROR message: frame start cannot be UNBOUNDED FOLLOWING
  • ERROR message: frame starting from following row cannot end with current row
  • ERROR message: frame end cannot be UNBOUNDED PRECEDING
  • ERROR message: frame starting from current row cannot have preceding rows
  • ERROR message: frame starting from following row cannot have preceding rows
  • ERROR message: window functions are not allowed in %s
  • ERROR message: window "%s" is already defined
  • ERROR message: cannot override PARTITION BY clause of window "%s"
  • ERROR message: cannot override ORDER BY clause of window "%s"
  • ERROR message: cannot copy window "%s" because it has a frame clause
  • ERROR message: cannot copy window "%s" because it has a frame clause; HINT: Omit the parentheses in this OVER clause.
  • ERROR message: RANGE with offset PRECEDING/FOLLOWING requires exactly one ORDER BY column
  • ERROR message: GROUPS mode requires an ORDER BY clause

Placeholders are filled by the actual object, column, or parameter.

Versions

The locked catalogue shows this condition by PostgreSQL 8.4.0; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

205 - 42P21 — Collation mismatch

Source-backed reference for PostgreSQL SQLSTATE 42P21.

42P21 — Collation mismatch

At a glance

42P21 (collation_mismatch) Different collation choices meet where PostgreSQL requires one compatible result.

Field Value
SQLSTATE 42P21
Condition collation_mismatch
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_COLLATION_MISMATCH
Aliases

Meaning

42P21 is raised when a fixed-source path needs one compatible collation but has incompatible choices. Implicit choices are tracked as COLLATE_CONFLICT and may be returned as InvalidOid when the caller permits no common collation; a caller that requires a collation is where the implicit mismatch becomes an ERROR. Explicit COLLATE conflicts fail immediately. The same condition also covers recursive CTE output, inherited or child-column definitions, and foreign-key key-column compatibility.

Diagnosis

For an implicit-collation message, keep both names and inspect whether the caller requested a common collation; differing implicit operands do not all raise 42P21 immediately. For an explicit-collation message, find the two COLLATE clauses and make the intended choice consistent. In a recursive query compare the non-recursive term with the overall column collation. For inheritance or partitioned child errors compare the parent and child column definitions. For a foreign key compare the referencing and referenced key columns: fixed source permits different collations when both are deterministic, but if either is nondeterministic the two collations must be the same. Preserve the DETAIL names rather than treating this as a generic text-cast problem.

Response

Apply one deliberate COLLATE at the expression boundary for an expression conflict, or align the explicit clauses and recursive non-recursive term. Align inherited or child column definitions before rerunning DDL. For a foreign key, choose compatible key collations and satisfy the stricter same-collation rule whenever either side is nondeterministic; then recheck equality and index semantics. If this ERROR occurs inside an explicit transaction, issue ROLLBACK or ROLLBACK TO a pre-error savepoint before the corrected statement; autocommit can retry after returning to idle.

Messages

Representative fixed-source messages include:

  • ERROR message: collation mismatch between implicit collations "%s" and "%s"; HINT: You can choose the collation by applying the COLLATE clause to one or both expressions.
  • ERROR message: collation mismatch between explicit collations "%s" and "%s"
  • ERROR message: recursive query "%s" column %d has collation "%s" in non-recursive term but collation "%s" overall; HINT: Use the COLLATE clause to set the collation of the non-recursive term.
  • ERROR message: column "%s" has a collation conflict; DETAIL: "%s" versus "%s"
  • ERROR message: inherited column "%s" has a collation conflict; DETAIL: "%s" versus "%s"
  • ERROR message: child table "%s" has different collation for column "%s"; DETAIL: "%s" versus "%s"
  • ERROR message: foreign key constraint "%s" cannot be implemented; DETAIL: Key columns "%s" of the referencing table and "%s" of the referenced table have incompatible collations: "%s" and "%s". If either collation is nondeterministic, then both collations have to be the same.

Placeholders are filled by the actual object, column, or parameter.

Versions

The locked catalogue shows this condition by PostgreSQL 9.1.0; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

206 - 42P22 — Indeterminate collation

Source-backed reference for PostgreSQL SQLSTATE 42P22.

42P22 — Indeterminate collation

At a glance

42P22 (indeterminate_collation) An operation that needs one collation has no unambiguous collation to use.

Field Value
SQLSTATE 42P22
Condition indeterminate_collation
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INDETERMINATE_COLLATION
Aliases

Meaning

42P22 is emitted when a selected operation requires a usable collation but derivation produced none, often represented by InvalidOid. This is different from 42P21: the caller-specific message names the operation that cannot proceed instead of presenting two explicit collation names. Fixed core callers include string hashing or comparison, index and partition expressions, CTAS and view output columns, regular expressions, LIKE/ILIKE, and formatting functions.

Diagnosis

Read the operation named by the primary message and trace its string expression to the point where collation should be chosen. Hashing or comparison points to the operator or value expression; an index or partition message points to the definition expression; a CTAS or view-column message points to the output column; regex, LIKE, and ILIKE point to the pattern operands; a %s function message names the formatting function. The fixed callers supply the caller-specific HINT Use the COLLATE clause to set the collation explicitly.. Choose the expression or declared-column boundary deliberately, and distinguish this no-collation requirement from a 42P21 conflict between known choices.

Response

Apply COLLATE at the expression or output-column boundary that owns the semantic choice, then recreate the affected index, partition, view, or CTAS definition when required. Verify comparison, hashing, pattern, regex, and formatting behavior under that collation; do not change the database locale globally just to silence one caller. If this ERROR occurs inside an explicit transaction, issue ROLLBACK or ROLLBACK TO a pre-error savepoint before retrying; autocommit can submit the corrected statement after returning to idle.

Messages

Representative fixed-source messages include:

  • ERROR message: could not determine which collation to use for string hashing; HINT: Use the COLLATE clause to set the collation explicitly.
  • ERROR message: no collation was derived for column "%s" with collatable type %s; HINT: Use the COLLATE clause to set the collation explicitly.
  • ERROR message: could not determine which collation to use for index expression; HINT: Use the COLLATE clause to set the collation explicitly.
  • ERROR message: could not determine which collation to use for partition expression; HINT: Use the COLLATE clause to set the collation explicitly.
  • ERROR message: could not determine which collation to use for view column "%s"; HINT: Use the COLLATE clause to set the collation explicitly.
  • ERROR message: could not determine which collation to use for regular expression; HINT: Use the COLLATE clause to set the collation explicitly.
  • ERROR message: could not determine which collation to use for %s function; HINT: Use the COLLATE clause to set the collation explicitly.
  • ERROR message: could not determine which collation to use for LIKE; HINT: Use the COLLATE clause to set the collation explicitly.
  • ERROR message: could not determine which collation to use for ILIKE; HINT: Use the COLLATE clause to set the collation explicitly.
  • ERROR message: could not determine which collation to use for string comparison; HINT: Use the COLLATE clause to set the collation explicitly.

Placeholders are filled by the actual object, column, or parameter.

Versions

The locked catalogue shows this condition by PostgreSQL 9.1.0; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

207 - 44000 — with_check_option_violation

PostgreSQL SQLSTATE 44000: view WITH CHECK OPTION diagnostics and repair.

44000 — with_check_option_violation

At a glance

44000 means that a row written through a view would not satisfy that view’s WITH CHECK OPTION predicate. It protects the view’s write invariant; it is not the table-level CHECK condition 23514.

Field Value
SQLSTATE 44000
Condition with_check_option_violation
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_WITH_CHECK_OPTION_VIOLATION
Aliases

Meaning

When an automatically updatable view is defined with WITH CHECK OPTION, PostgreSQL checks that an inserted or updated row remains visible through the view. The executor treats both FALSE and NULL from the view predicate as failure, so a nullable predicate column does not make an unknown row pass. ExecWithCheckOptions reports new row violates check option for view "%s"; the dynamic failing-row DETAIL is included only when the permissions allow the row description. LOCAL checks conditions defined directly in the current view; underlying base-view conditions are not checked unless those base views also specify CHECK OPTION. CASCADED checks the current view and all underlying base-view conditions. CHECK OPTION is supported only on automatically updatable views without an INSTEAD OF trigger or rule; a trigger-updatable base view and an INSTEAD rewrite are separate boundaries where cascading or all checks can be ignored. The selected natural case is a directly updatable view.

Diagnosis

Capture SQLSTATE, view name, DETAIL when present, and the exact row values sent through the view. Read the definition with pg_get_viewdef() and evaluate its predicate using SQL three-valued logic: only TRUE is visible through the check option, while FALSE and NULL fail. Check whether the view is automatically updatable, whether it uses LOCAL or CASCADED, and whether a base view has an INSTEAD OF trigger or an INSTEAD rewrite. Do not search only for table CHECK constraints: LOCAL does not check ordinary underlying-view predicates, while CASCADED does unless a trigger-updatable or rewritten boundary prevents that cascade. Missing DETAIL can be a permission boundary rather than proof that no row was checked.

Response

Correct the row so its predicate is TRUE, or change the view definition only after confirming the schema contract and the intended LOCAL/CASCADED scope. Keep the check option when the view is meant to be an enforced filtered interface. If a trigger-updatable base view or an INSTEAD rewrite is involved, inspect that boundary and its effective checks; do not assume a cascaded check reached it. After an autocommit error the selected connection remained IDLE; inside an explicit transaction rollback the failed block before retrying with a valid row.

Messages

The fixed source templates are new row violates check option for view "%s" and Failing row contains %s.. The view identifier and row rendering are dynamic. Treat DETAIL as diagnostic data and avoid copying it into a stable parser without accounting for values and formatting.

Representative case

The shared registry in verify/cases/44000/snippets.json (SHA-256 7b227bca904c860388c6cf1f5b7f551412b4d67832fb91aaa682f4126072e41c) creates a filtered view, attempts one row outside the predicate, and then inserts a valid row. See the public case export and structured evidence.

CREATE TABLE items(id integer PRIMARY KEY, visible boolean NOT NULL, note text NOT NULL);
CREATE VIEW visible_items AS SELECT id, visible, note FROM items WHERE visible WITH CHECK OPTION;
INSERT INTO visible_items VALUES (1, false, 'hidden');
INSERT INTO visible_items VALUES (1, true, 'visible');
SELECT id, visible, note FROM visible_items ORDER BY id;

The runner qualifies registry relation names inside a private schema. It asserts the natural server SQLSTATE and view diagnostic, then verifies that only the visible row was accepted.

The selected case observed 44000 on PostgreSQL 18.6 and 10.21 when a row with visible = false was inserted through a view with WITH CHECK OPTION. The DETAIL contained the failing row, autocommit stayed IDLE, and a row satisfying the predicate was accepted.

Versions

The locked catalogue records this condition from the early historical boundary through the formal snapshots. The fixed source has the same mechanism in 18.6 and 10.23; the selected runtime case covers a simple insert through a view on 18.6 and 10.21, not every view-rule composition.

Compare 23514 check violation for a table CHECK and 27000 triggered data change violation for trigger-driven same-command changes.

Sources

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.execMain.18.6 (SHA-256 33b97337fa23a649c5e7a092e1bd405a54e8503529236c62c9d5bb93a1774a8d)
  • CREATE VIEW documentation · local call scan src.calls.REL_18_6 (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

208 - 53000 — insufficient_resources

Source-backed reference for PostgreSQL SQLSTATE 53000.

53000

At a glance

53000 is the broad insufficient-resources condition. Fixed 18.6 callers include background-worker startup, local-buffer exhaustion, and file-descriptor limits, so the message and startup/runtime phase identify the resource.

Field Value
SQLSTATE 53000
Condition insufficient_resources
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INSUFFICIENT_RESOURCES
Aliases

Meaning

The class-level condition does not identify one tunable. For example, could not register background process points to worker capacity, no empty local buffer available to local-buffer state, and file-descriptor variants report either startup minimums or a per-process allocation limit.

Diagnosis

Record the primary message, detail/hint, phase, and server log context. For startup, compare process limits and configured worker capacity. For a running command, determine whether the failing object is a local buffer, descriptor, worker slot, or another fixed resource before changing settings.

Response

Relieve or increase the specific resource named by the message, within the platform and PostgreSQL limits. Clean up unused descriptors or workers and verify the relevant configuration. If an ERROR occurs inside an explicit transaction, use ROLLBACK or ROLLBACK TO SAVEPOINT before retrying; in autocommit, retry only after the named resource is available. Startup FATAL paths such as the server-process descriptor check have no client transaction to recover. Do not apply a generic restart or memory change without identifying the exhausted resource.

Versions

The locked catalogue records this condition from 7.4; cited callers are PostgreSQL 18.6 source. No resource exhaustion was manufactured on a host.

53400, 54001, 53200

Sources

contrib/pg_prewarm/autoprewarm.c#L943-L981

src/backend/storage/buffer/localbuf.c#L270-L272

src/backend/storage/file/fd.c#L1072-L1078

The structured evidence record records fixed messages and the source/runtime boundary.

209 - 53100 — disk_full

Source-backed reference for PostgreSQL SQLSTATE 53100.

53100

At a glance

53100 reports the explicit short-write branch of a file write. Fixed paths cover base-backup output and relation-file extension; the diagnostic names the file, partial byte count, requested count, and offset or block.

Field Value
SQLSTATE 53100
Condition disk_full
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DISK_FULL
Aliases

Meaning

The short-write messages carry the target file, bytes written versus requested, and an offset or block, with the hint Check free disk space.. The same md.c function first handles a negative FileWrite result through errcode_for_file_access() and %m; in the fixed helper’s saved-errno switch, ENOSPC maps to 53100, while EFBIG and EDQUOT are not listed and therefore take its ERRCODE_INTERNAL_ERROR default. This is a storage-write boundary, not a generic SQL data error or proof that the host volume is full.

Diagnosis

Identify the filesystem and target path from the message, then check free space, quota, mount state, write errors, and whether the database or backup destination is the affected volume. Compare the offset/block and partial byte count with the operation and correlate server logs. If the primary is could not ...: %m rather than the short-write template, inspect the saved errno: the fixed helper maps ENOSPC to 53100, but sends unlisted EFBIG and EDQUOT through its internal-error default. Do not relabel an errno-specific SQLSTATE as 53100.

Response

Free or provision capacity on the named filesystem, correct the reported write condition, or redirect the operation to a suitable destination. Treat a partial base backup or relation write as incomplete until the operation has been validated; resume or retry only under that operation’s documented recovery procedure. If this ERROR occurs inside an explicit transaction, use ROLLBACK or ROLLBACK TO SAVEPOINT before retrying; in autocommit, retry only after the storage cause is corrected. Do not create disk pressure on a user instance to test this code.

Versions

The locked catalogue records this condition from 7.4; the cited write paths are PostgreSQL 18.6 source. No disk-full runtime was run.

53000

Sources

src/backend/backup/basebackup_server.c#L177-L182

src/backend/storage/smgr/md.c#L521-L526

src/backend/storage/smgr/md.c#L512-L526

src/backend/utils/error/elog.c#L868-L938

The structured evidence record records fixed messages and the source/runtime boundary.

210 - 53200 — out_of_memory

Source-backed reference for PostgreSQL SQLSTATE 53200.

53200

At a glance

53200 is PostgreSQL’s out-of-memory condition. Fixed callers include ordinary memory-context allocation, shared-memory and lock-table capacity, extension/statistics-file loading, and WAL-reading processors. The useful diagnosis is the operation and allocation context, not a claim that every memory failure has one cause.

Field Value
SQLSTATE 53200
Condition out_of_memory
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_OUT_OF_MEMORY
Aliases

Meaning

The fixed source has several distinct boundaries. MemoryContextAllocationFailure reports out of memory with the requested size and memory-context name, while ShmemAlloc and lock-table setup report out of shared memory; the latter can hint at max_locks_per_transaction. Extension paths add operation details: pg_stat_statements logs out of memory with a file-reading detail, and WAL readers report the same primary with an allocation detail. The pg_stat_statements branch is LOG and returns from its loader, so it is not the same as a client ERROR that aborts the current transaction; the core and WAL-reader ERROR branches require normal transaction recovery. The two-phase source path is a WAL-reader allocation path, not evidence that reaching max_prepared_transactions itself emits 53200.

Diagnosis

Preserve severity, primary, detail, hint, operation, backend, and server log. Determine whether the path was a backend memory-context request, shared-memory/lock-table allocation, file/statistics structure, or WAL reader. For out of shared memory with a max_locks_per_transaction hint, inspect transaction lock counts and the configured lock-table capacity; increasing it consumes shared memory at startup. Check workload and relevant limits from observation; do not infer a host-wide memory diagnosis from the SQLSTATE alone.

Response

Reduce or reshape the operation, release application-side pressure, or adjust the named PostgreSQL capacity after confirming its effect and platform limits. Finish or roll back transactions that hold excessive locks before changing max_locks_per_transaction; do not treat that hint as proof of operating-system OOM. For a failed file/WAL/statistics operation, validate the object before retrying. The core/WAL-reader ERROR branches leave an explicit transaction failed, so use ROLLBACK or ROLLBACK TO SAVEPOINT before retrying; autocommit retry is appropriate only after the allocation cause is corrected. The pg_stat_statements LOG branch is a backend loader path and does not itself require client transaction recovery. OOM and corruption tests are intentionally source-only here; do not force allocator failure on a live host.

Versions

The locked catalogue records this condition from 7.4; cited extension and core paths are PostgreSQL 18.6 source. No OOM runtime was attempted.

53000, 53400, 55000

Sources

contrib/pg_stat_statements/pg_stat_statements.c#L2340-L2350

contrib/pg_walinspect/pg_walinspect.c#L121-L124

src/backend/access/transam/twophase.c#L1417-L1420

src/backend/utils/mmgr/aset.c#L444-L453

src/backend/utils/mmgr/mcxt.c#L1157-L1167

src/backend/storage/ipc/shmem.c#L151-L162

src/backend/storage/lmgr/lock.c#L2957-L2969

The structured evidence record records fixed messages and the source/runtime boundary.

211 - 53300 — too_many_connections

PostgreSQL reports SQLSTATE 53300 when a connection cannot be admitted because a connection limit is exhausted. Identify the role, database, or server limit and verify a fresh connection after capacity is restored.

At a glance

53300 is PostgreSQL’s too_many_connections condition in Class 53, insufficient_resources. It is emitted when a new backend cannot be admitted because a connection capacity limit has been reached. The representative case uses a role connection limit of one and opens a second session for that role.

This is a connection-startup failure. No SQL transaction is opened for the rejected session. In the final runs, psycopg reported the startup exception text but exposed sqlstate=None; the PostgreSQL collector recorded the server’s actual FATAL SQLSTATE 53300. Keep those observations separate when diagnosing a connection pool or an authentication gateway.

The case role_connection_limit passed on PostgreSQL 18.6 and the isolated PostgreSQL 10.21 target. The run IDs and per-case assertions are retained in the public evidence JSON.

Field Value
SQLSTATE 53300
Condition too_many_connections
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_TOO_MANY_CONNECTIONS
Aliases

Meaning and trigger paths

During backend startup, PostgreSQL checks the authenticated role’s rolconnlimit after creating the backend bookkeeping entry. For a non-superuser role with a nonnegative limit, a count above that limit raises FATAL with ERRCODE_TOO_MANY_CONNECTIONS and the message too many connections for role "%s". The source comments describe this role count as approximate because simultaneous startups can race.

The same SQLSTATE can identify another capacity path, such as a server-wide client limit. The role-limit case here does not establish the cause of every 53300; use the primary message, collector fields, and the configured role, database, and server limits to classify it.

Because the failure occurs before the SQL protocol reaches a transaction, transaction status is not INERROR or IDLE for the rejected session. A management or pool connection that remains open can change the limit and then prove recovery with a new session.

Messages and diagnostics

The executable excerpt uses the same role-limit SQL statements as the runner. limited_user is replaced by a disposable role in the isolated run. The second connection is a separate client-startup operation, so it is described between the SQL statements rather than represented by a fabricated SQL command.

ALTER ROLE limited_user CONNECTION LIMIT 1;
-- Keep one session open as limited_user.
-- Open a second session as limited_user: startup returns FATAL 53300.
ALTER ROLE limited_user CONNECTION LIMIT -1;
SELECT 1;

The latest target’s collector record was:

SQLSTATE: 53300                 # csvlog/jsonlog sql_state_code
severity: FATAL
message_primary: too many connections for role "<generated-role>"
source: miscinit.c / InitializeSessionUserId / line 880
driver startup sqlstate: null
transaction: none opened
repair: reset CONNECTION LIMIT; fresh role connection SELECT 1 -> 1

PostgreSQL 10.21 produced the same message and SQLSTATE in its collector, with the source location miscinit.c:575. In both targets the known role connection succeeded after the limit was reset. The role name and port above are run-generated values; the collector’s sql_state_code is the server evidence. A startup error may not expose a SQLSTATE property through a particular driver.

Diagnosis

Capture the connection parameters without secrets, the role and database, the server version, the exact startup text, and a collector record correlated by time, user, and connection source. Check pg_roles.rolconnlimit, database and server connection settings, and current backend counts. A pool can exhaust a role limit while the server still has global capacity.

Treat the role count as a capacity observation rather than an exact admission proof under a burst: PostgreSQL documents an approximate check for concurrent startups. Check the primary message before changing a global setting, and preserve an administrative path for recovery.

Do not issue transaction cleanup commands for the rejected session. It never reached a usable SQL transaction. A still-open owner or administration connection can restore the setting; the meaningful repair assertion is a fresh login for the affected role followed by a real query.

Response and repair

  • Bound pool size and connection concurrency so a role does not repeatedly exhaust its limit.
  • Increase the role, database, or server capacity only after checking memory, workload, and the intended admission policy.
  • Keep reserved capacity and a controlled administrative connection for recovery; do not grant superuser status merely to bypass a limit.
  • After changing the limit, open a new connection and execute a harmless query. Reconcile pool state and close stale sessions before retrying application work.

The representative repair reset the disposable role’s limit, opened a new role connection, and observed SELECT 1 as 1. That proves recovery of this role-limit path; it does not prove that a different database-wide or server-wide capacity failure has been repaired.

Versions and boundaries

The catalogue has a definition-presence observation for 53300 at PostgreSQL 7.4 and through the locked 8.4.22 pre-9.0 definitions, then in every listed formal snapshot through PostgreSQL 18.6 and the PostgreSQL 19 Beta 3 preview. This is a definition-only presence boundary, not an exact implementation introduction or runtime-use claim. The class title change between the 9.0 header and 9.1 text definitions is recorded in the catalogue; it is not an asserted implementation change for this condition.

The role-limit case passed on PostgreSQL 18.6 and 10.21. Source line numbers differ, and the driver/collector split is part of the observed boundary. Database-wide and server-wide capacity paths, connection pool behavior, and operating-system resource exhaustion require their own evidence.

28P01invalid_password is another connection-startup failure with no SQL transaction. 57014query_canceled is a statement interruption after a session has connected. 42P01undefined_table is a SQL name-resolution error after connection startup.

Sources

Structured evidence is recorded in the public evidence JSON. Source records are fixed to PostgreSQL commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; runtime records retain the collector output, driver observation, both target IDs, and structured observations.

212 - 53400 — configuration_limit_exceeded

Source-backed reference for PostgreSQL SQLSTATE 53400.

53400

At a glance

53400 reports that a configured or finite process slot is exhausted. Fixed paths cover background workers, logical-replication workers, and replication-origin state slots.

Field Value
SQLSTATE 53400
Condition configuration_limit_exceeded
Status active
Known present by 9.2.0
Locked snapshots 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_CONFIGURATION_LIMIT_EXCEEDED
Aliases

Meaning

The source distinguishes too many background workers, no slot for a new autovacuum/background worker, no logical-replication worker slots, and replication-origin state limits. Hints name the parameter where the path can identify one; the current setting and workload determine whether increasing it is safe.

Diagnosis

Keep the exact component and parameter from the message. Inspect worker counts, active replication, origin IDs, slots, and server logs; distinguish a worker-slot limit (53400) from a generic resource failure (53000) or a statement complexity limit (54001).

Response

Remove or finish work that legitimately holds the slot, or raise the named configuration after checking process and memory capacity. Apply the change through the normal configuration/restart or reload procedure, then verify that the requested component can start. These fixed worker, launcher, and replication-origin paths can run in background backend processes rather than a client transaction; where an ERROR reaches an explicit client transaction, use ROLLBACK or ROLLBACK TO SAVEPOINT before retrying, and in autocommit retry only after the slot cause is corrected. Do not create workers merely to force this condition.

Versions

The locked catalogue records this condition from 9.2.0; cited background-worker and logical-replication paths are PostgreSQL 18.6 source. No slot exhaustion was run.

53000, 55000, 54001

Sources

src/backend/postmaster/bgworker.c#L1002-L1009

src/backend/replication/logical/launcher.c#L435-L438

src/backend/replication/logical/origin.c#L976-L980

The structured evidence record records fixed messages and the source/runtime boundary.

213 - 54000 — program_limit_exceeded

Source-backed reference for PostgreSQL SQLSTATE 54000.

54000

At a glance

54000 is used when a concrete program, representation, or extension limit is exceeded. Fixed examples include safe allocation-size arithmetic, relation block numbering, array dimensions/size, cube dimensions, and hstore pair counts; the source path identifies the limit.

Field Value
SQLSTATE 54000
Condition program_limit_exceeded
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_PROGRAM_LIMIT_EXCEEDED
Aliases

Meaning

The condition is not a general “large value” warning. Core mcxt.c checks addition and multiplication of allocation sizes and emits invalid memory allocation request size ... on overflow; relation storage refuses a block number at InvalidBlockNumber; array construction/subscripts enforce dimension and total-size limits. Extension paths add their own ceilings: cube reports that a cube cannot have more than %d dimensions, while hstore reports actual and maximum pair counts. The operation and source path define the limit.

Diagnosis

Identify the source component and reported actual/maximum values. Check whether this is allocation-size overflow, relation growth, array dimensions/size, cube dimensions, hstore pairs, or another component. Inspect the expression or generated value that expands the request; an allocation-size overflow is a request-arithmetic problem, not proof that the host is out of RAM.

Response

Reduce the requested size, dimension, block growth, or pair count; split the value or choose a representation whose documented limit fits the requirement. For relation limits, redesign or partition storage before retrying. If an ERROR occurs inside an explicit transaction, use ROLLBACK or ROLLBACK TO SAVEPOINT before retrying; in autocommit, retry only after the request fits the named program limit. Do not discard elements silently or “fix” arithmetic overflow by blindly raising an unrelated memory setting; preserve the business rule for truncation or decomposition.

Versions

The locked catalogue records this condition from 7.4; cited core and extension paths are PostgreSQL 18.6 source. No limit was forced and no oversized extension value was created.

54011, 54023, 22000

Sources

contrib/cube/cube.c#L162-L166

contrib/hstore/hstore_io.c#L522-L525

src/backend/utils/mmgr/mcxt.c#L1683-L1718

src/backend/storage/smgr/md.c#L493-L504

src/backend/utils/adt/arraysubs.c#L147-L152

The structured evidence record records fixed messages and the source/runtime boundary.

214 - 54001 — statement_too_complex

Source-backed reference for PostgreSQL SQLSTATE 54001.

54001

At a glance

54001 covers a statement that exceeds a planner, parser, or execution-stack limit. Fixed paths include the 4096 grouping-set ceiling and max_stack_depth enforcement.

Field Value
SQLSTATE 54001
Condition statement_too_complex
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_STATEMENT_TOO_COMPLEX
Aliases

Meaning

The source separates a structural query limit (too many grouping sets present (maximum 4096)) from recursive execution depth (stack depth limit exceeded) with a hint naming max_stack_depth. They need different repairs: reducing query structure is not the same as changing a stack setting.

Diagnosis

Preserve the message and phase. For grouping sets, count the generated grouping sets and simplify the query. For stack depth, inspect recursive SQL/function expansion and compare the setting with the platform stack limit before changing it.

Response

Rewrite or decompose a structurally excessive statement. For stack depth, remove unintended recursion or reduce nesting; change max_stack_depth only after checking the operating-system stack allowance and operational policy. If this ERROR occurs inside an explicit transaction, use ROLLBACK or ROLLBACK TO SAVEPOINT before retrying; in autocommit, retry only after the statement or stack setting is corrected. The GUC rlimit check validates a SET or configuration value against the platform allowance; a failed SET still follows the transaction context that issued it. Validate the rewritten statement rather than automatically replaying it.

Versions

The locked catalogue records this condition from 7.4; cited parser and stack-depth paths are PostgreSQL 18.6 source. No complexity limit was forced.

54000, 54011, 42601

Sources

src/backend/parser/parse_agg.c#L1166-L1172

src/backend/utils/misc/stack_depth.c#L100-L105

src/backend/utils/misc/stack_depth.c#L156-L168

The structured evidence record records fixed messages and the source/runtime boundary.

215 - 54011 — too_many_columns

Source-backed reference for PostgreSQL SQLSTATE 54011.

54011

At a glance

54011 reports that a physical tuple descriptor or a related object definition exceeds its fixed column limit. The source path determines whether the count is for table attributes, index keys plus INCLUDE columns, partition keys, statistics dimensions, or a row-producing definition.

Field Value
SQLSTATE 54011
Condition too_many_columns
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_TOO_MANY_COLUMNS
Aliases

Meaning

Fixed messages include number of columns (%d) exceeds limit (%d), tables can have at most %d columns, cannot use more than %d columns in an index, cannot partition using more than %d columns, and statistics-specific forms. Table counts operate on physical attribute numbers: a dropped column still occupies a tuple-descriptor slot, so the visible-column count can be lower than relnatts. Index key and INCLUDE entries, partition keys, and statistics dimensions use separate limits even though all use this SQLSTATE.

In the locked 18.6 build, the relevant constants are MaxHeapAttributeNumber = 1600 user table attributes, MaxTupleAttributeNumber = 1664 tuple attributes, INDEX_MAX_KEYS = 32, PARTITION_MAX_KEYS = 32, and STATS_MAX_DIMENSIONS = 8. These values belong to different guards; the actual count and limit fields in a server diagnostic remain authoritative.

Diagnosis

Read the object type, actual count, maximum, and DDL operation from the message and context. For a table or inherited table, inspect pg_class.relnatts and pg_attribute, including attisdropped, rather than counting only visible names. For an index include INCLUDE columns in the DDL count; for partitioning and extended statistics use their own key/dimension counts. A function-in-FROM column definition list is another 54011 path with a row-shape limit.

Response

Reduce or split the object definition, use a different index or partitioning design, or move derived data to a related table. If dropped physical slots are the cause, dropping another visible column will not reclaim them; an ordinary physical rewrite such as VACUUM FULL or CLUSTER also keeps the dropped attributes in the tuple descriptor. Plan a new table with the intended logical column layout, migrate data while preserving dependencies, and validate DDL against the named object limit. If an ERROR occurs inside an explicit transaction, use ROLLBACK or ROLLBACK TO SAVEPOINT before retrying; in autocommit, retry only after the schema change removes the actual limit.

Versions

The locked catalogue records this condition from 7.4; cited heap, index, table, partition, statistics, and row-shape paths are PostgreSQL 18.6 source. No oversized schema was created.

54000, 54023, 54001

Sources

src/backend/access/common/heaptuple.c#L1131-L1134

src/backend/access/common/indextuple.c#L87-L90

src/backend/catalog/heap.c#L461-L464

src/backend/commands/tablecmds.c#L2567-L2582

src/backend/commands/indexcmds.c#L640-L664

src/backend/commands/statscmds.c#L215-L224

src/backend/parser/parse_relation.c#L1935-L1946

src/include/access/htup_details.h#L34-L48

src/include/pg_config_manual.h#L63-L74

src/include/statistics/statistics.h#L19

The structured evidence record records fixed messages and the source/runtime boundary.

216 - 54023 — too_many_arguments

Source-backed reference for PostgreSQL SQLSTATE 54023.

54023

At a glance

54023 is the argument-count limit for functions, procedures, aggregates, and set-returning calls. Fixed paths protect catalog arrays, parser nodes, and executor FunctionCallInfo storage, and report the actual compile-time limit with plural-aware messages.

Field Value
SQLSTATE 54023
Condition too_many_arguments
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_TOO_MANY_ARGUMENTS
Aliases

Meaning

The fixed build defines FUNC_MAX_ARGS as 100 in pg_config_manual.h; the source notes a practical upper bound near 600 and requires a full backend (including C functions) recompile if it changes. Function definitions count input parameters and explicitly do not count output arguments. Aggregate definitions and aggregate calls use FUNC_MAX_ARGS - 1 so transition/final functions remain representable. Procedure/function parser and executor guards cover explicit arguments plus default arguments, SRFs, and stored window expressions. The caller and object kind determine the repair.

Messages

Source path Exact primary template (singular / plural) Count passed to %d
pg_proc.c function definition functions cannot have more than %d argument / functions cannot have more than %d arguments Compare parameterCount (the input-parameter array length; output parameters are excluded) with FUNC_MAX_ARGS; %d receives FUNC_MAX_ARGS (100)
functioncmds.c procedure call cannot pass more than %d argument to a procedure / cannot pass more than %d arguments to a procedure Compare nargs = list_length(fexpr->args) with FUNC_MAX_ARGS; %d receives FUNC_MAX_ARGS
parse_func.c, execExpr.c, execSRF.c, and nodeWindowAgg.c function/SRF/window call cannot pass more than %d argument to a function / cannot pass more than %d arguments to a function Compare list_length(fargs), nargs, list_length(sexpr->args), or perfuncstate->numArguments with FUNC_MAX_ARGS; %d receives FUNC_MAX_ARGS
pg_aggregate.c aggregate definition/call aggregates cannot have more than %d argument / aggregates cannot have more than %d arguments Compare numArgs with FUNC_MAX_ARGS - 1; %d receives 99, leaving a slot for transition/final functions

These are errmsg_plural groups, so clients should preserve the server’s singular/plural rendering and the reported limit instead of searching only for one hand-written string.

Diagnosis

Record whether the failure is CREATE/definition time or invocation time, and whether the object is a function, procedure, aggregate, SRF, or window aggregate. Count explicit arguments and parser-expanded defaults; for an aggregate use the stricter FUNC_MAX_ARGS - 1 boundary. Preserve the exact singular/plural primary and maximum from the message, and check whether a stored view/plan was made by a binary with a different FUNC_MAX_ARGS.

Response

Reduce the argument list, group related values into a composite or documented record type, or redesign the function boundary. For a procedure or aggregate definition, change the signature and dependent callers together; do not silently drop arguments, count output arguments as inputs, or assume aggregate and ordinary-function calls share the same limit. Changing FUNC_MAX_ARGS is a build-wide compatibility decision, not a session setting. If an ERROR occurs inside an explicit transaction, use ROLLBACK or ROLLBACK TO SAVEPOINT before retrying; in autocommit, retry only after the definition or call has been changed to fit the fixed count.

Versions

The locked catalogue records this condition from 7.4; cited macro, catalog, parser, executor, aggregate, and SRF paths are PostgreSQL 18.6 source. No oversized signature or call was created.

54011, 54000, 42883

Sources

src/backend/catalog/pg_proc.c#L156-L161

src/backend/commands/functioncmds.c#L2261-L2266

src/backend/executor/execExpr.c#L2727-L2732

src/backend/executor/execSRF.c#L716-L721

src/include/pg_config_manual.h#L31-L43

src/backend/catalog/pg_aggregate.c#L121-L132

src/backend/parser/parse_func.c#L129-L142

src/backend/executor/nodeWindowAgg.c#L1042-L1054

The structured evidence record records fixed messages and the source/runtime boundary.

217 - 55000 — Object not in prerequisite state

PostgreSQL SQLSTATE 55000: Object not in prerequisite state (object_not_in_prerequisite_state), source-backed diagnosis and recovery guidance.

55000 — Object not in prerequisite state

At a glance

55000 means the requested operation lacks a required object or server state. This page selects the session-local sequence prerequisite behind currval; preload, recovery, and invalid-index paths are separate mechanisms.

Field Value
SQLSTATE 55000
Condition object_not_in_prerequisite_state
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE
Aliases

Meaning

currval is defined per backend session. Creating a sequence, or calling nextval in another session, does not initialize the current session. The fixed sequence template is currval of sequence "%s" is not yet defined in this session with ERROR severity.

Other fixed 55000 paths have different prerequisites. pg_stat_statements reports pg_stat_statements must be loaded via "shared_preload_libraries"; add the extension to that startup setting and restart the server through the normal configuration procedure. pg_surgery reports recovery is in progress with detail Heap surgery functions cannot be executed during recovery.; wait for recovery to finish or run the operation on the appropriate writable primary. pgstattuple reports index "%s" is not valid; inspect the index and rebuild it with the appropriate REINDEX or migration procedure before using that function. These are object or server-state checks, not permission failures and not interchangeable with the session-local sequence case.

Diagnosis

Check the exact object state and the backend session that owns it. For this path, identify the sequence and verify whether this backend has called nextval; a pooled connection that ran nextval is a different prerequisite state. In an explicit transaction, a failed currval aborts the transaction, so issue ROLLBACK or ROLLBACK TO SAVEPOINT before repairing it. For other 55000 paths inspect recovery, preload settings, index validity, or object-specific prerequisites.

Response

Call nextval in the same backend before currval, or pass an explicitly known value when that is the intended contract. In autocommit, reconnecting or issuing the next statement is possible because the failed statement’s transaction has ended; inside an explicit transaction, recover with a rollback or savepoint before calling nextval. Do not treat this as a privilege failure or assume a successful call from a pool’s different connection initializes the current one.

Observed diagnostics

The selected source group is ERROR with the dynamic sequence-name template above. Runtime diagnostics named currval_sequence; after the failure the autocommit session stayed IDLE, and the same session then returned 10 from nextval and currval.

Representative case

The selected registry creates the sequence and then, on one autocommit backend, calls currval before any nextval, initializes the sequence with nextval (returning 10), and reads currval again (returning 10). The failing call, repair, and verification are therefore one session-scoped state transition; this case does not test a connection-pool handoff.

CREATE SEQUENCE sequence_identifier START WITH 10;
SELECT currval('sequence_regclass');
SELECT nextval('sequence_regclass');
SELECT currval('sequence_regclass')

The selected PostgreSQL 18.6 and 10.21 runs passed SQLSTATE, severity, state or disconnect recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence.

Versions

The locked catalogue records 55000 from 7.4 through the listed snapshots. The sequence-session case passed on 18.6 and 10.21; these observations do not cover the other 55000 branches or infer every intermediate implementation.

Sources

  • src.errcodes.18.6src/backend/utils/errcodes.txt at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.currval.18.6src/backend/commands/sequence.c at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 3e5afe17d5a84862fae502a5481211220368f1d639e9d07ba6f96ee8be92a8d8 (source).
  • src.currval.10.23src/backend/commands/sequence.c at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 5510e1266e8d8c548a4318d753392e92e689d348f3353a2aa53d8dea871c44ab (source).
  • src.path.0contrib/pg_stat_statements/pg_stat_statements.c at 724edf9bde9d356724ad384a2e196edc3c9f80f7, the shared_preload_libraries guard (source).
  • src.path.1contrib/pg_surgery/heap_surgery.c at 724edf9bde9d356724ad384a2e196edc3c9f80f7, the recovery guard and detail (source).
  • src.path.2contrib/pgstattuple/pgstatindex.c at 724edf9bde9d356724ad384a2e196edc3c9f80f7, the invalid-index guard (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.55000 / snippet-registry.55000 — hashes are recorded in evidence/55000.json and each selected runtime record.

218 - 55006 — Object in use

PostgreSQL SQLSTATE 55006: Object in use (object_in_use), source-backed diagnosis and recovery guidance.

55006 — Object in use

At a glance

55006 reports that the requested object operation conflicts with active use. This page selects a same-session cursor holding a table in an explicit transaction; database users, logical replication, and pending trigger-event branches are distinct.

Field Value
SQLSTATE 55006
Condition object_in_use
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_OBJECT_IN_USE
Aliases

Meaning

The selected table-command template is cannot %s "%s" because it is being used by active queries in this session. Its relation reference count covers an active portal or scan in the same backend, rather than a generic permission problem. The same table-use guard has a separate cannot %s "%s" because it has pending trigger events branch for AFTER-trigger work in the current transaction. Other 55006 messages identify different blockers such as users of a database or a logical replication slot.

Diagnosis

Identify the object and the exact session or server state holding the use. In this case inspect the explicit transaction and named cursor; for pending trigger events, finish or roll back the transaction that queued them. For database or replication variants inspect pg_stat_activity, slots, subscriptions, and maintenance ownership before terminating anything. A cursor owned by this backend is not the same blocker as another user’s backend or a logical replication slot.

Response

Rollback the failed explicit transaction so its transaction-owned cursor and pending trigger work are released, then repeat the DDL in a deliberate maintenance boundary. For a database-user blocker, coordinate with the owning sessions; for a logical slot, resolve the subscription/slot lifecycle. Do not use CASCADE or terminate unrelated sessions as a generic response.

Observed diagnostics

The selected source group emits ERROR with dynamic operation and relation names. The runtime primary was cannot DROP TABLE "cursor_drop_table" because it is being used by active queries in this session; it entered INERROR, then rollback restored IDLE.

Representative case

The registry creates an empty table, begins a transaction, declares and fetches a named cursor, and attempts DROP TABLE on that same backend. The cursor is active even without rows, so this is the same-session active-query branch. After the real 55006, the handler rolls back, drops the table again on the same connection, and verifies that the relation is gone. This selected case does not stand in for another database user, a logical replication slot, or a pending AFTER-trigger event.

CREATE TABLE cursor_drop_table(id integer PRIMARY KEY);
BEGIN;
DECLARE active_cursor CURSOR FOR SELECT id FROM cursor_drop_table;
FETCH active_cursor;
DROP TABLE cursor_drop_table;
ROLLBACK;
DROP TABLE cursor_drop_table;
SELECT to_regclass('cursor_drop_table_regclass')

The selected PostgreSQL 18.6 and 10.21 runs passed SQLSTATE, severity, state or disconnect recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence.

Versions

The locked catalogue records 55006 from 7.4 through the listed snapshots. The active-cursor DDL case passed on 18.6 and 10.21; it does not establish behavior for database, replication, or pending-trigger branches.

Sources

  • src.errcodes.18.6src/backend/utils/errcodes.txt at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.active-cursor.18.6src/backend/commands/tablecmds.c at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9 (source).
  • src.pending-trigger.18.6 — the same tablecmds.c guard checks pending AFTER-trigger events and emits cannot %s "%s" because it has pending trigger events at lines 4439-4444 (source).
  • src.active-cursor.10.23src/backend/commands/tablecmds.c at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 6de441c88496c6cf57a836898388085ec08bf69afd70d07acdafd6089b9b5f8c (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.55006 / snippet-registry.55006 — hashes are recorded in evidence/55006.json and each selected runtime record.

219 - 55P02 — cant_change_runtime_param

Source-backed reference for PostgreSQL SQLSTATE 55P02.

55P02

At a glance

55P02 means that PostgreSQL rejected a runtime-parameter change because the GUC context or lifecycle phase does not permit that operation. The same condition name covers restart-only, SIGHUP-only, backend-start, internal, and binary-upgrade guards.

Field Value
SQLSTATE 55P02
Condition cant_change_runtime_param
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_CANT_CHANGE_RUNTIME_PARAM
Aliases

Meaning

set_config_with_handle() calls ereport(elevel, ...), so the client-visible severity follows the caller: a SQL SET normally uses ERROR, while configuration-file/database-setting paths may use LOG or WARNING. The guard first checks the GUC context. Internal parameters cannot be changed by an ordinary caller; PGC_POSTMASTER parameters require a restart; PGC_SIGHUP parameters reject a session-only change with parameter "%s" cannot be changed now; and backend or superuser-backend parameters reject a late change with parameter "%s" cannot be set after connection start. The same restart message is also used when a reload would change a postmaster value, and ALTER SYSTEM rejects parameters that cannot be placed in its configuration file.

A separate pg_upgrade_support.c guard uses this SQLSTATE when a binary-upgrade helper is called while IsBinaryUpgrade is false. That path is an internal administrative precondition, not a regular pg_settings.context decision.

Messages

  • Internal or configuration-file rejection: primary parameter "%s" cannot be changed; the set_config_with_handle() caller supplies the severity, while the ALTER SYSTEM guard uses ERROR.
  • Restart-only parameter: primary parameter "%s" cannot be changed without restarting the server; the caller supplies the severity.
  • SIGHUP-only parameter changed in a session: primary parameter "%s" cannot be changed now; the caller supplies the severity.
  • Backend-start parameter changed after connection start: primary parameter "%s" cannot be set after connection start; the caller supplies the severity.
  • Binary-upgrade helper outside binary-upgrade mode: primary function can only be called when server is in binary upgrade mode, ERROR.

Diagnosis

Record the parameter name, exact primary message, source (SET, startup option, configuration reload, database/role setting, ALTER SYSTEM, or binary-upgrade helper), and the server phase. Check pg_settings.context, pg_settings.pending_restart, pg_settings.source, and pg_settings.sourcefile; a postmaster context points to restart, sighup to reload, and backend to a new session. A value-format problem has a different SQLSTATE and should not be diagnosed from 55P02.

For a user SET, an ERROR aborts the current explicit transaction. For a configuration reload or background path, the same format may be logged or reported as a warning and does not imply a client transaction was aborted; use the reported severity and connection state.

Response

Apply the change through the context named by pg_settings: use configuration and restart for restart-only values, reload SIGHUP values, pass backend-start values through a new connection, and leave internal or binary-upgrade-only parameters to their owning mechanism. In an explicit transaction, issue ROLLBACK or ROLLBACK TO SAVEPOINT after a failed SQL SET before sending further commands. In autocommit, correct the lifecycle or source first and retry the setting; do not blindly repeat the same rejected operation. Confirm the effective value after the transition.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6. The known present by value is a catalogue boundary, not an exact implementation-introduction claim.

55P03, 57P03, 42501

Sources

src/backend/utils/misc/guc.c#L3407-3428

src/backend/utils/misc/guc.c#L3477-3512

src/backend/utils/misc/guc.c#L3550-3581

src/backend/utils/adt/pg_upgrade_support.c#L32-39

src/backend/utils/misc/guc.c#L4691-4694

The structured evidence record records fixed messages, caller-severity boundaries, and the source/runtime scope.

220 - 55P03 — lock_not_available

Source-backed full entry for PostgreSQL SQLSTATE 55P03.

55P03

At a glance

55P03 reports that a requested lock could not be obtained under the operation’s selected wait policy. Fixed paths cover row locks, relation locks, LOCK TABLE, lock_timeout, and maintenance commands that skip work.

Field Value
SQLSTATE 55P03
Condition lock_not_available
Status active
Known present by 8.0.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_LOCK_NOT_AVAILABLE
Aliases

Meaning

Row-lock callers use LockWaitError and ConditionalXactLockTableWait()/ConditionalMultiXactIdWait() to fail immediately with could not obtain lock on row in relation "%s". Relation and LOCK TABLE callers use ConditionalLockRelationOid() and report a relation variant. A lock_timeout interrupt is another ERROR path, canceling statement due to lock timeout; it means the wait exceeded the configured timeout, not that NOWAIT was requested.

VACUUM and ANALYZE use the same SQLSTATE when they cannot acquire their relation lock, but their ereport(elevel) is deliberately non-ERROR: ordinary maintenance reports a WARNING, and an autovacuum verbose path can use LOG. The command skips that object and continues, so a warning is not an aborted transaction.

Diagnosis

Keep the complete primary message, severity, relation or row name, lock mode, and statement. Inspect pg_stat_activity, pg_locks, blocker PIDs, transaction age, and whether the statement used NOWAIT, lock_timeout, or a maintenance command. Do not turn a skipped VACUUM/ANALYZE warning into a failed DML diagnosis.

The accepted row-lock case used a separate blocker and an autocommit contender. In an explicit transaction, a lock ERROR leaves the session INERROR until ROLLBACK or ROLLBACK TO SAVEPOINT; the accepted autocommit contender remained IDLE after its failed statement.

Response

Coordinate or release the blocker, or choose a deliberate wait/timeout/skip policy. For an ERROR in an explicit transaction, roll back the whole transaction or to an existing savepoint before issuing more SQL; verify which work was committed before replaying. In autocommit, change the blocking or timeout condition first, then retry the statement with an idempotency rule. For a maintenance WARNING/LOG, record the skipped relation and run maintenance later; do not issue ROLLBACK for a command that did not abort the transaction.

Observed diagnostics

The selected registry created a blocker holding SELECT ... FOR UPDATE in an explicit transaction and an autocommit contender issuing FOR UPDATE NOWAIT. PostgreSQL 18.6 and 10.21 returned ERROR / 55P03 with could not obtain lock on row in relation "nowait_rows"; the contender stayed IDLE. After the blocker rolled back, the same contender updated marker to repaired and verified it.

Representative case

The SQL is a role-labelled registry excerpt. Setup is run once; blocker and contender must be separate sessions. It covers the row-lock NOWAIT branch only, not lock_timeout or the maintenance skip branches.

-- setup (one maintenance session)
CREATE TABLE nowait_rows(id integer PRIMARY KEY, marker text NOT NULL);
INSERT INTO nowait_rows VALUES (1, 'seed');

-- blocker session: keep this transaction open
BEGIN;
SELECT id FROM nowait_rows WHERE id = 1 FOR UPDATE;

-- contender session, autocommit on: this is the 55P03 operation
SELECT id FROM nowait_rows WHERE id = 1 FOR UPDATE NOWAIT;

-- blocker session
ROLLBACK;

-- contender session after the blocker is released
UPDATE nowait_rows SET marker = 'repaired' WHERE id = 1 RETURNING marker;
SELECT marker FROM nowait_rows WHERE id = 1;

The passed case confirms this row-lock mechanism, its ERROR/IDLE boundary, and its repair step only; it does not prove that every lock mode or maintenance command has the same severity.

Versions

The locked catalogue records this condition from 8.0.0; fixed source coverage is PostgreSQL 18.6. The accepted runtime was observed on PostgreSQL 18.6 and 10.21.

55P02, 40001, 57014

Sources

src/backend/access/heap/heapam.c#L5178-5210

src/backend/catalog/namespace.c#L585-610

src/backend/tcop/postgres.c#L3420-3444

src/backend/commands/lockcmds.c#L130-145

src/backend/commands/vacuum.c#L835-880

The structured evidence record records fixed message roles, maintenance severity, and accepted runtime artifacts.

221 - 55P04 — unsafe_new_enum_value_usage

Source-backed reference for PostgreSQL SQLSTATE 55P04.

55P04

At a glance

55P04 protects the commit-before-use rule for a newly added enum value. It is raised after PostgreSQL has found an enum tuple that is still uncommitted and marked as unsafe, not because the label has invalid syntax.

Field Value
SQLSTATE 55P04
Condition unsafe_new_enum_value_usage
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_UNSAFE_NEW_ENUM_VALUE_USAGE
Aliases

Meaning

The fixed enum.c guard first accepts a tuple already hinted committed, then checks the tuple’s transaction ID. It also accepts a value not listed by EnumUncommitted(), because such a value cannot outlive its owning type. Only the remaining uncommitted value is rejected with the exact primary, detail, and hint below. Thus an ALTER TYPE ... ADD VALUE and a use of that new label in one uncommitted transaction can reach 55P04, while an already committed label does not.

Messages

  • Primary template: unsafe use of new value "%s" of enum type %s
  • Detail: none in this call group.
  • Hint: New enum values must be committed before they can be used.

The %s values are the enum label and formatted enum type name from the tuple; they are diagnostic data, not a value-format recipe.

Diagnosis

Preserve the enum label, type name, SQLSTATE, severity, and transaction status. Check whether the value was added earlier in the same still-open transaction and whether the failed use is an enum input/cast or another expression that resolves the enum value. Distinguish this guard from an invalid enum label (22P02); 22P04 is a COPY file-format condition, not this enum guard. Also distinguish a duplicate ADD VALUE operation.

Response

First recover the transaction after the ERROR: issue ROLLBACK, or use an appropriate ROLLBACK TO SAVEPOINT when the savepoint was placed so the earlier ADD VALUE remains. Do not use the label while the addition is still uncommitted. If a full rollback or savepoint rollback discarded the ADD VALUE, issue it again in a new transaction and COMMIT; if a savepoint preserved it, commit that transaction before using the label. Then start or continue a transaction that can see the committed catalog row. In autocommit, fix the commit boundary and retry the input; do not retry the same uncommitted sequence.

Versions

The locked catalogue records this condition from 12.0; fixed source coverage is PostgreSQL 18.6. The catalogue boundary does not assert that the guard had no earlier private or unresolved form.

22P02, 25006, 23505

Sources

src/backend/utils/adt/enum.c#L68-102

The structured evidence record records the exact guard and message group; no natural runtime case is claimed.

222 - 57000 — operator_intervention

Source-backed reference entry for PostgreSQL SQLSTATE 57000.

57000

At a glance

57000 is the SQLSTATE Class 57 condition operator_intervention. The fixed 18.6 definition is present, but the bounded report/call scan did not resolve a core emitting call for this exact code. The page therefore keeps the mechanism, message, severity, and recovery boundary unresolved rather than assigning it to shutdown, timeout, or cancellation.

Field Value
SQLSTATE 57000
Condition operator_intervention
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_OPERATOR_INTERVENTION
Aliases

Meaning

The condition name identifies an operator-intervention category, not a unique server phase. The fixed scan result is a bounded negative finding: it does not prove that no extension, future source path, or unresolved indirection can emit 57000. No primary/detail/hint template is asserted from the fixed source, and no runtime observation is claimed.

Diagnosis

Preserve the complete diagnostic from the provider: primary, detail, hint, severity, SQLSTATE, server version, connection state, and server-log correlation. Classify the concrete path from that message and surrounding logs. Do not infer administrator shutdown, statement cancellation, lock timeout, or startup refusal from the class name alone; those have distinct conditions and source paths.

Response

Follow the operator or extension instruction carried by the actual response. If the session remains usable, resolve the named intervention and check whether an explicit transaction is still active; if the response is ERROR, issue ROLLBACK or ROLLBACK TO SAVEPOINT as appropriate before continuing. In autocommit, correct the cause before retrying. If the connection was terminated, reconnect only after server readiness and verify the business result before replaying a non-idempotent operation. The bounded scan supplies no more specific repair.

Versions

The locked catalogue records this condition from 7.4; that catalogue boundary does not prove the exact implementation-introduction version. Fixed source coverage is PostgreSQL 18.6, with a bounded report/call scan only.

55P03, 57P01, 57014

Sources

src/backend/utils/errcodes.txt#L433

The structured evidence record records the fixed definition, bounded scan artifact, and source/runtime boundary.

223 - 57014 — query_canceled

PostgreSQL reports SQLSTATE 57014 when a running statement is canceled, including by statement_timeout. Classify the cancel source, verify transaction state, and confirm that a follow-up operation is safe.

At a glance

57014 is PostgreSQL’s query_canceled condition in Class 57, operator_intervention. It indicates that the server interrupted a statement. The same SQLSTATE covers several cancellation sources, so the primary message and server context are needed to distinguish a statement timeout, an explicit client cancel, a recovery conflict, or another administrative path.

The representative case sets statement_timeout to 100 ms and executes pg_sleep(1). PostgreSQL returns canceling statement due to statement timeout; the autocommit connection remains IDLE, and a subsequent SELECT 1 returns 1. This proves the timeout path and connection usability for this case, not that every canceled command has no side effects or the same transaction state.

Run 57014-registry-final-20260909 passed on PostgreSQL 18.6 and isolated PostgreSQL 10.21. The per-target assertions and structured observations are retained in the public evidence JSON.

Field Value
SQLSTATE 57014
Condition query_canceled
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_QUERY_CANCELED
Aliases

Meaning and trigger paths

statement_timeout starts a timer for each statement and asks the backend to process an interrupt when the budget expires. In the fixed source path, ProcessInterrupts emits ERRCODE_QUERY_CANCELED with canceling statement due to statement timeout. A client cancel uses the same SQLSTATE with canceling statement due to user request; lock timeout and some recovery paths use their own message or detail.

Cancellation stops the current statement at an interruptible point. It is not a general assertion that all work associated with a request has ceased, that an external side effect was undone, or that a transaction is usable without rollback. The transaction boundary, statement type, and cancellation source determine what must be cleaned up.

Messages and diagnostics

The representative operation is a dedicated autocommit connection with a 100 ms timeout:

SET statement_timeout = '100ms';
SELECT pg_sleep(1);
SELECT 1;

PostgreSQL 18.6 returned:

SQLSTATE: 57014
severity: ERROR
message_primary: canceling statement due to statement timeout
source: postgres.c / ProcessInterrupts / line 3446

PG10 returned the same primary message with source line 3018. There is no universal detail template for 57014; preserve message_detail, message_hint, context, and the statement that was interrupted when present.

Diagnosis

Record SQLSTATE, severity, primary message, detail, hint, context, backend PID, statement text, timeout settings, and the source of cancellation. Distinguish statement_timeout from lock_timeout, a client cancel, an administrator request, and a standby recovery conflict. Search server logs with the SQLSTATE and backend PID when the client diagnostic is incomplete.

Check transaction status after the error. The autocommit timeout case was IDLE and accepted SELECT 1; an error inside an explicit transaction may leave it INERROR and require rollback. If the interrupted statement changed rows before an error, verify the database state rather than assuming a request-level rollback outside the current transaction.

Response and repair

Tune the operation and its budget based on the cause:

  • Optimize or batch an overlong query, and set a timeout that matches the work’s service-level budget.
  • Handle a client or administrative cancel as a control decision, then inspect whether the application should retry.
  • Resolve lock contention separately when the message identifies lock timeout; increasing statement timeout does not repair a lock queue.
  • Roll back an aborted explicit transaction before issuing unrelated commands, and verify any external work whose lifetime is not controlled by PostgreSQL.

The representative follow-up query returned 1 with the connection IDLE. That is the repair assertion for this autocommit sleep case; it is not a promise that a canceled write, cursor, or transaction can always be resumed in place.

Versions and boundaries

The catalogue has a definition-presence observation for 57014 at PostgreSQL 7.4 and through the locked 8.4.22 pre-9.0 definitions, then in every listed formal snapshot through PostgreSQL 18.6 and the PostgreSQL 19 Beta 3 preview. This is a definition-only presence boundary, not an exact implementation introduction or runtime-use claim. No condition definition change is recorded in the scanned range.

The statement-timeout case passed on PostgreSQL 18.6 and 10.21. The SQLSTATE is shared by other cancellation mechanisms whose messages and transaction effects differ, so this evidence is limited to a server-side statement timeout on an autocommit connection.

40P01deadlock_detected is resolved by the lock manager as a cycle, not by a timeout budget. 53300too_many_connections is a startup capacity failure. 42P01undefined_table is a parse-time name error. 25P02in_failed_sql_transaction can follow a cancellation when the surrounding explicit transaction is aborted.

Sources

Structured evidence is recorded in the public evidence JSON. Source records are fixed to PostgreSQL commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; runtime records retain both target IDs and structured observations.

224 - 57P01 — admin_shutdown

Source-backed full entry for PostgreSQL SQLSTATE 57P01.

57P01

At a glance

57P01 is a server-initiated administrative-shutdown condition. Fixed core paths cover orderly or immediate client termination, worker/parallel termination, and a synchronous-replication wait that explicitly says the transaction has already committed locally but might not have been replicated to the standby.

Field Value
SQLSTATE 57P01
Condition admin_shutdown
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_ADMIN_SHUTDOWN
Aliases

Meaning

The SQLSTATE is reused at several lifecycle boundaries, so severity and recovery depend on the call site. The immediate-stop signal path sends a client-only WARNING and then exits without normal cleanup; the ordinary client administrator-command path uses FATAL. The synchronous-replication path uses WARNING and includes the detail The transaction has already committed locally, but might not have been replicated to the standby. That warning is followed by connection termination. Parallel and worker paths use their own FATAL or worker control flow. These are not interchangeable statements about whether a business operation committed.

Messages

  • Immediate stop: primary terminating connection due to immediate shutdown command, severity WARNING_CLIENT_ONLY; the process exits after reporting.
  • Client backend administrator command: primary terminating connection due to administrator command, severity FATAL; the connection closes.
  • Synchronous replication wait: primary canceling the wait for synchronous replication and terminating connection due to administrator command, severity WARNING, detail The transaction has already committed locally, but might not have been replicated to the standby.
  • Parallel transaction: primary postmaster exited during a parallel transaction, severity FATAL.
  • Another fixed promotion wait branch reports terminating connection due to unexpected postmaster exit at FATAL with context while waiting on promotion.

Diagnosis

Correlate the complete primary/detail/context, backend PID, administrator or postmaster action, server shutdown/recovery log, and transaction boundary. The selected runtime case covers only the client-backend administrator-command branch. It does not prove the immediate-stop, synchronous-replication, worker, parallel, or promotion outcomes. When the synchronous-replication detail appears, the transaction has already committed locally while remote standby replication is uncertain; query durable state and replication status before replaying a non-idempotent operation. The warning path still terminates the connection, so the old session cannot be used for recovery.

Response

For a FATAL or client-only shutdown report, the connection is not a transaction recovery point: wait for readiness, open a fresh connection, and inspect durable business state or an idempotency key before retrying. For the synchronous-replication branch, preserve the warning, record that local commit has already occurred, and determine standby receipt separately; the connection is still terminated after the warning. Do not assume any 57P01 path leaves a live session for recovery. The accepted case’s fresh SELECT 1 proves readiness after terminating the targeted victim, not that an interrupted business operation committed.

Observed diagnostics

The selected registry created a runner-owned victim client backend, a distinct administrator session, and a fresh session on PostgreSQL 18.6 and 10.21. The admin verified the target identity and pg_terminate_backend returned true. The victim driver reported FATAL / 57P01 with terminating connection due to administrator command and closed; the fresh session returned 1 and was IDLE. This bounded case does not cover the other source branches or business commit outcome.

Representative case

Use only the PID returned by the case-created victim session; never substitute an arbitrary production PID or the administrator’s own PID. The fresh probe verifies server reachability after the targeted termination. Check durable business state or an idempotency key before replaying a non-idempotent request.

-- victim session created by the case runner
SELECT pg_backend_pid();  -- save as :victim_pid
SELECT 1;                 -- probe before termination

-- admin session; record its own PID, then use only the runner-created victim PID
SELECT pg_backend_pid(); -- save as :admin_pid
SELECT pid, backend_type FROM pg_stat_activity WHERE pid = backend_pid;
SELECT pg_terminate_backend(backend_pid);

-- fresh session after the victim disconnects
SELECT 1;

Versions

The locked catalogue records this condition from 7.4; that catalogue boundary does not prove the exact implementation-introduction version. Fixed source coverage is PostgreSQL 18.6, with the selected runtime case also observed on PostgreSQL 10.21.

57P02, 57P03, 40001

Sources

src/backend/tcop/postgres.c#L2974-3001

src/backend/tcop/postgres.c#L3354-3356

src/backend/replication/syncrep.c#L283-305

src/backend/access/transam/parallel.c#L932-940

src/backend/access/transam/xlogfuncs.c#L737-741

The structured evidence record records fixed branches and the bounded runtime case.

225 - 57P02 — crash_shutdown

Source-backed reference entry for PostgreSQL SQLSTATE 57P02.

57P02

At a glance

57P02 is the crash-shutdown path. When a crash-and-restart cycle is in progress, the backend sends a client-only WARNING describing the postmaster command to roll back and exit, then exits without running normal cleanup callbacks because shared memory may be corrupted.

Field Value
SQLSTATE 57P02
Condition crash_shutdown
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_CRASH_SHUTDOWN
Aliases

Meaning

The fixed primary is terminating connection because of crash of another server process. Its detail says the postmaster ordered rollback and exit because another server process exited abnormally and possibly corrupted shared memory; its hint says to reconnect in a moment. The source uses WARNING_CLIENT_ONLY rather than FATAL so the signal handler can report to the client before forcing the process exit. The connection nevertheless closes, and no ordinary session-level recovery command can be sent afterward.

Messages

  • Primary: terminating connection because of crash of another server process.
  • Detail: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
  • Hint: In a moment you should be able to reconnect to the database and repeat your command.
  • Severity source: WARNING_CLIENT_ONLY, a client-visible warning that is not sent to the server log; process exit follows the report. It is therefore not a claim that this path is a recoverable statement-level WARNING.

Diagnosis

Correlate the SQLSTATE and full diagnostic with postmaster crash/recovery logs, backend PID, and the command in flight. The source explicitly orders rollback of the current transaction, but the client still must verify durable business state before replaying a non-idempotent request because the connection dies during the crash cycle. Distinguish this condition from orderly administrator shutdown (57P01) and startup refusal (57P03).

Response

Do not try to send ROLLBACK on the dead connection or manufacture a crash to test the path. Wait for postmaster recovery/readiness, establish a new connection, inspect durable business state and affected objects, and retry only after the operation is idempotent or its prior effect is known. Preserve the primary/detail/hint and server logs for incident diagnosis.

Versions

The locked catalogue records this condition from 7.4; that boundary does not prove the exact implementation-introduction version. Fixed source coverage is PostgreSQL 18.6.

57P01, 57P03, 08006

Sources

src/backend/tcop/postgres.c#L2974-3001

src/include/utils/elog.h#L46-55

The structured evidence record records the fixed message and the source/runtime boundary.

226 - 57P03 — cannot_connect_now

Source-backed full entry for PostgreSQL SQLSTATE 57P03.

57P03

At a glance

57P03 is emitted during connection startup when the database has not reached a connection-ready state. Fixed guards distinguish startup, shutdown, recovery, disabled hot standby, and two different not-yet-consistent recovery states.

Field Value
SQLSTATE 57P03
Condition cannot_connect_now
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_CANNOT_CONNECT_NOW
Aliases

Meaning

The startup packet is rejected before normal authentication is completed. Every fixed branch uses FATAL, so the attempted connection ends rather than entering a client transaction. The primary alone is not enough for the hot-standby branches: detail distinguishes a disabled feature, a recovery snapshot that is not ready, and recovery that has not reached a consistent state.

Messages

  • Startup gate: primary the database system is starting up, FATAL.
  • Hot standby disabled: primary the database system is not accepting connections, FATAL; detail Hot standby mode is disabled.
  • Recovery snapshot not ready: primary the database system is not yet accepting connections, FATAL; detail Recovery snapshot is not yet ready for hot standby.; hint To enable hot standby, close write transactions with more than %d subtransactions on the primary server.
  • Recovery not consistent: primary the database system is not yet accepting connections, FATAL; detail Consistent recovery state has not been yet reached.
  • Shutdown gate: primary the database system is shutting down, FATAL.
  • Recovery gate: primary the database system is in recovery mode, FATAL.

Diagnosis

Capture primary/detail/hint, the startup phase, hot-standby setting, recovery consistency/snapshot state, server readiness log, and target server role. A repeated not yet accepting response with the snapshot detail points to the primary-side subtransaction condition named by the hint; the consistent-recovery detail points to an earlier recovery gate. Do not treat these as a transaction stuck in INERROR: the connection was refused before a session transaction existed.

Response

Use bounded backoff and wait for the relevant startup, shutdown, or recovery transition. If hot standby is intentionally disabled, remember that hot_standby is a PGC_POSTMASTER setting: change the configuration source owned by the server and restart the server; a SIGHUP/reload cannot activate this setting. If the hint identifies long primary write transactions, resolve that operational cause. Establish a new connection after readiness. There is no transaction on the rejected startup path to roll back; if a prior client operation was disconnected during a transition, verify its business result before replaying it.

Versions

The locked catalogue records this condition from 7.4; that boundary does not prove the exact implementation-introduction version. Fixed source coverage is PostgreSQL 18.6.

57P01, 57P04, 08001

Sources

src/backend/tcop/backend_startup.c#L298-338

src/backend/utils/misc/guc_tables.c#L1895-1903

The structured evidence record records all fixed startup gates and the source/runtime boundary.

227 - 57P04 — database_dropped

Source-backed reference entry for PostgreSQL SQLSTATE 57P04.

57P04

At a glance

57P04 is selected when a recovery conflict terminates a session because the connected database must be dropped. The same recovery-conflict primary is used for other conflict reasons, but those branches select 40001; the database-dropped guard is the condition identity that matters here.

Field Value
SQLSTATE 57P04
Condition database_dropped
Status active
Known present by 9.0.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DATABASE_DROPPED
Aliases

Meaning

The fixed call site uses FATAL with primary terminating connection due to conflict with recovery, dynamic recovery-conflict detail, and hint In a moment you should be able to reconnect to the database and repeat your command.. The SQLSTATE expression is explicit: ERRCODE_DATABASE_DROPPED is selected only when reason == PROCSIG_RECOVERY_CONFLICT_DATABASE; other reasons in this terminating branch use ERRCODE_T_R_SERIALIZATION_FAILURE. For the database branch, the detail is User was connected to a database that must be dropped..

Messages

  • Primary: terminating connection due to conflict with recovery, FATAL.
  • Database-drop detail: User was connected to a database that must be dropped.
  • Hint: In a moment you should be able to reconnect to the database and repeat your command.
  • Other recovery-conflict reasons can reuse the primary but select 40001 and a different detail; do not label them 57P04 from the primary alone.

Diagnosis

Preserve SQLSTATE, primary/detail/hint, database name, backend PID, recovery-conflict reason, and standby/recovery logs. Confirm that the detail identifies the dropped database before treating the condition as 57P04. The FATAL report closes the connection, so there is no session in which to issue ROLLBACK. Check whether the interrupted operation could have committed before disconnection.

Response

Wait for the recovery conflict/database transition to clear, reconnect to a valid database, and verify durable business state before replaying a non-idempotent operation. If the server reports another recovery-conflict detail with 40001, apply serialization/retry handling instead. Do not repeatedly reconnect while the database is still being dropped or while recovery logs show the conflict is active.

Versions

The locked catalogue records this condition from 9.0.4; that boundary does not prove the exact implementation-introduction version. Fixed source coverage is PostgreSQL 18.6.

57P03, 57P02, 40001

Sources

src/backend/tcop/postgres.c#L3233-3248

src/backend/tcop/postgres.c#L2549-2578

The structured evidence record records the SQLSTATE guard, dynamic detail, and source/runtime boundary.

228 - 57P05 — idle_session_timeout

Source-backed full entry for PostgreSQL SQLSTATE 57P05.

57P05

At a glance

57P05 terminates a session after idle_session_timeout expires while the backend is truly idle between commands. The fixed code starts this timer only in the no-transaction branch; idle-in-transaction has a separate condition and timer.

Field Value
SQLSTATE 57P05
Condition idle_session_timeout
Status active
Known present by 14.0
Locked snapshots 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_IDLE_SESSION_TIMEOUT
Aliases

Meaning

The fixed primary is terminating connection due to idle-session timeout at FATAL. In PostgresMain, the idle-session timer is enabled after the backend reports STATE_IDLE and only in the branch where IsTransactionOrTransactionBlock() is false. The timer is disabled as soon as a command is read. This makes 57P05 a session-lifecycle termination, distinct from statement timeout 57014, lock timeout 55P03, idle-in-transaction timeout 25P03, and transaction timeout 25P04.

Messages

  • Primary: terminating connection due to idle-session timeout.
  • Severity: FATAL; the timer interrupt terminates the connection rather than returning a recoverable statement ERROR.
  • Boundary: a truly idle session between commands uses 57P05; a session idle inside an open transaction uses the separate idle-in-transaction timer/condition.

Diagnosis

Capture the primary, backend PID, idle_session_timeout value and source, last command, pg_stat_activity state, transaction status, and server log. Verify whether the session was idle or idle in transaction when the timer started. Elapsed client request time alone cannot distinguish this from statement or lock timeout, and the SQLSTATE should be interpreted with the connection’s last ReadyForQuery state.

Response

Close or recreate the expired connection and make long-lived work explicit rather than holding an unused session. Adjust idle_session_timeout only when policy permits and the workload needs it. Because FATAL closes the connection, there is no useful ROLLBACK command to send on that session; after reconnecting, verify durable effects before replaying a non-idempotent command. If the workload was idle in a transaction, diagnose 25P03/25P04 and transaction ownership separately.

Versions

The locked catalogue records this condition from 14.0; that boundary does not prove the exact implementation-introduction version. Fixed source coverage is PostgreSQL 18.6.

57P01, 25P03, 25P04, 57014, 55P03

Sources

src/backend/tcop/postgres.c#L3504-3513

src/backend/tcop/postgres.c#L4585-4650

src/backend/tcop/postgres.c#L4704-4721

The structured evidence record records the message and idle-state boundary.

229 - 58000 — system_error

Source-backed reference entry for PostgreSQL SQLSTATE 58000.

58000

At a glance

58000 is the system-error condition. In the fixed backend path, pg_promote creates the promotion signal file and then calls kill(PostmasterPid, SIGUSR1); a failed signal reports ERROR with the operating-system text substituted for %m.

Field Value
SQLSTATE 58000
Condition system_error
Status active
Known present by 9.2.0
Locked snapshots 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_SYSTEM_ERROR
Aliases

Meaning

The representative backend primary is exactly failed to send signal to postmaster: %m. The code unlinks the promotion signal file before raising ERROR, so the failed system call is part of a postmaster-notification path, not a user value or SQL syntax failure. The shared common/exec.c source uses a log_error macro that has two compile-time branches. In a non-FRONTEND build it expands to ereport(LOG, (errcodefn, errmsg_internal(...))); in a FRONTEND build it ignores the errcode() argument and prints the formatted text to stderr. Thus the frontend utility message is not proof of a client-protocol 58000 diagnostic or a client transaction abort. The separate pg_log_error macro in common/logging.h maps to PG_LOG_ERROR, but pclose_check() does not call that macro.

Messages

  • Backend pg_promote signal path: primary failed to send signal to postmaster: %m, severity ERROR. The expanded text depends on the OS errno at the failed kill() call.
  • Shared pclose_check() source: the call-site template is %s() failed: %m; with pclose() it expands to pclose() failed: <OS text>. Non-FRONTEND builds log it through ereport(LOG) with the supplied ERRCODE_SYSTEM_ERROR; FRONTEND builds ignore that code and print to stderr, so this is not a client-protocol 58000 path.

Diagnosis

Preserve the full primary after %m expansion, the operation (promotion signal, pclose, or another system helper), process identity, and server or utility log context. For backend pg_promote, inspect the postmaster PID, signal permissions/process liveness, and the OS error. Do not replace the OS-specific cause with a generic disk, permission, or process diagnosis without the actual errno. The SQLSTATE alone does not establish transaction outcome.

Response

Correct the operating-system condition identified by the expanded message, then verify postmaster/server health before retrying the operation. A backend ERROR normally aborts the current explicit transaction, so send ROLLBACK or ROLLBACK TO SAVEPOINT before continuing; in autocommit, retry only after the cause is fixed. A frontend log from pclose_check has its utility’s own control flow and does not call for a SQL transaction rollback. If the connection was lost, reconnect after readiness and verify business effects.

Versions

The locked catalogue records this condition from 9.2.0; that boundary does not prove the exact implementation-introduction version. Fixed source coverage is PostgreSQL 18.6.

57P01, 57P02, XX000

Sources

src/backend/access/transam/xlogfuncs.c#L702-708

src/common/exec.c#L52-70

src/common/exec.c#L391-412

src/include/common/logging.h#L106-110

The structured evidence record records the backend and frontend/common message boundaries.

230 - 58030 — io_error

Source-backed full reference for PostgreSQL SQLSTATE 58030.

58030

At a glance

58030 is emitted by a specific shared-buffer cleanup path after a write failure has already been recorded. In PostgreSQL 18.6 that path reports WARNING, not a generic client ERROR: it names the block and relation and says that repeated failure may be permanent.

Field Value
SQLSTATE 58030
Condition io_error
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_IO_ERROR
Aliases

Meaning

FlushBuffer starts the shared-buffer write, flushes WAL first for permanent relations, and calls smgrwrite. If error unwinding reaches the resource-owner buffer-I/O callback, AbortBufferIO marks the buffer with BM_IO_ERROR. When the buffer is still valid and dirty and this is not the first failure, it emits SQLSTATE 58030 at WARNING level, then terminates the buffer I/O with the error flag. The earlier smgrwrite failure is the event that may have aborted the client statement; this later warning is a repeat-failure notice and does not by itself establish that the client transaction is in error.

The relation text is generated from the buffer tag (relpathperm), while the write callback can add the context writing block %u of relation "%s" to the original error. The message therefore identifies where to investigate, but it is not a promise that the block is the only damaged object.

A separate storage-manager path extends a relation segment with FileWrite. If that call returns a negative result, md.c raises ERROR with could not extend file "%s": %m and errcode_for_file_access(); the saved EIO errno maps to 58030, while ENOSPC maps to 53100. This original ERROR can abort a client statement and put an explicit transaction in the failed state. It is a different emission from the later repeated-failure WARNING in AbortBufferIO.

Messages

  • WARNING, SQLSTATE 58030: could not write block %u of %s
    • Detail: Multiple failures --- write error might be permanent.
  • Error context used around shared-buffer writes: writing block %u of relation "%s".
  • ERROR, SQLSTATE selected by errcode_for_file_access(); for saved EIO, 58030: could not extend file "%s": %m
    • Hint: Check free disk space.

The first write failure can have a different primary message and SQLSTATE, for example one selected by an OS errno helper. Preserve that first record together with this warning. In the relation-extension path, EIO deliberately selects this condition, whereas ENOSPC selects 53100; do not collapse those errno branches into a generic disk-full diagnosis.

Diagnosis

Keep the complete error chain, including the first write error, this warning, server-log context, relation fork and block, filesystem or device errno, mount state, and whether WAL or a replica has confirmed the write. Check whether the failing operation was a backend statement, checkpoint, background writer, or another server path. A source-only review cannot identify which storage component failed on a particular deployment.

Response

Stop retrying while the storage path is unhealthy. Verify the mount, device, permissions, space and quota, and storage error logs; preserve the affected relation and replica evidence before any repair. The relation-extension ERROR can leave an explicit client transaction failed, so issue ROLLBACK or ROLLBACK TO an already-established savepoint before sending more SQL. The repeated-failure WARNING from a background or cleanup path does not by itself require a client rollback, but it still requires storage remediation and a durability check. Retry the whole idempotent unit only after the cause is fixed; if the backend or server stopped, use a new connection and validate commit state before replaying work.

Versions

The locked catalogue records this condition from 7.4; the fixed mechanism and message role are read from PostgreSQL 18.6. No natural I/O failure was induced for this source-only entry.

53100, 58P03, XX001

Sources

src/backend/storage/buffer/bufmgr.c#L4307-L4436

src/backend/storage/buffer/bufmgr.c#L6164-L6225

src/backend/storage/smgr/md.c#L512-L519

src/backend/utils/error/elog.c#L867-L942

The structured evidence record records the fixed warning, detail, source boundary, and lack of natural runtime evidence.

231 - 58P01 — undefined_file

Source-backed full reference for PostgreSQL SQLSTATE 58P01.

58P01

At a glance

58P01 means that a required file or directory could not be found. In the fixed tablespace path, PostgreSQL distinguishes an ENOENT target during chmod from other permission or filesystem failures; the recovery hint is conditional on the server being in recovery.

Field Value
SQLSTATE 58P01
Condition undefined_file
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_UNDEFINED_FILE
Aliases

Meaning

utility.c calls PreventInTransactionBlock(isTopLevel, "CREATE TABLESPACE") before entering CreateTableSpace, so the command is rejected inside an explicit transaction block; there is no explicit client transaction block to roll back for that command. create_tablespace_directories() is used after that command and from tablespace WAL replay. When the target is not an in-place directory and chmod(location, ...) returns ENOENT, the code emits SQLSTATE 58P01 with directory "%s" does not exist. It adds Create this directory for the tablespace before restarting the server. only when InRecovery is true. Other chmod failures use errcode_for_file_access() and the dynamic primary could not set permissions on directory "%s": %m; an in-place creation failure similarly uses could not create directory "%s": %m with an errno-selected code.

The condition is therefore broader than tablespace startup. The operation and %m detail decide whether the missing object is a tablespace, relation file, configuration file, or another file consumer.

Messages

  • ERROR, SQLSTATE 58P01: directory "%s" does not exist
    • Conditional hint during recovery: Create this directory for the tablespace before restarting the server.
  • ERROR, with errcode_for_file_access(): could not set permissions on directory "%s": %m.
  • ERROR, with errcode_for_file_access(): could not create directory "%s": %m (the in-place directory branch).

The latter two templates are not guaranteed to be 58P01: errcode_for_file_access() selects the SQLSTATE from the saved errno.

Diagnosis

Record the complete primary, %m detail, phase, path, database/tablespace identity, and whether the caller is SQL execution or WAL replay. Check that the expected volume is mounted at the exact path, then verify ownership, mode, symlink target, and the tablespace version directory. A missing mount and an intentionally removed directory need different recovery plans.

Response

Restore the expected mount or directory from the deployment and backup procedure; do not create an arbitrary empty path over an unknown tablespace location. CREATE TABLESPACE is guarded by PreventInTransactionBlock, so it cannot run inside an explicit client transaction block; there is no explicit block to roll back for that command itself. If a different file consumer reports a client ERROR inside an explicit transaction, issue ROLLBACK or use an already-established savepoint before continuing. When the message comes from WAL recovery, there is no client transaction to resume: restore the path and follow the server’s restart/recovery procedure. Retry only after ownership, permissions, and the target’s contents have been checked.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6. The cited source is a source-only review; no tablespace fault was induced.

58P02, 58P03, 58030

Sources

src/backend/commands/tablespace.c#L347-L359

src/backend/commands/tablespace.c#L565-L625

src/backend/commands/tablespace.c#L1515-L1525

src/backend/tcop/utility.c#L713-L717

The structured evidence record records conditional hints, dynamic errno paths, and the source/runtime boundary.

232 - 58P02 — duplicate_file

Source-backed reference for PostgreSQL SQLSTATE 58P02.

58P02

At a glance

58P02 is the duplicate-file condition in the fixed server-side base-backup output path. The path accepts a missing directory, accepts an existing empty directory, and raises this code when the existing target is non-empty.

Field Value
SQLSTATE 58P02
Condition duplicate_file
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DUPLICATE_FILE
Aliases

Meaning

bbsink_server_new() first performs and commits its privilege check transaction. It then rejects relative paths and calls pg_check_dir(pathname): result 0 creates the directory, result 1 accepts an empty directory, and results 2–4 enter the fixed ERRCODE_DUPLICATE_FILE branch. An access error takes a separate errcode_for_file_access() branch. This is a base-backup output safety check, not proof that every EEXIST or non-empty directory in PostgreSQL uses 58P02.

Messages

  • ERROR, SQLSTATE 58P02: directory "%s" exists but is not empty.
  • ERROR, with errcode_for_file_access(): could not access directory "%s": %m.
  • ERROR, with errcode_for_file_access(): could not create directory "%s": %m when the target is absent but creation fails.

The last two templates receive their SQLSTATE from the saved OS errno and should not be relabeled 58P02 merely because they occur in the same function.

Diagnosis

Confirm that the path is the intended base-backup destination, inspect its owner, mount, and inventory, and determine whether it contains a prior complete backup or an interrupted one. Preserve that inventory before changing it. The source path performs output preparation after the internal privilege-check transaction has been committed, so this condition is a failed backup setup rather than evidence that a user DML transaction can be repaired by blindly continuing.

Response

Use a documented empty destination or archive the previous output according to the backup policy. Validate the completed backup and its manifest after creation; never recursively delete or force-overwrite an unknown directory. If an outer client command reports an ERROR, follow the actual session state and roll back to an existing savepoint or transaction as appropriate, but do not treat ROLLBACK as a way to make the non-empty backup target safe. A new connection is needed only if the owning server process was terminated.

Versions

The locked catalogue records this condition from 7.4; the fixed base-backup path is from PostgreSQL 18.6. No backup target was altered or tested for this source-only entry.

58P01, 58P03, 53100

Sources

src/backend/backup/basebackup_server.c#L59-L125

The structured evidence record records the directory-state branches, dynamic errno paths, and source/runtime boundary.

233 - 58P03 — file_name_too_long

Source-backed full reference for PostgreSQL SQLSTATE 58P03.

58P03

At a glance

58P03 is selected by PostgreSQL’s file-access errno helper when the saved OS errno is ENAMETOOLONG. It is not a standalone fixed primary such as file name too long: the caller supplies a %m message, and the helper supplies the SQLSTATE.

Field Value
SQLSTATE 58P03
Condition file_name_too_long
Status active
Known present by 18.0
Locked snapshots 18.6, 19beta3
Macros ERRCODE_FILE_NAME_TOO_LONG
Aliases

Meaning

errcode_for_file_access() maps ENAMETOOLONG to ERRCODE_FILE_NAME_TOO_LONG. The same complete switch maps ENOENT to 58P01, EEXIST to 58P02, ENOSPC to 53100, and EIO to 58030; all other errno values may map elsewhere. The helper explicitly expects the caller’s primary message to retain %m, so the OS text and locale are part of the useful diagnosis.

Fixed 18.6 backend callers include the base-backup sink’s could not access directory "%s": %m and the tablespace path’s could not set permissions on directory "%s": %m, both emitted with ERROR before the helper chooses the code. These examples show why the operation context matters: the same SQLSTATE can arise from different file operations, while a file-name failure in another caller may carry a different primary template.

Messages

  • ERROR, representative base-backup primary: could not access directory "%s": %m.
  • ERROR, representative tablespace primary: could not set permissions on directory "%s": %m.
  • The %m expansion is the saved OS error text; when it is ENAMETOOLONG, errcode_for_file_access() supplies SQLSTATE 58P03.

There is no fixed source-backed 58P03 primary independent of the caller in this review. Do not replace %m with an invented English sentence or infer an extension’s message from the condition name.

Diagnosis

Capture the complete primary/detail/context, the operation and component, the full path, operating-system errno, filesystem limits, encoding, and any PostgreSQL object-name mapping. Distinguish a filesystem component limit from PostgreSQL’s identifier limits, and distinguish the helper’s ENAMETOOLONG branch from ENOENT, EEXIST, disk-full, and I/O branches. The fixed source confirms the helper and representative callers; it does not claim a natural reproduction on a particular host.

Response

Use a path and name accepted by the owning component and filesystem, or relocate the target while preserving a durable mapping. For a client ERROR in an explicit transaction, ROLLBACK or an existing savepoint is required before continuing; fix the path and retry the affected operation, not arbitrary unrelated statements. A startup/background caller may have no client transaction, and a terminated backend requires a new connection. Preserve the original OS detail when escalating the issue.

Versions

The locked catalogue records 58P03 from 18.0; fixed helper and caller coverage is PostgreSQL 18.6. The page is source-reviewed only and has no natural runtime claim.

58P01, 58P02, 58030

Sources

src/backend/utils/error/elog.c#L867-L942

src/backend/backup/basebackup_server.c#L119-L124

src/backend/commands/tablespace.c#L606-L618

The structured evidence record records the errno mapping, representative primaries, and source/runtime boundary.

234 - 72000 — snapshot_too_old

Source-backed historical reference for PostgreSQL SQLSTATE 72000.

72000

At a glance

72000 is a historical snapshot_too_old error. PostgreSQL 16.15 still defines and emits it; the SQLSTATE was removed in the PostgreSQL 17 major line. PostgreSQL 16.15 is therefore a later minor snapshot of the last major line, not the removal point.

Field Value
SQLSTATE 72000
Condition snapshot_too_old
Status removed
Known present by 9.6.0
Locked snapshots 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15
Macros ERRCODE_SNAPSHOT_TOO_OLD
Aliases

Meaning

In the fixed 16.15 sources, old_snapshot_threshold is a PGC_POSTMASTER integer GUC; -1 disables the feature. The inline TestForOldSnapshot guard requires a non-negative threshold, an MVCC or TOAST snapshot with a valid LSN, and a page LSN newer than the snapshot. It then calls TestForOldSnapshot_impl, which additionally requires a permanent, non-catalog relation that allows early pruning and compares snapshot.whenTaken with GetOldSnapshotThresholdTimestamp(). If the snapshot is too old, the function raises ERROR 72000 with snapshot too old.

The threshold timestamp is maintained by the old-snapshot time-to-XID mapping used by early pruning and vacuum. The PG16.15 documentation says that dead data older than the threshold may be vacuumed, and a read of a page modified after the snapshot can fail; a materialized cursor or a system catalog may avoid the error. Space retained for detection is not released to the operating system until an explicit operation such as VACUUM FULL.

Messages

  • ERROR, SQLSTATE 72000: snapshot too old.

There is no current PG17/18 definition row in the locked catalogue. Do not infer a replacement SQLSTATE or claim that an unrelated current error is equivalent.

Diagnosis

On PostgreSQL 9.6 through 16, record the major version, SHOW old_snapshot_threshold, transaction snapshot age, relation kind, page/read path, and vacuum or pruning history. Check whether the relation is excluded by the guard (for example a system catalog), whether the read used a materialized cursor or result set, and whether the setting was active at server start. A source-only review cannot establish the threshold or cleanup history on a live cluster.

Response

This is a statement ERROR; in an explicit transaction, roll back the transaction or to an already-established savepoint before issuing more SQL. The old snapshot cannot be repaired in place: end or shorten the long-running reader, use a suitable startup configuration for the historical major (the GUC is PGC_POSTMASTER, so changing it requires restart), and rerun the whole read unit with an idempotent boundary. On PostgreSQL 17 and later, first identify the current error and mechanism instead of installing a 72000 handler based on the historical name.

Versions

The locked definition artifact records 72000 from 9.6.0 through 16.15 and no PG17/18 definition. The 16.15 source documents the GUC and guard; the fixed buffer-manager emitter is from commit 7d3e000c5961a544302072058a1184e9a588837b. The catalogue boundary establishes removal in the PG17 major line, not in minor release 16.15.

40001, XX001

Sources

src/backend/storage/buffer/bufmgr.c#L5663-L5675

src/include/storage/bufmgr.h#L363-L392

src/backend/utils/time/snapmgr.c#L1697-L1714

src/backend/utils/misc/guc_tables.c#L3295-L3302

doc/src/sgml/config.sgml#L2827-L2884

The structured evidence record records the historical definition, guard, GUC, documentation, and source/runtime boundary.

235 - Class 00 — Successful Completion

Members and evidence boundaries for PostgreSQL SQLSTATE class 00.

Class 00 — Successful Completion

Shared meaning

The first two characters 00 identify Successful Completion. Successful completion of a statement. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

00000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

236 - Class 01 — Warning

Members and evidence boundaries for PostgreSQL SQLSTATE class 01.

Class 01 — Warning

Shared meaning

The first two characters 01 identify Warning. A statement completed with a warning condition. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 8 members in this class:

01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

237 - Class 02 — No Data (this is also a warning class per the SQL standard)

Members and evidence boundaries for PostgreSQL SQLSTATE class 02.

Class 02 — No Data (this is also a warning class per the SQL standard)

Shared meaning

The first two characters 02 identify No Data (this is also a warning class per the SQL standard). A statement completed without returning the requested data. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 2 members in this class:

02000, 02001

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

238 - Class 03 — SQL Statement Not Yet Complete

Members and evidence boundaries for PostgreSQL SQLSTATE class 03.

Class 03 — SQL Statement Not Yet Complete

Shared meaning

The first two characters 03 identify SQL Statement Not Yet Complete. The SQL statement is incomplete and needs more input. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

03000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

239 - Class 08 — Connection Exception

Members and evidence boundaries for PostgreSQL SQLSTATE class 08.

Class 08 — Connection Exception

Shared meaning

The first two characters 08 identify Connection Exception. The client or server could not establish or keep a connection. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 7 members in this class:

08000, 08001, 08003, 08004, 08006, 08007, 08P01

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

240 - Class 09 — Triggered Action Exception

Members and evidence boundaries for PostgreSQL SQLSTATE class 09.

Class 09 — Triggered Action Exception

Shared meaning

The first two characters 09 identify Triggered Action Exception. An action invoked by a statement or trigger failed. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

09000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

241 - Class 0A — Feature Not Supported

Members and evidence boundaries for PostgreSQL SQLSTATE class 0A.

Class 0A — Feature Not Supported

Shared meaning

The first two characters 0A identify Feature Not Supported. The requested SQL feature is not implemented or supported. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

0A000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

242 - Class 0B — Invalid Transaction Initiation

Members and evidence boundaries for PostgreSQL SQLSTATE class 0B.

Class 0B — Invalid Transaction Initiation

Shared meaning

The first two characters 0B identify Invalid Transaction Initiation. A transaction was started in an invalid way. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

0B000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

243 - Class 0F — Locator Exception

Members and evidence boundaries for PostgreSQL SQLSTATE class 0F.

Class 0F — Locator Exception

Shared meaning

The first two characters 0F identify Locator Exception. A locator value or locator operation is invalid. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 2 members in this class:

0F000, 0F001

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

244 - Class 0L — Invalid Grantor

Members and evidence boundaries for PostgreSQL SQLSTATE class 0L.

Class 0L — Invalid Grantor

Shared meaning

The first two characters 0L identify Invalid Grantor. The grantor named by an authorization operation is invalid. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 2 members in this class:

0L000, 0LP01

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

245 - Class 0P — Invalid Role Specification

Members and evidence boundaries for PostgreSQL SQLSTATE class 0P.

Class 0P — Invalid Role Specification

Shared meaning

The first two characters 0P identify Invalid Role Specification. The role named by an authorization operation is invalid. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

0P000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

246 - Class 0Z — Diagnostics Exception

Members and evidence boundaries for PostgreSQL SQLSTATE class 0Z.

Class 0Z — Diagnostics Exception

Shared meaning

The first two characters 0Z identify Diagnostics Exception. A diagnostics operation has an invalid state or request. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 2 members in this class:

0Z000, 0Z002

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

247 - Class 10 — XQuery Error

Members and evidence boundaries for PostgreSQL SQLSTATE class 10.

Class 10 — XQuery Error

Shared meaning

The first two characters 10 identify XQuery Error. An XQuery expression or XQuery processing step failed. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

10608

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

248 - Class 20 — Case Not Found

Members and evidence boundaries for PostgreSQL SQLSTATE class 20.

Class 20 — Case Not Found

Shared meaning

The first two characters 20 identify Case Not Found. A requested case or branch has no matching alternative. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

20000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

249 - Class 21 — Cardinality Violation

Members and evidence boundaries for PostgreSQL SQLSTATE class 21.

Class 21 — Cardinality Violation

Shared meaning

The first two characters 21 identify Cardinality Violation. A result has the wrong cardinality for the operation. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

21000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

250 - Class 22 — Data Exception

Members and evidence boundaries for PostgreSQL SQLSTATE class 22.

Class 22 — Data Exception

Shared meaning

The first two characters 22 identify Data Exception. A value violates a data type, format, or range rule. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 68 members in this class:

22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200H, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22013, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 2202G, 2202H, 22030, 22031, 22032, 22033, 22034, 22035, 22036, 22037, 22038, 22039, 2203A, 2203B, 2203C, 2203D, 2203E, 2203F, 2203G, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

251 - Class 23 — Integrity Constraint Violation

Members and evidence boundaries for PostgreSQL SQLSTATE class 23.

Class 23 — Integrity Constraint Violation

Shared meaning

The first two characters 23 identify Integrity Constraint Violation. A row operation violates a declared integrity constraint. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 7 members in this class:

23000, 23001, 23502, 23503, 23505, 23514, 23P01

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

252 - Class 24 — Invalid Cursor State

Members and evidence boundaries for PostgreSQL SQLSTATE class 24.

Class 24 — Invalid Cursor State

Shared meaning

The first two characters 24 identify Invalid Cursor State. A cursor is not in the state required by the operation. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

24000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

253 - Class 25 — Invalid Transaction State

Members and evidence boundaries for PostgreSQL SQLSTATE class 25.

Class 25 — Invalid Transaction State

Shared meaning

The first two characters 25 identify Invalid Transaction State. A transaction is not in the state required by the operation. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 13 members in this class:

25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 25P03, 25P04

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

254 - Class 26 — Invalid SQL Statement Name

Members and evidence boundaries for PostgreSQL SQLSTATE class 26.

Class 26 — Invalid SQL Statement Name

Shared meaning

The first two characters 26 identify Invalid SQL Statement Name. A named SQL statement cannot be found or used. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

26000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

255 - Class 27 — Triggered Data Change Violation

Members and evidence boundaries for PostgreSQL SQLSTATE class 27.

Class 27 — Triggered Data Change Violation

Shared meaning

The first two characters 27 identify Triggered Data Change Violation. A triggered data change violates the operation’s rules. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

27000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

256 - Class 28 — Invalid Authorization Specification

Members and evidence boundaries for PostgreSQL SQLSTATE class 28.

Class 28 — Invalid Authorization Specification

Shared meaning

The first two characters 28 identify Invalid Authorization Specification. The authorization specification is invalid or rejected. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 2 members in this class:

28000, 28P01

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

257 - Class 2B — Dependent Privilege Descriptors Still Exist

Members and evidence boundaries for PostgreSQL SQLSTATE class 2B.

Class 2B — Dependent Privilege Descriptors Still Exist

Shared meaning

The first two characters 2B identify Dependent Privilege Descriptors Still Exist. A dependent privilege descriptor prevents the requested change. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 2 members in this class:

2B000, 2BP01

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

258 - Class 2D — Invalid Transaction Termination

Members and evidence boundaries for PostgreSQL SQLSTATE class 2D.

Class 2D — Invalid Transaction Termination

Shared meaning

The first two characters 2D identify Invalid Transaction Termination. The transaction was terminated in an invalid way. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

2D000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

259 - Class 2F — SQL Routine Exception

Members and evidence boundaries for PostgreSQL SQLSTATE class 2F.

Class 2F — SQL Routine Exception

Shared meaning

The first two characters 2F identify SQL Routine Exception. An SQL routine failed while being invoked or executed. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 5 members in this class:

2F000, 2F002, 2F003, 2F004, 2F005

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

260 - Class 34 — Invalid Cursor Name

Members and evidence boundaries for PostgreSQL SQLSTATE class 34.

Class 34 — Invalid Cursor Name

Shared meaning

The first two characters 34 identify Invalid Cursor Name. The named cursor does not exist or is invalid. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

34000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

261 - Class 38 — External Routine Exception

Members and evidence boundaries for PostgreSQL SQLSTATE class 38.

Class 38 — External Routine Exception

Shared meaning

The first two characters 38 identify External Routine Exception. An external routine failed while executing. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 5 members in this class:

38000, 38001, 38002, 38003, 38004

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

262 - Class 39 — External Routine Invocation Exception

Members and evidence boundaries for PostgreSQL SQLSTATE class 39.

Class 39 — External Routine Invocation Exception

Shared meaning

The first two characters 39 identify External Routine Invocation Exception. An external routine could not be invoked correctly. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 6 members in this class:

39000, 39001, 39004, 39P01, 39P02, 39P03

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

263 - Class 3B — Savepoint Exception

Members and evidence boundaries for PostgreSQL SQLSTATE class 3B.

Class 3B — Savepoint Exception

Shared meaning

The first two characters 3B identify Savepoint Exception. A savepoint operation is invalid for the current transaction. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 2 members in this class:

3B000, 3B001

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

264 - Class 3D — Invalid Catalog Name

Members and evidence boundaries for PostgreSQL SQLSTATE class 3D.

Class 3D — Invalid Catalog Name

Shared meaning

The first two characters 3D identify Invalid Catalog Name. The named database catalog does not exist or is invalid. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

3D000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

265 - Class 3F — Invalid Schema Name

Members and evidence boundaries for PostgreSQL SQLSTATE class 3F.

Class 3F — Invalid Schema Name

Shared meaning

The first two characters 3F identify Invalid Schema Name. The named schema does not exist or is invalid. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

3F000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

266 - Class 40 — Transaction Rollback

Members and evidence boundaries for PostgreSQL SQLSTATE class 40.

Class 40 — Transaction Rollback

Shared meaning

The first two characters 40 identify Transaction Rollback. The transaction was rolled back because it could not safely continue. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 5 members in this class:

40000, 40001, 40002, 40003, 40P01

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

267 - Class 42 — Syntax Error or Access Rule Violation

Members and evidence boundaries for PostgreSQL SQLSTATE class 42.

Class 42 — Syntax Error or Access Rule Violation

Shared meaning

The first two characters 42 identify Syntax Error or Access Rule Violation. The statement violates syntax or an access rule. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 44 members in this class:

42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 428C9, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

268 - Class 44 — WITH CHECK OPTION Violation

Members and evidence boundaries for PostgreSQL SQLSTATE class 44.

Class 44 — WITH CHECK OPTION Violation

Shared meaning

The first two characters 44 identify WITH CHECK OPTION Violation. A row would violate a WITH CHECK OPTION view condition. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

44000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

269 - Class 53 — Insufficient Resources

Members and evidence boundaries for PostgreSQL SQLSTATE class 53.

Class 53 — Insufficient Resources

Shared meaning

The first two characters 53 identify Insufficient Resources. The server lacks a resource required by the operation. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 5 members in this class:

53000, 53100, 53200, 53300, 53400

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

270 - Class 54 — Program Limit Exceeded

Members and evidence boundaries for PostgreSQL SQLSTATE class 54.

Class 54 — Program Limit Exceeded

Shared meaning

The first two characters 54 identify Program Limit Exceeded. The operation exceeds a configured program limit. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 4 members in this class:

54000, 54001, 54011, 54023

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

271 - Class 55 — Object Not In Prerequisite State

Members and evidence boundaries for PostgreSQL SQLSTATE class 55.

Class 55 — Object Not In Prerequisite State

Shared meaning

The first two characters 55 identify Object Not In Prerequisite State. A prerequisite object or state is missing or unsuitable. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 5 members in this class:

55000, 55006, 55P02, 55P03, 55P04

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

272 - Class 57 — Operator Intervention

Members and evidence boundaries for PostgreSQL SQLSTATE class 57.

Class 57 — Operator Intervention

Shared meaning

The first two characters 57 identify Operator Intervention. The operation was cancelled or rejected by operator intervention. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 7 members in this class:

57000, 57014, 57P01, 57P02, 57P03, 57P04, 57P05

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

273 - Class 58 — System Error (errors external to PostgreSQL itself)

Members and evidence boundaries for PostgreSQL SQLSTATE class 58.

Class 58 — System Error (errors external to PostgreSQL itself)

Shared meaning

The first two characters 58 identify System Error (errors external to PostgreSQL itself). The server encountered an error external to PostgreSQL itself. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 5 members in this class:

58000, 58030, 58P01, 58P02, 58P03

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

274 - Class 72 — Snapshot Failure

Members and evidence boundaries for PostgreSQL SQLSTATE class 72.

Class 72 — Snapshot Failure

Shared meaning

The first two characters 72 identify Snapshot Failure. A snapshot could not be created or used. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 1 members in this class:

72000

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

275 - Class F0 — Configuration File Error

Members and evidence boundaries for PostgreSQL SQLSTATE class F0.

Class F0 — Configuration File Error

Shared meaning

The first two characters F0 identify Configuration File Error. A configuration file or its contents are invalid. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 2 members in this class:

F0000, F0001

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

276 - Class HV — Foreign Data Wrapper Error (SQL/MED)

Members and evidence boundaries for PostgreSQL SQLSTATE class HV.

Class HV — Foreign Data Wrapper Error (SQL/MED)

Shared meaning

The first two characters HV identify Foreign Data Wrapper Error (SQL/MED). A SQL/MED foreign data wrapper operation failed. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 27 members in this class:

HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

277 - Class P0 — PL/pgSQL Error

Members and evidence boundaries for PostgreSQL SQLSTATE class P0.

Class P0 — PL/pgSQL Error

Shared meaning

The first two characters P0 identify PL/pgSQL Error. A PL/pgSQL program raised an error condition. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 5 members in this class:

P0000, P0001, P0002, P0003, P0004

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

278 - Class XX — Internal Error

Members and evidence boundaries for PostgreSQL SQLSTATE class XX.

Class XX — Internal Error

Shared meaning

The first two characters XX identify Internal Error. An internal PostgreSQL failure occurred. A class gives a directory-level family; each member still needs its own message, transaction aftermath, and response evidence.

Members

The locked catalogue contains 3 members in this class:

XX000, XX001, XX002

Version boundary

Member links lead to their own versioned facts; consult the version pages and source evidence for exact presence and change boundaries.

Sources

Members are generated from data/classes.json and the locked SQLSTATE directory.

279 - F0000 — config_file_error

Source-backed full reference for PostgreSQL SQLSTATE F0000.

F0000

At a glance

F0000 is the configuration-file error condition, but its severity and recovery boundary depend on the owner. Fixed core paths include a recovery-target failure and OAuth HBA validation; the unaccent contrib dictionary has its own file-open and rule-parser paths.

Field Value
SQLSTATE F0000
Condition config_file_error
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_CONFIG_FILE_ERROR
Aliases

Meaning

The recovery path emits FATAL when archive recovery ends before a configured target is reached. OAuth validation calls ereport(elevel): HBA parsing supplies the level, load_hba() logs parse errors while retaining the old rules on reload, and initial postmaster startup turns a failed HBA load into a separate FATAL that prevents startup. The unaccent loader reports an ERROR when it cannot open its rules file, while duplicate rules and malformed rule lines are WARNING conditions with this SQLSTATE.

These are configuration-owner-specific paths. A line number and file context belong to HBA parsing; %m belongs to the dictionary file-open operation; a recovery-target message has neither of those fields.

Messages

  • FATAL, SQLSTATE F0000: recovery ended before configured recovery target was reached.
  • elevel selected by HBA loading, with SQLSTATE F0000: oauth_validator_libraries must be set for authentication method %s; context line %d of configuration file "%s".
  • elevel selected by HBA loading: invalid list syntax in parameter "%s".
  • elevel selected by HBA loading: authentication method "oauth" requires argument "validator" to be set when oauth_validator_libraries contains multiple options; context line %d of configuration file "%s".
  • ERROR, SQLSTATE F0000: could not open unaccent file "%s": %m.
  • WARNING, SQLSTATE F0000: duplicate source strings, first one will be used.
  • WARNING, SQLSTATE F0000: invalid syntax: more than two strings in unaccent rule or invalid syntax: unfinished quoted string in unaccent rule.

The OAuth templates use ereport(elevel), so the source function alone does not turn every HBA event into ERROR or FATAL; the startup/reload caller determines the operational boundary.

Diagnosis

Keep the complete primary, detail, hint, context, file name, line number, subsystem, and phase. For recovery, inspect the configured target and available WAL/archive. For OAuth, inspect the HBA line and oauth_validator_libraries value; distinguish an empty list from list syntax and from a missing validator argument. For unaccent, check the resolved rules path, permissions, encoding, and rule format; a warning can leave the dictionary loaded with a first-rule-wins or skipped-line behavior.

Response

Fix the named configuration using its owning format and keep a known-good copy. A recovery-target FATAL or initial HBA-load FATAL ends startup, so there is no client transaction to roll back; correct the target/configuration and restart, then use a new connection. An HBA reload parse failure is logged and the old rules remain active, so repair the file and reload again rather than assuming the new rules took effect. An unaccent ERROR inside an explicit client transaction requires ROLLBACK or an existing savepoint before continuing; warning paths do not require rollback, but their skipped or duplicate rules should be reviewed before relying on the dictionary.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6. No startup, reload, or dictionary failure was induced for this source-only page.

58P01, F0001, 57P03

Sources

src/backend/access/transam/xlogrecovery.c#L1921-L1931

src/backend/libpq/auth-oauth.c#L813-L870

src/backend/libpq/hba.c#L2635-L2692

src/backend/postmaster/postmaster.c#L1327-L1338

contrib/unaccent/unaccent.c#L65-L109

contrib/unaccent/unaccent.c#L260-L271

The structured evidence record records the fixed message groups, caller-selected severity, and source/runtime boundary.

280 - F0001 — lock_file_exists

Source-backed full reference for PostgreSQL SQLSTATE F0001.

F0001

At a glance

F0001 is a startup ownership failure. PostgreSQL checks both the lock file and the shared-memory identity for the intended data directory; a live owner is different from a stale artifact left by a crashed postmaster.

Field Value
SQLSTATE F0001
Condition lock_file_exists
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_LOCK_FILE_EXISTS
Aliases

Meaning

CreateLockFile creates the lock file atomically with O_EXCL. If an existing file contains a PID, it uses kill(pid, 0) to distinguish a live process from a vanished one. For the data-directory lock it also reads the recorded shared-memory identifiers and calls PGSharedMemoryIsInUse; that helper only treats a segment associated with the intended DataDir as relevant, because accidental shared-memory ID matches are possible. An empty lock file is a separate F0001 branch and can mean that another server is still starting or that a previous startup crashed.

The SysV shared-memory startup path has the same boundary: an attached or indeterminate pre-existing segment is reported as still in use, while an unattached segment associated with the data directory can be removed and recreated. These guards prevent two postmasters from claiming one cluster.

Messages

  • FATAL, SQLSTATE F0001: lock file "%s" already exists.
    • Data-directory hint: Is another postgres (PID %d) running in data directory "%s"? (the postmaster wording is selected for the encoded owner).
    • Socket-lock variants name using socket file "%s" instead.
  • FATAL, SQLSTATE F0001: lock file "%s" is empty.
    • Hint: Either another server is starting, or the lock file is the remnant of a previous server startup crash.
  • FATAL, SQLSTATE F0001: pre-existing shared memory block (key %lu, ID %lu) is still in use.
    • Hint: Terminate any old server processes associated with data directory "%s".

Other lock-file I/O failures use errcode_for_file_access() and can receive a different SQLSTATE; do not collapse them into F0001.

Diagnosis

Confirm the exact PGDATA, socket directory, PID, start time, recorded device/inode identity, process owner, and postmaster log. A successful kill(pid, 0), or a failure whose errno is neither ESRCH nor EPERM, keeps the live-process branch active. ESRCH means that the PID does not exist; EPERM means that a process exists but the caller lacks permission to signal it. This guard treats EPERM as a candidate for the next identity checks because checkDataDir() and the 0600/0640 lock-file modes rule out a different-UID process as the competing postmaster; it does not by itself authorize deleting the lock. If the PID is gone or treated as a different-UID candidate, inspect the data-directory shared-memory IDs and whether an orphan backend still attaches before considering cleanup. An empty file is explicitly ambiguous, not proof of staleness.

Response

This is a startup FATAL, so there is no client transaction state to recover; after the ownership problem is resolved, start the server and use a new connection. If another postmaster or backend is live, stop or coordinate it through normal administration. Only after verifying the exact cluster, process identity, and shared-memory state may an operator follow the documented stale-lock cleanup path. Never remove a lock or shared-memory object by pathname, PID text, or numeric ID alone; if the owner is live, deletion risks split-brain (two postmasters claiming one cluster) and data loss.

Versions

The locked catalogue records this condition from 7.4; fixed startup and shared-memory paths are from PostgreSQL 18.6. No process, lock-file, or shared-memory fault was induced for this source-only entry.

F0000, 57P03, 58P01

Sources

src/backend/utils/init/miscinit.c#L1262-L1427

src/backend/port/sysv_shmem.c#L306-L335

src/backend/port/sysv_shmem.c#L765-L835

The structured evidence record records live/stale guards, fixed FATAL messages, and the source/runtime boundary.

281 - HV000 — fdw_error

PostgreSQL SQLSTATE HV000 is the SQL/MED foreign-data-wrapper error condition. Identify the wrapper callback and any remote diagnostic before deciding how to recover.

HV000 — fdw_error

At a glance

HV000 is the generic SQL/MED foreign-data-wrapper error condition. It identifies the FDW error class, not a particular remote failure, callback, or retry policy. No direct ERRCODE_FDW_ERROR report group was resolved in the PostgreSQL 18.6 core/contrib scan; the concrete trigger therefore depends on the installed implementation.

An FDW callback may report its own SQLSTATE, and a wrapper that talks to another system may forward a remote diagnostic. Record the complete diagnostic and the foreign table, server, wrapper name/version, and operation before interpreting HV000.

Field Value
SQLSTATE HV000
Condition fdw_error
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_ERROR
Aliases

Meaning and scope

The 18.6 definition is HV000 E ERRCODE_FDW_ERROR fdw_error in the SQL/MED-specific Class HV. The FDW API exposes planning, scan, modification, import, and explanation callbacks; the executor invokes those callbacks through an FDW routine supplied by the installed wrapper. That API boundary explains why the condition is defined centrally while concrete implementations live in extensions.

postgres_fdw, file_fdw, and third-party FDWs implement the FDW callback API. dblink is a separate contrib client API that can itself use Class HV codes while talking to another PostgreSQL server; it is not an FDW callback implementation. A remote server’s SQLSTATE, a libpq connection error, and a wrapper’s locally raised error can all appear in one user operation, but they are not interchangeable evidence for HV000.

Messages and diagnostics

No stable 18.6 core message variant for HV000 was resolved in the archived call scan. Preserve C/SQLSTATE, S, V, M, D, H, W, F, L, and R where supplied, together with the wrapper callback or remote command. Do not substitute a generic “FDW error” string for the actual message.

Diagnosis

First identify the phase: planning, scan initialization, fetch, insert/update/delete, commit/rollback, schema import, or EXPLAIN. Then inspect the foreign table and server options, user mapping, wrapper extension version, and any remote connection log. For a remote PostgreSQL wrapper, compare the remote SQLSTATE and fields with the local wrapper error; they can describe different layers of the same failure.

The source scan covered PostgreSQL 18.6 core and bundled contrib sources; it does not cover every external wrapper, driver, remote database, or user-defined callback.

Response

Use the identified layer to choose the repair: correct the foreign server or user mapping, fix the wrapper option or callback contract, repair the remote operation, or install a compatible wrapper version. Retry only after checking whether the wrapper reached the remote system and whether a write may have been committed; HV000 alone does not establish either fact.

Do not catch every Class HV value and blindly retry. Preserve the original fields and consult the wrapper’s documented transaction and reconnect behavior.

Versions

The locked catalogue first observes HV000 in PostgreSQL 9.1.0 and includes it in every formal snapshot through 18.6 and the 19 Beta 3 preview. The pre-9 scan did not observe it in the available 7.4–8.4 definition files; that is a source boundary, not an exact introduction claim.

Compare HV001fdw_out_of_memory, HV002fdw_dynamic_parameter_value_needed, and HV00Bfdw_invalid_handle. Remote server conditions must be interpreted using the remote system’s own SQLSTATE and diagnostics.

Sources

  • errcodes.txt — fixed PostgreSQL 18.6 definition (src.errcodes.18.6, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba).
  • fdwapi.h — callback boundary (src.fdwapi.18.6).
  • nodeForeignscan.c — executor callback dispatch (src.nodeforeignscan.18.6).
  • FDW callback documentation — callback responsibilities and error boundary (doc.fdwhandler.18).
  • Structured evidence — fixed sources and bounded call-scan result.

282 - HV001 — fdw_out_of_memory

PostgreSQL SQLSTATE HV001 reports an FDW-side allocation failure. PostgreSQL’s bundled dblink and postgres_fdw paths use it while obtaining libpq connection options.

HV001 — fdw_out_of_memory

At a glance

HV001 is the SQL/MED condition for an FDW-side out-of-memory failure. In PostgreSQL 18.6, the bundled postgres_fdw and dblink implementations use it when PQconndefaults() returns no option array, and postgres_fdw also uses it when its option copy cannot be allocated.

The fixed source messages are out of memory, optionally with detail Could not get libpq's default connection options. This is an ERROR; whether the remote operation ran is phase-specific.

Field Value
SQLSTATE HV001
Condition fdw_out_of_memory
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_OUT_OF_MEMORY
Aliases

Meaning and trigger paths

postgres_fdw calls PQconndefaults() while building its option list; a null result is treated as an allocation failure and reported with HV001. A later malloc for the copied options has the same code but only the primary message. dblink has two corresponding option-discovery paths. These are wrapper implementation details, not proof that every HV001 means the backend allocator exhausted all memory.

Messages and diagnostics

The 18.6 source variants are:

  • ERROR: out of memory, with detail Could not get libpq's default connection options. in contrib/dblink/dblink.c:1972-1974, :2908-2910, and contrib/postgres_fdw/option.c:317-319.
  • ERROR: out of memory without detail in contrib/postgres_fdw/option.c:340-341.

Keep the function phase and wrapper name. The message is not a remote server response.

Diagnosis

Capture SQLSTATE and all fields, then identify whether failure occurred while reading FDW/server options or while establishing a dblink/postgres_fdw connection. Inspect backend memory pressure, process limits, and the wrapper/library versions. If the detail names libpq defaults, first distinguish a PQconndefaults() allocation failure from a libpq installation or configuration problem; check the local library path/version only as supporting evidence before debugging the remote SQL.

Response

Reduce concurrent memory pressure and check the backend process/container limits, then retry the same option-discovery operation only after the allocation failure is understood. If the server actually reports 53200, follow that SQLSTATE’s diagnostic; do not relabel a confirmed HV001 merely because an allocation failed. For a write path, establish from the callback phase and remote logs whether any remote command was sent before retrying; HV001 alone is not a whole-transaction retry signal.

Versions

The catalogue first observes HV001 in 9.1.0 and retains it through 18.6 and 19 Beta 3. The 18.6 implementation paths and exact capitalization above are fixed to commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; older variants may differ.

HV000 is the generic FDW condition. HV002 is a missing wrapper parameter. 53200 is the generic backend out-of-memory condition and should not be substituted without evidence that the backend, rather than the FDW path, raised the error.

Sources

283 - HV002 — fdw_dynamic_parameter_value_needed

PostgreSQL SQLSTATE HV002 reports a required FDW parameter that is unavailable. file_fdw raises it when a foreign table has neither filename nor program.

HV002 — fdw_dynamic_parameter_value_needed

At a glance

HV002 says that an FDW operation needs a parameter value that was not available. PostgreSQL 18.6’s bundled file_fdw validator raises it during foreign-table option validation when neither filename nor program is supplied.

Field Value
SQLSTATE HV002
Condition fdw_dynamic_parameter_value_needed
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_DYNAMIC_PARAMETER_VALUE_NEEDED
Aliases

Meaning and trigger paths

In contrib/file_fdw/file_fdw.c, the validator checks ForeignTableRelationId options and raises ERROR with either filename or program is required for file_fdw foreign tables when both values are absent. The condition name is broader than this one implementation: another FDW may need a value at planning, scan, or modify time and report a different message.

Messages and diagnostics

The fixed 18.6 variant is ERROR: either filename or program is required for file_fdw foreign tables from file_fdw_validator, lines 345-350. The fixed 9.1.24 source uses ERROR: filename is required for file_fdw foreign tables; neither source template adds a detail or hint. These are local option-validation errors; they do not mean a remote program failed to start.

Diagnosis

Inspect the exact CREATE FOREIGN TABLE or ALTER FOREIGN TABLE ... OPTIONS definition and the wrapper’s accepted option names. For file_fdw, check that exactly one usable source option is present and that its value is visible to the server process. For another wrapper, locate its validator or callback and read its own required-parameter contract.

Response

Add the required FDW option with the correct spelling and permissions, or use the wrapper’s supported dynamic parameter mechanism. Re-run validation or the original operation after checking the foreign server and table identity. Retrying unchanged SQL cannot provide a missing value and is not a recovery strategy.

Versions

HV002 is observed from 9.1.0 through 18.6 and the 19 Beta 3 preview. The fixed 9.1.24 file_fdw source uses “filename is required”, while the fixed 18.6 source uses “either filename or program is required”; use the server version when matching the message. This does not claim the exact release where the wording changed.

HV00D concerns an option name the wrapper does not recognize. HV000 is a generic wrapper failure. HV005 concerns a missing foreign column rather than a missing FDW option.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • file_fdw.c — validator condition and message.
  • Historical file_fdw.c 9.1.24 — fixed filename-only validator message, SHA-256 6f948ed8f9ffa6d1077b289f23c53eff02c5182492f0827b908c2be86026dad8.
  • Structured evidence — source path and historical message boundary.

284 - HV004 — fdw_invalid_data_type

PostgreSQL SQLSTATE HV004 denotes a foreign-data-wrapper data type mismatch. Confirm the wrapper’s type mapping and the local foreign-table definition.

HV004 — fdw_invalid_data_type

At a glance

HV004 is the SQL/MED condition for a foreign-data-wrapper data type that cannot be used for the requested operation. The 18.6 core/contrib call scan found no resolved direct HV004 report group, so this page does not claim a particular bundled message or SQL trigger.

Field Value
SQLSTATE HV004
Condition fdw_invalid_data_type
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_INVALID_DATA_TYPE
Aliases

Meaning and scope

The condition belongs to the FDW callback boundary: a wrapper may reject a local column type, a remote type mapping, or a value conversion. PostgreSQL’s FDW documentation notes that a wrapper may raise an error for a data-type mismatch; it does not prescribe one universal mapping or message.

Messages and diagnostics

No fixed 18.6 message variant was resolved for this code. Keep the wrapper’s M, D, H, source file/function, local column type, remote type, and operation. A remote server’s type error must remain distinguishable from the wrapper’s local SQLSTATE.

Diagnosis

Identify the foreign table column and conversion direction, then inspect the wrapper’s validator, deparser, and tuple conversion code at its pinned version. Compare the local catalog type, collation/typmod where relevant, and the remote type metadata. A generic cast failure or 22xxx value error is not evidence for HV004.

Response

Use a supported type mapping or alter the foreign-table definition after checking data compatibility. If conversion is implemented by an external wrapper, upgrade or configure that wrapper only after checking its compatibility contract. Do not retry an unchanged plan; a data-type mismatch is deterministic for the same metadata.

Versions

The catalogue observes HV004 from 9.1.0 through 18.6 and 19 Beta 3. The available pre-9 definition scan did not observe it; no exact introduction version is claimed.

Compare HV006 for inconsistent type descriptors and HV007 for an invalid column name. 42804 is a core datatype mismatch and has a different ownership boundary.

Sources

285 - HV005 — fdw_column_name_not_found

PostgreSQL SQLSTATE HV005 denotes a foreign column name that the FDW cannot find. Check the wrapper’s remote descriptor and name mapping.

HV005 — fdw_column_name_not_found

At a glance

HV005 is the SQL/MED condition for a foreign column name that the wrapper cannot find in the relevant remote or imported descriptor. No direct HV005 report group was resolved in the PostgreSQL 18.6 core/contrib scan, so the concrete remote system and message remain wrapper-specific.

Field Value
SQLSTATE HV005
Condition fdw_column_name_not_found
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_COLUMN_NAME_NOT_FOUND
Aliases

Meaning and scope

This code concerns name lookup at an FDW boundary: an imported or planned column name is absent from the descriptor the wrapper is using. It is narrower than a missing foreign table and different from a local 42703 undefined column.

Messages and diagnostics

No fixed core message is available. Preserve the exact name, case-folding/quoting context, foreign table or remote relation, wrapper version, and whether the failure occurred during import, planning, scan, or modification.

Diagnosis

Compare pg_attribute for the foreign table with the wrapper’s remote metadata and name-translation rules. Re-run schema discovery or inspect the wrapper’s import mapping where applicable. Do not infer a remote column simply from the local target list.

Response

Correct the foreign-table column definition or the wrapper’s name mapping, then refresh the remote schema metadata as its documentation requires. Retry after the descriptor agrees; changing transaction retry policy cannot create a missing column.

Versions

HV005 is observed from 9.1.0 through 18.6 and the 19 Beta 3 preview. Pre-9 definition files in the locked scan did not contain it, so the precise introduction is unknown.

HV007 concerns an invalid column name supplied to a descriptor API; HV008 concerns an invalid ordinal. 42703 is PostgreSQL’s local undefined-column condition.

Sources

286 - HV006 — fdw_invalid_data_type_descriptors

PostgreSQL SQLSTATE HV006 denotes inconsistent or unusable FDW data-type descriptors. Inspect the wrapper metadata contract before changing SQL.

HV006 — fdw_invalid_data_type_descriptors

At a glance

HV006 covers invalid data-type descriptor information at an FDW boundary. PostgreSQL 18.6 defines it but the core/contrib call scan resolved no direct report group, so no bundled wrapper message or natural SQL reproduction is claimed.

Field Value
SQLSTATE HV006
Condition fdw_invalid_data_type_descriptors
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_INVALID_DATA_TYPE_DESCRIPTORS
Aliases

Meaning

The condition is about the descriptor metadata itself: a wrapper’s type OID, length, precision, typmod, or related descriptor fields can be inconsistent with the callback contract. It is distinct from a single value that fails conversion (HV004).

Messages and diagnostics

No fixed core message was found. Record descriptor field names and values, local and remote relation identities, callback phase, wrapper version, and any remote metadata response. Do not manufacture a message from the condition name.

Diagnosis

Trace the descriptor from schema import/planning through tuple conversion. Inspect the wrapper source for the callback that builds or consumes it, then compare it with fdwapi.h and the wrapper’s pinned documentation. A stale extension binary or changed remote schema is a more useful lead than a generic SQL retry.

Response

Refresh or correct the wrapper’s descriptor construction and align the foreign-table metadata with the remote schema. If the issue follows an extension upgrade, test the matching wrapper/server ABI. Retry only after the descriptor is corrected.

Versions

The code is present in all locked formal snapshots from 9.1.24 through 18.6 and in 19 Beta 3; the earliest locked definition is 9.1.0. No pre-9 definition observation is available.

HV004 is a data-type mismatch; HV021 concerns inconsistent descriptor information more generally; HV006 focuses on data-type descriptor fields.

Sources

287 - HV007 — fdw_invalid_column_name

PostgreSQL SQLSTATE HV007 denotes an invalid column name passed through an FDW descriptor or callback. Check wrapper naming rules and quoting.

HV007 — fdw_invalid_column_name

At a glance

HV007 is an FDW-specific invalid-column-name condition. The 18.6 core/contrib scan found no direct report group, so the wrapper that validates the name and its message must be identified from the actual deployment.

Field Value
SQLSTATE HV007
Condition fdw_invalid_column_name
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_INVALID_COLUMN_NAME
Aliases

Meaning

The name reached the FDW API but violates the wrapper’s accepted descriptor or remote naming rules. That is different from HV005, where a name is valid in form but cannot be found, and from core 42703 on a local SQL query.

Messages and diagnostics

No fixed PostgreSQL core message is confirmed. Preserve the original quoted/unquoted name, case folding, foreign table, callback phase, and wrapper version.

Diagnosis

Inspect the wrapper’s name parser and remote identifier rules. Compare pg_attribute.attname, generated query identifiers, and any quoted or case-sensitive remote names. Locate the wrapper’s pinned source before assigning a repair to PostgreSQL itself.

Response

Use a name accepted by both the local foreign-table definition and the remote system, or configure the wrapper’s explicit name mapping. Rebuild the foreign descriptor after changing metadata; repeating the same statement is not useful.

Versions

HV007 is present from 9.1.0 through 18.6 and 19 Beta 3. The available pre-9 source definition scan did not observe this SQLSTATE.

HV005 is “column name not found”; HV008 is an invalid column number; 42703 is the local undefined-column code.

Sources

288 - HV008 — fdw_invalid_column_number

PostgreSQL SQLSTATE HV008 denotes an invalid foreign-column ordinal. Inspect the wrapper descriptor and local-to-remote column mapping.

HV008 — fdw_invalid_column_number

At a glance

HV008 identifies an invalid column number (ordinal) in an FDW descriptor or callback. PostgreSQL 18.6 defines it, but its core/contrib call scan found no direct report group or bundled message.

Field Value
SQLSTATE HV008
Condition fdw_invalid_column_number
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_INVALID_COLUMN_NUMBER
Aliases

Meaning

The wrapper received or produced an ordinal that is outside the descriptor it is using. This is a mapping/descriptor issue, not evidence that a user SQL column name is absent (HV005) or malformed (HV007).

Messages and diagnostics

No fixed core message is confirmed. Keep the ordinal, descriptor width, local relation identity, callback phase, and wrapper/remote metadata version.

Diagnosis

Compare the target list and pg_attribute.attnum values with the wrapper’s remote column array. Check dropped columns, projection rewrites, and schema changes between planning and execution. Read the installed wrapper source for the callback that indexes the descriptor.

Response

Refresh the foreign-table mapping or correct the wrapper’s ordinal translation, then plan the statement again. Do not mask the error by dropping arbitrary columns; the correct repair depends on which descriptor boundary supplied the invalid ordinal.

Versions

HV008 is observed in every locked formal snapshot beginning at 9.1.0 through 18.6 and in 19 Beta 3. It was not observed in the available pre-9 definition files.

HV005 concerns a missing name, HV007 an invalid name, and HV006 invalid type descriptor metadata.

Sources

289 - HV009 — fdw_invalid_use_of_null_pointer

PostgreSQL SQLSTATE HV009 denotes an FDW null-pointer contract violation. Identify the wrapper callback and preserve the failure context.

HV009 — fdw_invalid_use_of_null_pointer

At a glance

HV009 describes an invalid null-pointer use at the FDW boundary. The PostgreSQL 18.6 core/contrib scan found no direct resolved report group, so no safe SQL reproduction or bundled message is claimed.

Field Value
SQLSTATE HV009
Condition fdw_invalid_use_of_null_pointer
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_INVALID_USE_OF_NULL_POINTER
Aliases

Meaning

The condition is intended for a wrapper/API contract violation involving a null pointer, such as an absent descriptor, handle, or callback result that the wrapper treats as present. It is not a generic SQL NULL value error and cannot be inferred from a nullable column.

Messages and diagnostics

No fixed core message variant was found. Preserve the pointer-owning callback, handle/descriptor identity, wrapper build, and full server log. A crash, XX000, or a driver exception may occur instead depending on the implementation.

Diagnosis

Treat this as a wrapper defect or contract mismatch until source proves otherwise. Inspect the callback implementation and ABI/API version, then check whether a remote disconnect or failed allocation created the null state. Do not dereference or “repair” the object from SQL.

Response

Stop retrying the same operation while the wrapper defect is present. Preserve logs and isolate the foreign server/table, then upgrade or patch the wrapper after reproducing in a disposable environment. If the process or connection terminated, follow that component’s recovery procedure.

Versions

The condition is observed from 9.1.0 through 18.6 and the 19 Beta 3 preview; pre-9 definition scans did not observe it. No implementation introduction version is claimed.

HV00B is an invalid FDW handle; XX000 is a broader internal-error boundary. A normal SQL null-value condition is in Class 22.

Sources

290 - HV00A — fdw_invalid_string_format

PostgreSQL SQLSTATE HV00A denotes a string format that an FDW cannot accept. Confirm the wrapper’s format grammar and the operation phase.

HV00A — fdw_invalid_string_format

At a glance

HV00A is the SQL/MED condition for an invalid string format at an FDW boundary. PostgreSQL 18.6’s core/contrib call scan found no resolved direct report group, so the format grammar and message must come from the installed wrapper or remote driver.

Field Value
SQLSTATE HV00A
Condition fdw_invalid_string_format
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_INVALID_STRING_FORMAT
Aliases

Meaning

The wrapper rejected a string because its syntax, escaping, encoding, or format fields do not satisfy the wrapper contract. The condition does not identify whether the string was an option, a remote identifier, a serialized value, or a driver response.

Messages and diagnostics

No fixed core message is confirmed. Keep the operation, option or field name, original encoding/quoting, wrapper version, and any remote diagnostic. Do not rewrite the string based only on the condition name.

Diagnosis

Locate the wrapper’s parser or conversion function and compare the exact input with its pinned grammar. Check server encoding and escaping only where that wrapper documents them. Distinguish a malformed FDW option from a remote SQL syntax error and from a value-format condition in Class 22.

Response

Correct the string according to the wrapper’s documented format, or use its structured option/API instead of hand-built text. Recreate the plan or foreign-table metadata after the change; retrying the unchanged string will reproduce the same validation result.

Versions

HV00A is present in the locked catalogue from 9.1.0 through 18.6 and in 19 Beta 3. It was not observed in the available pre-9 definition files; exact introduction remains unknown.

HV00D concerns an unrecognized option name; HV004 concerns a data-type mismatch. A core text/value format error may use a Class 22 code instead.

Sources

291 - HV00B — fdw_invalid_handle

PostgreSQL SQLSTATE HV00B identifies an invalid handle at an FDW or SQL/MED boundary. The actual handle owner and lifecycle must come from the installed wrapper.

HV00B — fdw_invalid_handle

At a glance

HV00B names an invalid FDW handle: a wrapper received a handle that is unknown, closed, or invalid for the current operation. The PostgreSQL 18.6 core/contrib call scan has no resolved direct HV00B report group, so the handle type and message are implementation-specific.

Field Value
SQLSTATE HV00B
Condition fdw_invalid_handle
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_INVALID_HANDLE
Aliases

Meaning

SQL/MED uses “handle” for an implementation-owned reference, not a PostgreSQL relation OID or a SQL transaction ID. A wrapper might use one for a remote connection, cursor, reply, or execution object; these are possible examples, not an established emitter path in this batch. The class definition alone does not identify which one.

Messages and diagnostics

No direct 18.6 core/contrib message variant was resolved. Record the wrapper name/version, handle kind and lifetime, callback phase, foreign server/table, and the complete diagnostic. A remote server’s connection failure may be a different SQLSTATE.

Diagnosis

Trace creation, transfer, reuse, and close of the handle in the wrapper source. Check whether a scan or modification callback outlived a connection, whether a callback ran after cleanup, and whether the wrapper’s ABI matches the server. Do not infer that a NULL SQL value is an invalid handle.

Response

Repair the wrapper’s handle lifecycle or recreate the wrapper-owned connection/object according to its API. If the wrapper cannot establish whether a write completed, inspect remote logs before repeating it. An unchanged request is unlikely to repair a stale or closed handle.

Versions

HV00B is present from 9.1.0 through 18.6 and in 19 Beta 3. The available pre-9 definition scan did not observe it; this is a history boundary, not an exact introduction claim.

HV00K concerns a reply handle; HV009 concerns invalid null-pointer use; HV00N concerns establishing a connection.

Sources

292 - HV00C — fdw_invalid_option_index

PostgreSQL SQLSTATE HV00C identifies an invalid FDW option index. Confirm the wrapper’s option array and index contract before changing server options.

HV00C — fdw_invalid_option_index

At a glance

HV00C identifies an option index that is invalid for the FDW option collection in use. No direct HV00C report group was resolved in the PostgreSQL 18.6 core/contrib scan, so no specific option array or message is attributed.

Field Value
SQLSTATE HV00C
Condition fdw_invalid_option_index
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_INVALID_OPTION_INDEX
Aliases

Meaning

This condition concerns an ordinal into a wrapper’s option representation. It is different from HV00D, where the option name is rejected, and from HV00J, whose name says the option was not found in dblink’s option set.

Messages and diagnostics

No fixed 18.6 message is confirmed. Preserve the option index, option scope (wrapper/server/table/user mapping), wrapper version, and callback or validation phase.

Diagnosis

Read the installed wrapper’s option enumeration and the code that consumes the index. Check stale cached metadata, an extension/server ABI mismatch, and whether an option list was reordered between planning and execution. Do not treat a SQL option spelling error as an index error without the wrapper source.

Response

Refresh or rebuild the wrapper-owned option list and use the option API expected by that wrapper. Correct a stale extension or mapping before retrying; changing an unrelated FDW option does not repair an invalid index.

Versions

The catalogue observes HV00C from 9.1.0 through 18.6 and in 19 Beta 3. It was not observed in the available pre-9 definition files.

HV00D is an invalid option name; HV00J is dblink’s option-name-not-found condition; HV008 is an invalid foreign-column number.

Sources

293 - HV00D — fdw_invalid_option_name

PostgreSQL SQLSTATE HV00D reports an option name that the FDW implementation does not accept. file_fdw and postgres_fdw provide concrete validation messages and hints.

HV00D — fdw_invalid_option_name

At a glance

HV00D is raised when an FDW option name is not valid in the current wrapper context. PostgreSQL 18.6 has direct paths in file_fdw, postgres_fdw, and the postgres_fdw import option parser.

Field Value
SQLSTATE HV00D
Condition fdw_invalid_option_name
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_INVALID_OPTION_NAME
Aliases

Meaning and messages

The option is checked against the wrapper’s valid options for its context: FDW, server, foreign table, user mapping, or import. The 18.6 primary template is invalid option "%s". file_fdw and postgres_fdw/option.c add Perhaps you meant the option "%s". only when a close match exists; if valid options exist but no close match is found, the source emits no hint, and There are no valid options in this context. is used only when no valid option exists. The postgres_fdw import parser has only the primary message.

Diagnosis

Record the object being altered and the wrapper version, then read that wrapper’s validator and option list. Check whether an option belongs on the foreign server, foreign table, or user mapping; identical names can be valid in one scope and invalid in another. Preserve the hint’s close match instead of guessing from a different wrapper.

Response

Use the option name and scope accepted by the installed wrapper, or remove the unsupported option. If the option was introduced by a newer extension, align the extension and server versions after confirming that is the cause. Retrying the same definition cannot change validation.

Messages and diagnostics

The fixed 18.6 call groups are file_fdw/file_fdw.c:248-253, postgres_fdw/option.c:110-116, and postgres_fdw/postgres_fdw.c:5491-5493; all are ERROR. Their %s values are dynamic option names and close matches.

Versions

HV00D is present from 9.1.0 through 18.6 and 19 Beta 3. A fixed REL9_6_24 snapshot of the file_fdw and postgres_fdw validators uses the older Valid options in this context are: %s hint, while the fixed 18.6 paths use the closest-match/no-valid-options branches. These two snapshots bound the wording; they do not establish the exact transition release, so match the installed version when comparing logs.

HV00C concerns an option index, HV00J is dblink’s option-name-not-found code, and HV00A concerns string format rather than option identity.

Sources

294 - HV00J — fdw_option_name_not_found

PostgreSQL SQLSTATE HV00J is dblink’s option-name-not-found condition. It is separate from FDW option validation in postgres_fdw and file_fdw.

HV00J — fdw_option_name_not_found

At a glance

HV00J is used by dblink’s connection-option validation when an option name is not in the accepted dblink/libpq option set. dblink is a separate contrib client API, not an FDW callback implementation. The 18.6 core/contrib scan found no other resolved HV00J group.

Field Value
SQLSTATE HV00J
Condition fdw_option_name_not_found
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_OPTION_NAME_NOT_FOUND
Aliases

Meaning and messages

At dblink.c:2005-2011, dblink reports ERROR with invalid option "%s". It adds Perhaps you meant the option "%s". only when a close match is available; if valid options exist but no close match is found, the source emits no hint, and There are no valid options in this context. is used only when no valid option exists. A fixed REL9_6_24 dblink snapshot shows the older dynamic Valid options in this context are: %s hint; this is a bounded comparison, not an exact transition claim.

Diagnosis

Identify whether the option belongs to a dblink connection string/option list and check the installed libpq option names. Keep the exact option name, dblink/libpq versions, and whether the failure occurred while parsing a connection definition. Do not apply postgres_fdw option tables to dblink.

Response

Replace the name with the accepted dblink/libpq option or remove it, preserving the close-match hint as a guide. Validate the connection definition again; an invalid option name is deterministic and does not call for a database transaction retry.

Diagnosis boundary

The confirmed implementation is dblink’s option parser at contrib/dblink/dblink.c:2005-2011; no natural runtime was run in this batch, and the source does not establish remote connection success or failure.

Versions

The code is present from 9.1.0 through 18.6 and 19 Beta 3. The fixed 18.6 and REL9_6_24 dblink snapshots show different hint wording; they bound the observed versions without dating the transition. Match the installed version when interpreting a log.

HV00D covers file_fdw/postgres_fdw option names; HV00N concerns establishing a connection; HV001 covers an allocation failure while obtaining libpq defaults.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • dblink.c — 18.6 dblink option parser.
  • dblink.c in REL9_6_24 — bounded historical hint comparison; SHA-256 ff331aac2153e21aa88cc6c4e656ab00b0593744062270849f27281434db3b55.
  • Structured evidence — exact message/detail/hint grouping.

295 - HV00K — fdw_reply_handle

PostgreSQL SQLSTATE HV00K identifies an FDW reply-handle condition. The reply lifecycle and operation phase must be read from the installed wrapper.

HV00K — fdw_reply_handle

At a glance

HV00K is the SQL/MED reply-handle condition. PostgreSQL 18.6 defines it, but the locked core/contrib scan has no direct resolved HV00K report group; the condition does not by itself say whether a reply handle is missing, stale, or otherwise unusable.

Field Value
SQLSTATE HV00K
Condition fdw_reply_handle
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_REPLY_HANDLE
Aliases

Meaning

An FDW that executes asynchronously or in stages may keep a handle for a remote reply. The API definition does not prescribe the handle representation or a universal state machine. Do not equate this condition with HV00B unless the wrapper’s source identifies the same object.

Messages and diagnostics

No fixed 18.6 message is confirmed. Preserve the reply/operation identity, callback phase, remote request status, wrapper version, and all protocol fields.

Diagnosis

Locate the wrapper’s request submission and reply-consumption code. Check whether the handle was consumed twice, released early, or used after a remote cancellation/disconnect. The source scan does not establish behavior for external wrappers.

Response

Follow the wrapper’s reply lifecycle and recreate the remote request only when its API says that is safe. For writes, establish completion from the remote system before repeating a request; HV00K alone is not a retry guarantee.

Versions

HV00K is observed from 9.1.0 through 18.6 and 19 Beta 3; pre-9 definition files did not contain it. No exact implementation introduction is claimed.

HV00B is a generic invalid handle; HV00L concerns creating an execution object; HV00M concerns creating a reply object.

Sources

296 - HV00L — fdw_unable_to_create_execution

PostgreSQL SQLSTATE HV00L identifies an FDW failure to create an execution object. Inspect the wrapper’s remote execution setup and resource contract.

HV00L — fdw_unable_to_create_execution

At a glance

HV00L denotes an FDW implementation’s inability to create a remote execution object. No direct 18.6 core/contrib report group was resolved, so the object, remote API, and message are wrapper-specific.

Field Value
SQLSTATE HV00L
Condition fdw_unable_to_create_execution
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_UNABLE_TO_CREATE_EXECUTION
Aliases

Meaning

The condition name describes failure while a wrapper is creating an execution object before using it for the requested operation. It might involve a remote statement, cursor, plan, or driver object; only the wrapper source can identify which object and stage apply.

Messages and diagnostics

No fixed core message is confirmed. Record the wrapper, remote operation, connection state, option set, and the underlying driver/remote diagnostic if one exists.

Diagnosis

Read the wrapper’s execution creation function and classify the failure as local allocation, remote rejection, invalid options, or connection state. Check server/wrapper/driver versions and whether a prior request left the connection in an unusable state.

Response

Correct the identified option or connection state and recreate the execution object through the wrapper API. For a write, confirm that no remote execution began before repeating it; the condition alone does not establish that boundary.

Versions

The directory contains HV00L from 9.1.0 through 18.6 and 19 Beta 3. The available pre-9 definitions do not show it.

HV00M concerns reply-object creation; HV00N concerns connection establishment; HV001 covers a specific option-allocation path.

Sources

297 - HV00M — fdw_unable_to_create_reply

PostgreSQL SQLSTATE HV00M identifies an FDW failure to create a reply object. Diagnose the wrapper’s result-channel setup separately from execution creation.

HV00M — fdw_unable_to_create_reply

At a glance

HV00M denotes failure to create an FDW reply object or result channel. The PostgreSQL 18.6 core/contrib scan has no direct resolved report group; the exact object and driver boundary must be read from the installed wrapper.

Field Value
SQLSTATE HV00M
Condition fdw_unable_to_create_reply
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_UNABLE_TO_CREATE_REPLY
Aliases

Meaning

An FDW may create an execution and a separate reply/result object. HV00M names failure of the latter setup; it does not prove that the remote statement was never sent.

Messages and diagnostics

No fixed core message is confirmed. Keep the operation, reply format, connection/handle state, wrapper and driver versions, and any remote diagnostic.

Diagnosis

Trace reply allocation/registration and the point at which the execution object was created. Distinguish local result-buffer failure from a remote protocol rejection. Check whether cleanup left a stale reply handle.

Response

Repair the wrapper’s result-channel setup and clean up the affected handle according to its API. Before repeating a write, establish remote completion from the wrapper or remote logs; HV00M does not make an automatic retry safe.

Versions

HV00M is present from 9.1.0 through 18.6 and in 19 Beta 3; no pre-9 definition observation is available.

HV00L covers execution-object creation; HV00K covers a reply handle; HV00B covers an invalid generic handle.

Sources

298 - HV00N — fdw_unable_to_establish_connection

PostgreSQL SQLSTATE HV00N identifies an FDW connection-establishment failure. The actual connection layer and diagnostic must come from the wrapper.

HV00N — fdw_unable_to_establish_connection

At a glance

HV00N is the SQL/MED condition for an FDW unable to establish its connection. No direct 18.6 core/contrib HV00N report group was resolved. Do not use the condition name to choose between DNS, authentication, TLS, network, or remote-server causes.

Field Value
SQLSTATE HV00N
Condition fdw_unable_to_establish_connection
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_UNABLE_TO_ESTABLISH_CONNECTION
Aliases

Meaning

The condition name describes a wrapper connection-setup boundary. postgres_fdw and dblink have their own concrete connection and libpq paths, but the 18.6 paths in this batch use other SQLSTATEs; they are not evidence for HV00N.

Messages and diagnostics

No fixed core message is confirmed. Preserve wrapper/driver version, foreign server and user mapping, connection parameters (excluding secrets), local and remote logs, and whether authentication or transport was reached.

Diagnosis

Locate the wrapper’s connection function and classify the first failing layer: name resolution, socket/TLS, authentication, protocol negotiation, or remote admission. Compare the wrapper’s SQLSTATE with any driver or remote code; they can differ.

Response

Correct the identified endpoint, credentials, network/TLS configuration, or server admission rule, then establish a fresh connection using the wrapper’s API. For writes, do not replay an operation until logs show whether a prior connection reached the remote command stage.

Versions

The code is in locked definitions from 9.1.0 through 18.6 and 19 Beta 3; available pre-9 definitions do not contain it. Exact implementation introduction is unknown.

HV001 is a confirmed allocation path; HV00L concerns execution creation after setup; 08006 is a broader connection failure class.

Sources

299 - HV00P — fdw_no_schemas

PostgreSQL SQLSTATE HV00P reports that an FDW does not support IMPORT FOREIGN SCHEMA. The core command checks the wrapper callback directly.

HV00P — fdw_no_schemas

At a glance

HV00P is raised by the core IMPORT FOREIGN SCHEMA command when the selected FDW has no ImportForeignSchema callback. It means the wrapper does not support that import mechanism, not that a remote schema is empty.

Field Value
SQLSTATE HV00P
Condition fdw_no_schemas
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_NO_SCHEMAS
Aliases

Meaning and message

foreigncmds.c:1527-1530 reports ERROR: foreign-data wrapper "%s" does not support IMPORT FOREIGN SCHEMA when fdw_routine->ImportForeignSchema is NULL. The wrapper name is dynamic; no remote schema query has necessarily run.

Diagnosis

Confirm the FDW named by the SERVER clause and inspect its handler’s ImportForeignSchema callback. Distinguish this unsupported capability from HV00Q, where postgres_fdw supports import but cannot find the requested remote schema.

Response

Use explicit CREATE FOREIGN TABLE definitions, choose a wrapper that implements schema import, or add the supported wrapper callback. Reissuing the same IMPORT FOREIGN SCHEMA command against the same handler will produce the same capability error.

Messages and diagnostics

The confirmed severity is ERROR, with no detail or hint in this call group. Preserve fdwname, server identity, and the handler extension version.

Versions

The HV00P condition definition is present in the locked 9.1.0 snapshot and later, but that does not date IMPORT FOREIGN SCHEMA to 9.1. The command and its ImportForeignSchema callback are present in the fixed PostgreSQL 9.5.0 source snapshot; the current 18.6 branch is the source-backed message path described above. No pre-9 definition observation is available.

HV00Q is a remote-schema-not-found result from postgres_fdw; HV00D is invalid option name; HV000 is generic FDW error.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • foreigncmds.c — callback check and message.
  • fdwapi.hImportForeignSchema callback definition; SHA-256 572ba892e6435ca92d3b3bc84dde5bbd3160cc3a082693daab8daa835c4d2cd7.
  • foreigncmds.c in the REL9_5_0 snapshot — command and callback feature boundary; SHA-256 d2ab3a8883ed1e27c38a0a7ff83f0fc9d493c488d7e30f56eef7d1ae449f9a16.
  • Structured evidence — source path and bounded runtime scope.

300 - HV00Q — fdw_schema_not_found

PostgreSQL SQLSTATE HV00Q reports that postgres_fdw cannot find the requested remote schema during IMPORT FOREIGN SCHEMA.

HV00Q — fdw_schema_not_found

At a glance

HV00Q is a concrete postgres_fdw import error. Its remote connection runs an exact pg_catalog.pg_namespace lookup for the requested nspname; when the result count is not exactly one, the wrapper reports the remote schema by name.

Field Value
SQLSTATE HV00Q
Condition fdw_schema_not_found
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_SCHEMA_NOT_FOUND
Aliases

Meaning and message

In postgres_fdw.c:5515-5526, the import path sends SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname = ... on the mapped remote connection, checks PQntuples(res) != 1, and raises ERROR: schema "%s" is not present on foreign server "%s". The requested remote schema and server name are dynamic fields. The fixed query does not use the local search_path; a connection/query failure is handled earlier, while later remote privileges are a separate import concern.

Diagnosis

Check the IMPORT FOREIGN SCHEMA source name, remote database, mapped user, and the exact postgres_fdw server options. Confirm the mapped remote connection can run the fixed pg_catalog.pg_namespace lookup for the exact name; do not diagnose this branch from the local search_path. Distinguish a zero-or-unexpected-row result from a connection/query error reported earlier, and check remote schema/table privileges separately when the import proceeds.

Response

Use the remote schema’s exact name, create it remotely if appropriate, or import from the correct foreign server/database. In autocommit, rerun only after the remote catalog state or mapping is corrected. Inside an explicit transaction, an ERROR leaves the local transaction failed; issue ROLLBACK, or ROLLBACK TO a previously established and still usable SAVEPOINT, before retrying the corrected import. Do not replay the command inside an INERROR transaction.

Messages and diagnostics

The fixed call group is severity ERROR, primary message schema "%s" is not present on foreign server "%s", with no detail or hint. Keep the remote schema/server values and wrapper version.

Versions

HV00Q is present from 9.1.0 through 18.6 and 19 Beta 3. Older wording or catalog-query details may vary; the 18.6 path is fixed to commit 724edf9bde9d356724ad384a2e196edc3c9f80f7.

HV00P means the wrapper lacks schema-import support; 3D000 is a local database-not-found code; HV00D concerns invalid wrapper options.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • postgres_fdw.c — remote pg_namespace query, result check, and message.
  • Transaction and savepoint recovery — the explicit-transaction recovery boundary; fixed xact.sgml SHA-256 b48fbe8bd02ce3d1181a350c88c8baa6e11c73edc90a936e77b180daef328c5c.
  • Structured evidence — source path and message grouping.

301 - HV00R — fdw_table_not_found

PostgreSQL SQLSTATE HV00R names a table-not-found condition at an FDW boundary; the installed wrapper determines which table lookup and diagnostic are involved.

HV00R — fdw_table_not_found

At a glance

HV00R identifies a table-not-found condition in the FDW class. The locked PostgreSQL 18.6 core/contrib call scan has no resolved HV00R report group, so it does not identify a core emitter, remote catalog, or message template.

Field Value
SQLSTATE HV00R
Condition fdw_table_not_found
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_TABLE_NOT_FOUND
Aliases

Meaning

The condition name points to a table lookup that an FDW operation could not satisfy. That table might be a remote object, a wrapper-side mapping, or another implementation-owned name; the SQLSTATE definition does not choose among them.

Messages and diagnostics

No resolved 18.6 core/contrib message variant was found for HV00R. Preserve the complete diagnostic, wrapper and driver versions, foreign server/table identity, operation phase, and any remote message before interpreting the condition.

Diagnosis

Locate the installed wrapper’s table lookup and its SQLSTATE mapping. Check the exact foreign table or remote relation name, database/schema context, mapped user, and whether the failure occurred during planning, execution, or metadata discovery. Do not assume that every zero-row query means this condition.

Response

Correct the table or mapping identified by the wrapper, or use the remote object and server that the operation actually names. If the wrapper cannot establish whether a preceding write completed, inspect remote state before repeating it; changing an unrelated FDW option will not explain the condition.

Versions

HV00R is present in the locked definition snapshots from 9.1.24 through 18.6 and 19 Beta 3, with known_present_by 9.1.0. The available pre-9 definition material does not establish an exact introduction release.

HV021 concerns inconsistent descriptor information; HV010 concerns FDW function sequencing; HV00Q is a concrete postgres_fdw remote-schema condition.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • fdwapi.h — generic FDW callback boundary.
  • Structured evidence — fixed 18.6 sources and bounded scan.

302 - HV010 — fdw_function_sequence_error

PostgreSQL SQLSTATE HV010 names an FDW function-sequence condition; the wrapper and callback phase must be identified from the actual implementation.

HV010 — fdw_function_sequence_error

At a glance

HV010 indicates that an FDW function was called in an invalid sequence. The fixed 18.6 core/contrib call scan has no resolved HV010 report group, so it does not establish a native callback or message.

Field Value
SQLSTATE HV010
Condition fdw_function_sequence_error
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_FUNCTION_SEQUENCE_ERROR
Aliases

Meaning

The condition is about the order or lifecycle of wrapper operations. fdwapi.h defines callback entry points such as planning and foreign-scan callbacks, but that API background does not emit HV010 or define every wrapper’s legal sequence.

Messages and diagnostics

No resolved 18.6 core/contrib message variant was found. Keep the complete message, callback name, operation phase, wrapper/driver version, and whether the call followed planning, scan start, iteration, rescan, modification, or cleanup.

Diagnosis

Trace the wrapper’s state machine around the failing callback. Verify which object was initialized, whether the callback was repeated or skipped, and whether cleanup ran before a later call. Use the wrapper’s own contract and source mapping to decide whether the reported sequence is local or remote.

Response

Restore the sequence required by the installed wrapper and its callback contract, then validate the same operation from a fresh object state. Avoid repeating a callback blindly: a wrapper may have already issued a remote request or released its state.

Versions

HV010 is present in the locked definition snapshots from 9.1.24 through 18.6 and 19 Beta 3, with known_present_by 9.1.0. The available pre-9 definition material does not prove an exact introduction release.

HV00B concerns an invalid handle; HV00K concerns a reply handle; HV009 concerns invalid null-pointer use.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • fdwapi.h — generic FDW callback boundary.
  • Structured evidence — fixed 18.6 sources and bounded scan.

303 - HV014 — fdw_too_many_handles

PostgreSQL SQLSTATE HV014 names an FDW handle-limit condition; the resource owner and limit come from the installed wrapper.

HV014 — fdw_too_many_handles

At a glance

HV014 identifies an FDW condition involving too many handles. No resolved HV014 report group was found in the locked PostgreSQL 18.6 core/contrib call scan, so no native handle limit or message is attributed.

Field Value
SQLSTATE HV014
Condition fdw_too_many_handles
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_TOO_MANY_HANDLES
Aliases

Meaning

A handle can be an implementation-owned reference to a connection, cursor, result, or execution object. The class definition does not specify the handle kind, scope of the limit, or whether the limit belongs to a wrapper, driver, or remote service.

Messages and diagnostics

No resolved 18.6 core/contrib message variant was found. Preserve the complete diagnostic, handle kind, count or limit if reported, operation phase, wrapper/driver version, and foreign server identity.

Diagnosis

Find the wrapper code that allocates or tracks handles and determine whether the limit is per statement, session, process, server, or remote connection. Check for handles that were not closed after errors, while keeping the wrapper’s own ownership rules as the authority.

Response

Close or release the handles that the wrapper identifies as no longer needed, or use its supported pooling/limit configuration after confirming the scope. If a failed operation may have sent work remotely, verify remote state before retrying it.

Versions

HV014 is present in the locked definition snapshots from 9.1.24 through 18.6 and 19 Beta 3, with known_present_by 9.1.0. The available pre-9 definition material does not establish an exact introduction release.

HV00B is an invalid handle condition; HV00K concerns a reply handle; HV00L concerns creating an execution object.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • fdwapi.h — generic FDW callback boundary.
  • Structured evidence — fixed 18.6 sources and bounded scan.

304 - HV021 — fdw_inconsistent_descriptor_information

PostgreSQL SQLSTATE HV021 names an FDW descriptor-consistency condition; the descriptor and producer must be identified from the wrapper implementation.

HV021 — fdw_inconsistent_descriptor_information

At a glance

HV021 identifies inconsistent information in an FDW descriptor. The 18.6 core/contrib call scan has no resolved HV021 report group, so it does not identify a core descriptor check or message.

Field Value
SQLSTATE HV021
Condition fdw_inconsistent_descriptor_information
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_INCONSISTENT_DESCRIPTOR_INFORMATION
Aliases

Meaning

The descriptor may describe columns, types, names, lengths, or another wrapper-owned result contract. fdwapi.h exposes callback and slot boundaries, but it does not say which descriptor mismatch maps to this SQLSTATE.

Messages and diagnostics

No resolved 18.6 core/contrib message variant was found. Preserve the full diagnostic, descriptor kind, expected and actual metadata when shown, callback phase, wrapper/driver version, and relation identity.

Diagnosis

Compare the descriptor supplied by the wrapper with the descriptor expected by the callback or consumer. Check schema changes, type and column order, nullability or length metadata only when the wrapper reports them; do not infer a mismatch from a generic conversion failure.

Response

Correct the wrapper’s descriptor construction or the remote/schema contract it actually identifies, then recreate the affected plan or object. Repeating the same operation without changing the mismatched metadata will not repair the descriptor.

Versions

HV021 is present in the locked definition snapshots from 9.1.24 through 18.6 and 19 Beta 3, with known_present_by 9.1.0. The available pre-9 definition material does not establish an exact introduction release.

HV008 concerns an FDW column sequence; HV091 concerns a descriptor field identifier; HV024 concerns an attribute value.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • fdwapi.h — generic FDW callback boundary.
  • Structured evidence — fixed 18.6 sources and bounded scan.

305 - HV024 — fdw_invalid_attribute_value

PostgreSQL SQLSTATE HV024 names an invalid FDW attribute value; the relevant attribute and validator are implementation-specific.

HV024 — fdw_invalid_attribute_value

At a glance

HV024 identifies an attribute value that an FDW boundary rejects. No resolved HV024 report group was found in the locked PostgreSQL 18.6 core/contrib call scan, so no particular attribute or message is confirmed.

Field Value
SQLSTATE HV024
Condition fdw_invalid_attribute_value
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_INVALID_ATTRIBUTE_VALUE
Aliases

Meaning

An attribute may be a wrapper option, descriptor property, column or connection attribute, depending on the implementation. The SQLSTATE definition does not provide the accepted value set or identify whether validation is local or remote.

Messages and diagnostics

No resolved 18.6 core/contrib message variant was found. Preserve the exact attribute name and value as rendered, operation phase, wrapper/driver version, foreign server/table, and any detail or hint.

Diagnosis

Locate the wrapper or driver validator named by the diagnostic and compare the value with that version’s documented or source-defined domain. Distinguish an invalid value from an unknown attribute name (HV00D may be relevant only when the actual SQLSTATE is HV00D).

Response

Use a value accepted by the identified validator, or change the object/remote definition that supplies it. Do not broaden the value or retry unchanged until the validator’s supported domain is known.

Versions

HV024 is present in the locked definition snapshots from 9.1.24 through 18.6 and 19 Beta 3, with known_present_by 9.1.0. The available pre-9 definition material does not establish an exact introduction release.

HV00D concerns an invalid option name; HV021 concerns inconsistent descriptor information; HV090 concerns string or buffer length.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • fdwapi.h — generic FDW callback boundary.
  • Structured evidence — fixed 18.6 sources and bounded scan.

306 - HV090 — fdw_invalid_string_length_or_buffer_length

PostgreSQL SQLSTATE HV090 names an FDW string or buffer length condition; the buffer owner and valid bounds come from the actual wrapper or driver.

HV090 — fdw_invalid_string_length_or_buffer_length

At a glance

HV090 identifies an invalid string length or buffer length at an FDW boundary. The locked 18.6 core/contrib call scan has no resolved HV090 report group, so it does not establish a native buffer check or message.

Field Value
SQLSTATE HV090
Condition fdw_invalid_string_length_or_buffer_length
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH
Aliases

Meaning

The condition can concern a string length, a destination buffer, or a wrapper-defined length field. The definition does not tell whether the invalid value was supplied by a remote response, a driver, or local wrapper code.

Messages and diagnostics

No resolved 18.6 core/contrib message variant was found. Preserve the complete diagnostic, length and buffer context if exposed, encoding or type context, callback phase, and wrapper/driver version.

Diagnosis

Trace the wrapper’s length validation and allocation boundary. Compare the value with the bounds and units used by that implementation, and distinguish bytes from characters only when the source or diagnostic supports it.

Response

Correct the producer or option that supplies the invalid length, or use the wrapper’s supported buffer/encoding path. Avoid truncating a value blindly; confirm the wrapper’s contract and whether a remote request has already been sent.

Versions

HV090 is present in the locked definition snapshots from 9.1.24 through 18.6 and 19 Beta 3, with known_present_by 9.1.0. The available pre-9 definition material does not establish an exact introduction release.

HV024 concerns an invalid attribute value; HV00A concerns invalid string format; HV091 concerns a descriptor field identifier.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • fdwapi.h — generic FDW callback boundary.
  • Structured evidence — fixed 18.6 sources and bounded scan.

307 - HV091 — fdw_invalid_descriptor_field_identifier

PostgreSQL SQLSTATE HV091 names an invalid FDW descriptor field identifier; the descriptor API and field namespace must come from the implementation.

HV091 — fdw_invalid_descriptor_field_identifier

At a glance

HV091 identifies a descriptor field identifier that an FDW boundary cannot use. No resolved HV091 report group was found in the locked PostgreSQL 18.6 core/contrib call scan, so no particular descriptor namespace or message is confirmed.

Field Value
SQLSTATE HV091
Condition fdw_invalid_descriptor_field_identifier
Status active
Known present by 9.1.0
Locked snapshots 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_FDW_INVALID_DESCRIPTOR_FIELD_IDENTIFIER
Aliases

Meaning

A field identifier may select a name, type, length, or other descriptor property in a wrapper-owned interface. Generic FDW callback signatures do not define this SQLSTATE’s field namespace.

Messages and diagnostics

No resolved 18.6 core/contrib message variant was found. Preserve the full diagnostic, descriptor kind, field identifier, expected namespace if reported, callback phase, and wrapper/driver version.

Diagnosis

Identify the descriptor producer and consumer, then compare the requested field identifier with that implementation’s documented or source-defined fields. Do not replace it with a column ordinal unless the wrapper explicitly defines that mapping.

Response

Use the field identifier supported by the actual descriptor interface, or correct the producer/consumer version mismatch when source evidence shows one. Repeating the same lookup cannot make an unknown identifier valid.

Versions

HV091 is present in the locked definition snapshots from 9.1.24 through 18.6 and 19 Beta 3, with known_present_by 9.1.0. The available pre-9 definition material does not establish an exact introduction release.

HV021 concerns inconsistent descriptor information; HV008 concerns an FDW column sequence; HV090 concerns string or buffer length.

Sources

  • errcodes.txt — definition, SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba.
  • fdwapi.h — generic FDW callback boundary.
  • Structured evidence — fixed 18.6 sources and bounded scan.

308 - P0000 — plpgsql_error

Source-backed reference for PostgreSQL SQLSTATE P0000.

P0000

At a glance

P0000 is the PL/pgSQL Error category entry. The bounded PostgreSQL 18.6 call archive has no resolved report group for the category code itself, so member-code paths remain separate.

Field Value
SQLSTATE P0000
Condition plpgsql_error
Status active
Known present by 8.0.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_PLPGSQL_ERROR
Aliases

Meaning

This is a category identity for PL/pgSQL errors. More specific members such as P0002, P0003, and P0004 have their own paths.

Diagnosis

Use the actual SQLSTATE in the ErrorResponse and inspect the concrete PL/pgSQL path; do not assign a member error to the category code.

Response

Handle the concrete member SQLSTATE and its documented PL/pgSQL operation. Category identity alone is not enough for a narrower repair.

Versions

The locked catalogue records this condition from 8.0.0 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

P0002, P0003, P0004

Sources

See the fixed source links, message templates, and scope limits in the structured evidence record.

309 - P0001 — raise_exception

PostgreSQL uses SQLSTATE P0001 for a PL/pgSQL RAISE EXCEPTION with no explicit condition or SQLSTATE. Diagnose the application control flow and recover at the correct transaction boundary.

At a glance

P0001 is the raise_exception condition in PostgreSQL’s PL/pgSQL-specific Class P0. A RAISE EXCEPTION statement with no condition name and no explicit SQLSTATE defaults to this code. The message is supplied by the function author, so P0001 is usually an application or procedure control signal rather than a diagnosis of one server subsystem.

The level and code are separate choices. EXCEPTION is the default RAISE level and normally aborts the current transaction. NOTICE, WARNING, INFO, LOG, and DEBUG generate messages without that exception behavior; an explicit ERRCODE can also choose a different SQLSTATE. Always capture the severity and SQLSTATE together.

The representative case plpgsql_raise_exception creates a function containing RAISE EXCEPTION 'calibration exception', calls it, and then runs SELECT 1 on the same autocommit connection. PostgreSQL 18.6 and 10.21 both returned P0001, preserved the message, left the connection IDLE, and accepted the follow-up query. The SQL excerpt below is the complete ordered function, call, and follow-up from the shared snippet registry; the runner owns the schema-qualified name and cleanup.

Field Value
SQLSTATE P0001
Condition raise_exception
Status active
Known present by 8.0.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_RAISE_EXCEPTION
Aliases

Meaning and trigger paths

The 18.6 directory places P0001 in Class P0, PL/pgSQL Error, and names it raise_exception. The class is PostgreSQL-specific. In the PL/pgSQL executor, the default code is assigned only when no code was supplied and the level is at least ERROR; the executor then reports the caller’s message and optional detail, hint, and object fields.

The syntax supports several distinct paths:

  • RAISE EXCEPTION 'message' uses P0001 by default.
  • RAISE EXCEPTION condition_name uses the condition’s SQLSTATE, so it need not be P0001.
  • RAISE EXCEPTION SQLSTATE '5-character-code' or RAISE ... USING ERRCODE = ... lets a procedure expose a domain-specific contract. PostgreSQL permits user-chosen five-character codes other than 00000.
  • A lower level such as RAISE WARNING 'message' emits a message at that priority. It is not the same transaction event as RAISE EXCEPTION, even if the caller chooses an explicit error code.

The no-argument RAISE; form is re-raise control inside an active exception handler. Its behavior and SQLSTATE are determined by the exception being re-raised; it is not a new default P0001 event.

Messages and diagnostics

The representative registry operation is:

CREATE FUNCTION raise_exception_case() RETURNS void
LANGUAGE plpgsql AS $$
BEGIN
    RAISE EXCEPTION 'calibration exception';
END
$$;
SELECT raise_exception_case();
SELECT 1;

The function name is schema-qualified and generated by the test executor in the actual run. The observed 18.6 diagnostic was:

SQLSTATE: P0001
severity: ERROR
message_primary: calibration exception
context: PL/pgSQL function ...raise_exception_case() line 3 at RAISE
source: pl_exec.c / exec_stmt_raise / line 3923

There is no universal English primary message for P0001; the function supplies it. USING MESSAGE, DETAIL, HINT, COLUMN, CONSTRAINT, DATATYPE, TABLE, and SCHEMA can add structured diagnostics. Localized message text can change while SQLSTATE remains stable, so branch on P0001 and inspect the structured fields rather than parsing the primary string.

Diagnosis

First determine whether the code came from an intentional RAISE EXCEPTION or from a different domain condition that the function explicitly selected. Record SQLSTATE, localized and nonlocalized severity, primary message, detail, hint, context, source location, and the statement that called the function. In a PL/pgSQL handler, SQLSTATE and SQLERRM identify the active exception, while GET STACKED DIAGNOSTICS retrieves its fields.

Then locate the function branch and its transaction context. A failed call in autocommit ends that statement and leaves the connection ready for another command, as the representative case shows. A call inside an explicit transaction normally leaves the transaction aborted until the client issues ROLLBACK or rolls back to a savepoint. The server connection is not necessarily terminated.

An EXCEPTION clause changes the boundary. The protected body runs in a subtransaction; when it errors, persistent changes made by that body are rolled back before the first matching condition handler runs, while changes made outside it remain. WHEN OTHERS matches every error except QUERY_CANCELED and ASSERT_FAILURE; it is broad and should not be used as a substitute for identifying the intended P0001 path.

Response

Use P0001 when the procedure intentionally exposes the generic PL/pgSQL raise contract. If callers need to distinguish validation, conflict, quota, or another business outcome, choose and document an appropriate SQLSTATE and add DETAIL or HINT that helps the caller act. Do not turn unrelated server errors into P0001 merely to simplify application code.

At the client boundary, roll back an explicit transaction before issuing unrelated commands, or use a savepoint when the caller can safely isolate the function call. In PL/pgSQL, prefer a narrow handler such as WHEN raise_exception or WHEN SQLSTATE 'P0001' when the recovery is specific. If a broad handler is required, preserve RETURNED_SQLSTATE, MESSAGE_TEXT, PG_EXCEPTION_DETAIL, PG_EXCEPTION_HINT, and context before deciding whether to continue or re-raise.

The natural RAISE EXCEPTION case is safe to demonstrate because it exercises the intended PL/pgSQL mechanism. That does not make P0001 evidence of a server fault; it is an explicit exception raised by the function.

Versions

The catalogue records P0001 in the locked 8.0.0–8.4.22 pre-9.0 formal sources, every formal snapshot from 9.0.23 through 18.6, and the 19 Beta 3 preview. The same-tag REL8_1_4 errcodes.sgml table already lists P0001 as raise_exception, confirming that condition-name observation by 8.1.4. The class title is PL/pgSQL Error (PostgreSQL-specific error class) in the 9.0 header view and changes to PL/pgSQL Error in the 9.1 text definition. Candidate source gaps remain for 7.0–7.3; these are observed catalogue boundaries, not asserted implementation introduction dates.

The fixed 18.6 source commit is 724edf9bde9d356724ad384a2e196edc3c9f80f7. The default RAISE EXCEPTION rule is documented for PostgreSQL 18 and source-confirmed in the 18.6 executor. The representative case passed on PostgreSQL 18.6 and 10.21; it does not test every custom code, handler, or transaction mode.

P0000plpgsql_error is the broader PL/pgSQL-specific class condition. P0002no_data_found, P0003too_many_rows, and P0004assert_failure are distinct P0 conditions. 25P02in_failed_sql_transaction describes the follow-on state after an unhandled exception aborts an explicit transaction. XX000internal_error is a server internal-error code and should not be used as a synonym for an intentional RAISE.

Sources

The structured evidence is recorded in the public evidence JSON. Source records are pinned to PostgreSQL commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; runtime records retain the shared snippet registry, both target summaries, and run P0001-snippet-registry-final-20260909.

310 - P0002 — no_data_found

Source-backed reference for PostgreSQL SQLSTATE P0002.

P0002

At a glance

P0002 is PL/pgSQL no_data_found. Fixed paths include the strict-query ERROR text and a separate tablespace NOTICE path; it does not mean every SELECT returning zero rows.

Field Value
SQLSTATE P0002
Condition no_data_found
Status active
Known present by 8.2.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NO_DATA_FOUND
Aliases

Meaning

A fixed PL/pgSQL strict-query path reports query returned no rows and may attach parameters: %s detail, while a tablespace path uses the same SQLSTATE for the NOTICE no matching relations in tablespace "%s" found. It does not mean every SELECT returning zero rows.

Diagnosis

Separate strict-query ERROR from the tablespace NOTICE by message and severity. A normal zero-row SELECT is not enough to establish P0002.

Response

Handle the strict no-row case explicitly. For the tablespace NOTICE, verify whether the empty match is intended; if it is, no repair is required, otherwise correct the target before continuing. Do not automatically replay a zero-row operation.

Versions

The locked catalogue records this condition from 8.2.0 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

P0003, P0004, 02000

Sources

See the fixed pl_exec.c and tablecmds.c paths alongside the structured evidence record.

311 - P0003 — too_many_rows

Source-backed reference for PostgreSQL SQLSTATE P0003.

P0003

At a glance

P0003 is PL/pgSQL too_many_rows. Fixed paths preserve the message, optional parameter detail, hint, and the source-selected severity boundary.

Field Value
SQLSTATE P0003
Condition too_many_rows
Status active
Known present by 8.2.0
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_TOO_MANY_ROWS
Aliases

Meaning

A fixed PL/pgSQL path reports query returned more than one row; the strict path may attach parameters: %s detail and the source-provided hint Make sure the query returns a single row, or use LIMIT 1.. The actual severity is branch-dependent.

Diagnosis

Check the strict or modifying-statement path and preserve the actual severity: plpgsql.extra_errors selecting too_many_rows takes precedence and makes the extra check ERROR; otherwise plpgsql.extra_warnings selecting it makes the extra check WARNING. Strict or modifying-statement paths use ERROR regardless of those settings. Ordinary multi-row SELECT behavior is not automatically P0003.

Response

Make the query satisfy the single-row contract or deliberately choose a multi-row structure; do not blindly replay business work.

Versions

The locked catalogue records this condition from 8.2.0 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

P0002, P0004, 02000

Sources

See the fixed pl_exec.c GUC branch and report paths alongside the structured evidence record.

312 - P0004 — assert_failure

Source-backed reference for PostgreSQL SQLSTATE P0004.

P0004

At a glance

P0004 is PL/pgSQL assert_failure. The fixed ASSERT path reports ERROR with either the evaluated message or assertion failed.

Field Value
SQLSTATE P0004
Condition assert_failure
Status active
Known present by 9.5.0
Locked snapshots 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_ASSERT_FAILURE
Aliases

The shared assertion_failure_recovery case passed on PostgreSQL 18.6 and PostgreSQL 10.21. With plpgsql.check_asserts enabled, the false ASSERT returned P0004 with value must be positive and left the explicit transaction INERROR; ROLLBACK restored IDLE, a valid input succeeded, and the disabled-assert control returned zero.

CREATE OR REPLACE FUNCTION p0004_assert(value integer) RETURNS integer LANGUAGE plpgsql AS $$ BEGIN ASSERT value > 0, 'value must be positive'; RETURN value; END $$;
SET plpgsql.check_asserts = on;
SHOW plpgsql.check_asserts;
BEGIN;
SELECT p0004_assert(0);
ROLLBACK;
SELECT p0004_assert(1);
SET plpgsql.check_asserts = off;
SHOW plpgsql.check_asserts;
SELECT p0004_assert(0);
SET plpgsql.check_asserts = on;
SHOW plpgsql.check_asserts;
SELECT p0004_assert(1);

Meaning

An ASSERT is an executable invariant check inside PL/pgSQL. PostgreSQL evaluates its Boolean condition; a false or NULL result takes the assertion-failure path. The fixed executor then reports ERROR with SQLSTATE P0004: it evaluates the message expression only on that path, uses a non-NULL result as the primary text, and uses assertion failed for a NULL or omitted message. With checks disabled, it skips both the condition and message expression.

plpgsql.check_asserts is a session setting that controls whether ASSERT statements are checked. With it enabled, a failed assertion is a real ERROR and an explicit transaction enters INERROR. With it disabled, ASSERT statements are skipped; the same false input does not prove the invariant and should not be used as a production validation substitute.

The selected runtime exercises a false condition with a non-NULL message and a false condition with checks disabled. The NULL condition and the no-message fallback are source-confirmed semantics, not additional natural observations in this batch.

Diagnosis

Start with the ErrorResponse fields and the server log entry together. In the fixed 18.6 path, message_primary is either the evaluated message or assertion failed; the runtime case also recorded ERROR, P0004, exec_stmt_assert, and context identifying the PL/pgSQL function and line 1 at ASSERT. Check SHOW plpgsql.check_asserts on the affected session, because a setting change in another connection does not change this one.

If the primary is assertion failed, check whether the ASSERT had no message or its message expression evaluated to NULL. If there is no P0004 at all, inspect SHOW plpgsql.check_asserts first: a disabled setting skips the check before evaluating its condition. Keep the function source and the session setting together when comparing two calls; a pooled connection can have a different setting from the one that created the function.

Separate a broken program invariant from expected business input. An assertion such as value > 0 is useful for an assumption that should always hold after validation; an expected negative user value belongs in ordinary validation, a constraint, or an explicit application error with a deliberate SQLSTATE. If the error occurred inside an explicit transaction, inspect the transaction state before issuing another command: the observed case was INERROR until ROLLBACK, not a connection failure.

Response

For an explicit transaction, issue ROLLBACK before unrelated work, then reproduce with the corrected invariant or input. The shared case verified ROLLBACK → IDLE, a valid call returning 1, and the same assertion remaining silent when plpgsql.check_asserts was set to off.

Use WHEN ASSERT_FAILURE when a PL/pgSQL block deliberately wants to handle this named condition. WHEN OTHERS does not catch ASSERT_FAILURE, so a broad handler cannot be used as a hidden assertion switch. An exception block can recover through its documented subtransaction boundary, but swallowing the failure without checking the invariant leaves the program assumption unverified. Keep assertions enabled while diagnosing; disabling them is a diagnostic control, not a repair.

Versions

The locked catalogue records P0004 from 9.5.0 through the listed formal snapshots and 19beta3. The fixed executor source is PostgreSQL 18.6 pl_exec.c#L3965-L3968. The official PL/pgSQL error and message documentation covers ASSERT and named conditions; the control-structures error-trapping documentation defines the EXCEPTION subtransaction and handler matching boundary. The latest/PG10 runtime case confirms the described P0004 and transaction behavior for the shared function.

P0002 for PL/pgSQL no-data handling, P0003 for strict multi-row handling, and P0000 for the PL/pgSQL error category. Use the actual SQLSTATE from the response rather than treating every PL/pgSQL failure as P0004.

Sources

The fixed implementation is pl_exec.c#L3965-L3968. The official PL/pgSQL error and message reference documents ASSERT semantics, while the control-structures error-trapping reference documents the WHEN OTHERS exclusion and subtransaction boundary. The structured evidence record pins the source SHA, runtime summaries, raw results, and shared snippet registry.

313 - PostgreSQL 10.23 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 10.23.

PostgreSQL 10.23 — formal

Snapshot

This is a locked formal definition snapshot containing 240 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 0Z000, 0Z002, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200H, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 2202G, 2202H, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 25P03, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 39P03, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 428C9, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 53400, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 58000, 58030, 58P01, 58P02, 72000, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, P0004, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 9.6.24, the current snapshot PostgreSQL 10.23 adds 2 values and removes 0. Added: 2200H, 428C9

Sources

Locked source: https://github.com/postgres/postgres/blob/02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4/src/backend/utils/errcodes.txt

314 - PostgreSQL 11.22 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 11.22.

PostgreSQL 11.22 — formal

Snapshot

This is a locked formal definition snapshot containing 241 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 0Z000, 0Z002, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200H, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22013, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 2202G, 2202H, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 25P03, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 39P03, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 428C9, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 53400, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 58000, 58030, 58P01, 58P02, 72000, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, P0004, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 10.23, the current snapshot PostgreSQL 11.22 adds 1 values and removes 0. Added: 22013

Sources

Locked source: https://github.com/postgres/postgres/blob/fd851f9e4a13d81cccc4ac5d6059d732c7518111/src/backend/utils/errcodes.txt

315 - PostgreSQL 12.22 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 12.22.

PostgreSQL 12.22 — formal

Snapshot

This is a locked formal definition snapshot containing 257 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 0Z000, 0Z002, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200H, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22013, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 2202G, 2202H, 22030, 22032, 22033, 22034, 22035, 22036, 22037, 22038, 22039, 2203A, 2203B, 2203C, 2203D, 2203E, 2203F, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 25P03, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 39P03, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 428C9, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 53400, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 55P04, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 58000, 58030, 58P01, 58P02, 72000, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, P0004, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 11.22, the current snapshot PostgreSQL 12.22 adds 16 values and removes 0. Added: 22030, 22032, 22033, 22034, 22035, 22036, 22037, 22038, 22039, 2203A, 2203B, 2203C, 2203D, 2203E, 2203F, 55P04

Sources

Locked source: https://github.com/postgres/postgres/blob/498f30a8b7025a2a7bd3715acc1d1692122ba542/src/backend/utils/errcodes.txt

316 - PostgreSQL 13.23 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 13.23.

PostgreSQL 13.23 — formal

Snapshot

This is a locked formal definition snapshot containing 258 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 0Z000, 0Z002, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200H, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22013, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 2202G, 2202H, 22030, 22031, 22032, 22033, 22034, 22035, 22036, 22037, 22038, 22039, 2203A, 2203B, 2203C, 2203D, 2203E, 2203F, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 25P03, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 39P03, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 428C9, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 53400, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 55P04, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 58000, 58030, 58P01, 58P02, 72000, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, P0004, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 12.22, the current snapshot PostgreSQL 13.23 adds 1 values and removes 0. Added: 22031

Sources

Locked source: https://github.com/postgres/postgres/blob/89df812eb890814b105d871185935b580478e660/src/backend/utils/errcodes.txt

317 - PostgreSQL 14.24 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 14.24.

PostgreSQL 14.24 — formal

Snapshot

This is a locked formal definition snapshot containing 259 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 0Z000, 0Z002, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200H, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22013, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 2202G, 2202H, 22030, 22031, 22032, 22033, 22034, 22035, 22036, 22037, 22038, 22039, 2203A, 2203B, 2203C, 2203D, 2203E, 2203F, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 25P03, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 39P03, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 428C9, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 53400, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 55P04, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 57P05, 58000, 58030, 58P01, 58P02, 72000, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, P0004, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 13.23, the current snapshot PostgreSQL 14.24 adds 1 values and removes 0. Added: 57P05

Sources

Locked source: https://github.com/postgres/postgres/blob/6b3806732b7c5df06bdd0ed150e8a07b4ad62315/src/backend/utils/errcodes.txt

318 - PostgreSQL 15.19 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 15.19.

PostgreSQL 15.19 — formal

Snapshot

This is a locked formal definition snapshot containing 260 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 0Z000, 0Z002, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200H, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22013, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 2202G, 2202H, 22030, 22031, 22032, 22033, 22034, 22035, 22036, 22037, 22038, 22039, 2203A, 2203B, 2203C, 2203D, 2203E, 2203F, 2203G, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 25P03, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 39P03, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 428C9, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 53400, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 55P04, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 57P05, 58000, 58030, 58P01, 58P02, 72000, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, P0004, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 14.24, the current snapshot PostgreSQL 15.19 adds 1 values and removes 0. Added: 2203G

Sources

Locked source: https://github.com/postgres/postgres/blob/2ff1375b5dd8bf09d8cb0e795974528180fd75ca/src/backend/utils/errcodes.txt

319 - PostgreSQL 16.15 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 16.15.

PostgreSQL 16.15 — formal

Snapshot

This is a locked formal definition snapshot containing 260 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 0Z000, 0Z002, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200H, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22013, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 2202G, 2202H, 22030, 22031, 22032, 22033, 22034, 22035, 22036, 22037, 22038, 22039, 2203A, 2203B, 2203C, 2203D, 2203E, 2203F, 2203G, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 25P03, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 39P03, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 428C9, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 53400, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 55P04, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 57P05, 58000, 58030, 58P01, 58P02, 72000, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, P0004, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 15.19, the current snapshot PostgreSQL 16.15 adds 0 values and removes 0.

Sources

Locked source: https://github.com/postgres/postgres/blob/7d3e000c5961a544302072058a1184e9a588837b/src/backend/utils/errcodes.txt

320 - PostgreSQL 17.11 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 17.11.

PostgreSQL 17.11 — formal

Snapshot

This is a locked formal definition snapshot containing 260 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 0Z000, 0Z002, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200H, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22013, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 2202G, 2202H, 22030, 22031, 22032, 22033, 22034, 22035, 22036, 22037, 22038, 22039, 2203A, 2203B, 2203C, 2203D, 2203E, 2203F, 2203G, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 25P03, 25P04, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 39P03, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 428C9, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 53400, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 55P04, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 57P05, 58000, 58030, 58P01, 58P02, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, P0004, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 16.15, the current snapshot PostgreSQL 17.11 adds 1 values and removes 1. Added: 25P04; Removed: 72000

Sources

Locked source: https://github.com/postgres/postgres/blob/083ac033419f690758508e08c1736089384bbee8/src/backend/utils/errcodes.txt

321 - PostgreSQL 18.6 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 18.6.

PostgreSQL 18.6 — formal

Snapshot

This is a locked formal definition snapshot containing 262 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 0Z000, 0Z002, 10608, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200H, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22013, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 2202G, 2202H, 22030, 22031, 22032, 22033, 22034, 22035, 22036, 22037, 22038, 22039, 2203A, 2203B, 2203C, 2203D, 2203E, 2203F, 2203G, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 25P03, 25P04, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 39P03, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 428C9, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 53400, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 55P04, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 57P05, 58000, 58030, 58P01, 58P02, 58P03, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, P0004, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 17.11, the current snapshot PostgreSQL 18.6 adds 2 values and removes 0. Added: 10608, 58P03

Sources

Locked source: https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt

322 - PostgreSQL 19beta3 — preview

SQLSTATE definition snapshot and evidence members for PostgreSQL 19beta3.

PostgreSQL 19beta3 — preview

Snapshot

This is a locked preview definition snapshot containing 262 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 0Z000, 0Z002, 10608, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200H, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22013, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 2202G, 2202H, 22030, 22031, 22032, 22033, 22034, 22035, 22036, 22037, 22038, 22039, 2203A, 2203B, 2203C, 2203D, 2203E, 2203F, 2203G, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 25P03, 25P04, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 39P03, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 428C9, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 53400, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 55P04, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 57P05, 58000, 58030, 58P01, 58P02, 58P03, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, P0004, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 18.6, preview snapshot PostgreSQL 19beta3 adds 0 values and removes 0.

Sources

Locked source: https://github.com/postgres/postgres/blob/3638289fb57bdabec00deda98ee9624a35f5d66a/src/backend/utils/errcodes.txt

323 - PostgreSQL 9.0.23 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 9.0.23.

PostgreSQL 9.0.23 — formal

Snapshot

This is a locked formal definition snapshot containing 199 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 44000, 53000, 53100, 53200, 53300, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 58030, 58P01, 58P02, F0000, F0001, P0000, P0001, P0002, P0003, XX000, XX001, XX002

Additions and changes

PostgreSQL 9.0.23 is the first locked snapshot and forms the baseline.

Sources

Locked source: https://github.com/postgres/postgres/blob/9a42e8514f7e42737992bb09bd93540dd9630a9a/src/include/utils/errcodes.h

324 - PostgreSQL 9.1.24 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 9.1.24.

PostgreSQL 9.1.24 — formal

Snapshot

This is a locked formal definition snapshot containing 228 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 58030, 58P01, 58P02, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 9.0.23, the current snapshot PostgreSQL 9.1.24 adds 29 values and removes 0. Added: 42P21, 42P22, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091

Sources

Locked source: https://github.com/postgres/postgres/blob/e85493559c4678f54d30b6b4e04b17c03a3192d7/src/backend/utils/errcodes.txt

325 - PostgreSQL 9.2.24 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 9.2.24.

PostgreSQL 9.2.24 — formal

Snapshot

This is a locked formal definition snapshot containing 232 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 0Z000, 0Z002, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 53400, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 58000, 58030, 58P01, 58P02, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 9.1.24, the current snapshot PostgreSQL 9.2.24 adds 4 values and removes 0. Added: 0Z000, 0Z002, 53400, 58000

Sources

Locked source: https://github.com/postgres/postgres/blob/8786f783ab2398468a8c4d8eac937fc6533d16e3/src/backend/utils/errcodes.txt

326 - PostgreSQL 9.3.25 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 9.3.25.

PostgreSQL 9.3.25 — formal

Snapshot

This is a locked formal definition snapshot containing 232 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 0Z000, 0Z002, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 53400, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 58000, 58030, 58P01, 58P02, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 9.2.24, the current snapshot PostgreSQL 9.3.25 adds 0 values and removes 0.

Sources

Locked source: https://github.com/postgres/postgres/blob/c10bb239d29017ba66eca88a24b84a1d4db36a6c/src/backend/utils/errcodes.txt

327 - PostgreSQL 9.4.26 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 9.4.26.

PostgreSQL 9.4.26 — formal

Snapshot

This is a locked formal definition snapshot containing 232 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 0Z000, 0Z002, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 53400, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 58000, 58030, 58P01, 58P02, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 9.3.25, the current snapshot PostgreSQL 9.4.26 adds 0 values and removes 0.

Sources

Locked source: https://github.com/postgres/postgres/blob/30ffdd24d7222bc01183a56d536c236240674516/src/backend/utils/errcodes.txt

328 - PostgreSQL 9.5.25 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 9.5.25.

PostgreSQL 9.5.25 — formal

Snapshot

This is a locked formal definition snapshot containing 236 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 0Z000, 0Z002, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 2202G, 2202H, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 39P03, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 53400, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 58000, 58030, 58P01, 58P02, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, P0004, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 9.4.26, the current snapshot PostgreSQL 9.5.25 adds 4 values and removes 0. Added: 2202G, 2202H, 39P03, P0004

Sources

Locked source: https://github.com/postgres/postgres/blob/202c587e2f28bc295f6935d044e20680b627e7a1/src/backend/utils/errcodes.txt

329 - PostgreSQL 9.6.24 — formal

SQLSTATE definition snapshot and evidence members for PostgreSQL 9.6.24.

PostgreSQL 9.6.24 — formal

Snapshot

This is a locked formal definition snapshot containing 238 SQLSTATE values. Presence means the value appears in the release definition source; it does not by itself prove a runtime path.

Members

00000, 01000, 01003, 01004, 01006, 01007, 01008, 0100C, 01P01, 02000, 02001, 03000, 08000, 08001, 08003, 08004, 08006, 08007, 08P01, 09000, 0A000, 0B000, 0F000, 0F001, 0L000, 0LP01, 0P000, 0Z000, 0Z002, 20000, 21000, 22000, 22001, 22002, 22003, 22004, 22005, 22007, 22008, 22009, 2200B, 2200C, 2200D, 2200F, 2200G, 2200L, 2200M, 2200N, 2200S, 2200T, 22010, 22011, 22012, 22014, 22015, 22016, 22018, 22019, 2201B, 2201E, 2201F, 2201G, 2201W, 2201X, 22021, 22022, 22023, 22024, 22025, 22026, 22027, 2202E, 2202G, 2202H, 22P01, 22P02, 22P03, 22P04, 22P05, 22P06, 23000, 23001, 23502, 23503, 23505, 23514, 23P01, 24000, 25000, 25001, 25002, 25003, 25004, 25005, 25006, 25007, 25008, 25P01, 25P02, 25P03, 26000, 27000, 28000, 28P01, 2B000, 2BP01, 2D000, 2F000, 2F002, 2F003, 2F004, 2F005, 34000, 38000, 38001, 38002, 38003, 38004, 39000, 39001, 39004, 39P01, 39P02, 39P03, 3B000, 3B001, 3D000, 3F000, 40000, 40001, 40002, 40003, 40P01, 42000, 42501, 42601, 42602, 42611, 42622, 42701, 42702, 42703, 42704, 42710, 42712, 42723, 42725, 42803, 42804, 42809, 42830, 42846, 42883, 42939, 42P01, 42P02, 42P03, 42P04, 42P05, 42P06, 42P07, 42P08, 42P09, 42P10, 42P11, 42P12, 42P13, 42P14, 42P15, 42P16, 42P17, 42P18, 42P19, 42P20, 42P21, 42P22, 44000, 53000, 53100, 53200, 53300, 53400, 54000, 54001, 54011, 54023, 55000, 55006, 55P02, 55P03, 57000, 57014, 57P01, 57P02, 57P03, 57P04, 58000, 58030, 58P01, 58P02, 72000, F0000, F0001, HV000, HV001, HV002, HV004, HV005, HV006, HV007, HV008, HV009, HV00A, HV00B, HV00C, HV00D, HV00J, HV00K, HV00L, HV00M, HV00N, HV00P, HV00Q, HV00R, HV010, HV014, HV021, HV024, HV090, HV091, P0000, P0001, P0002, P0003, P0004, XX000, XX001, XX002

Additions and changes

Compared with the previous locked snapshot PostgreSQL 9.5.25, the current snapshot PostgreSQL 9.6.24 adds 2 values and removes 0. Added: 25P03, 72000

Sources

Locked source: https://github.com/postgres/postgres/blob/a4116b8d5a4f68803452d8f1aa3f74f302049a90/src/backend/utils/errcodes.txt

330 - XX000 — internal_error

PostgreSQL uses SQLSTATE XX000 for internal-error paths and as the default code for an ERROR without an explicit code. Preserve the full diagnostic and investigate the exact subsystem; XX000 alone does not prove corruption.

At a glance

XX000 is the internal_error condition in Class XX, Internal Error. The PostgreSQL source directory describes this class as covering “can’t-happen” conditions and software bugs. It is a generic diagnostic boundary, not a claim that a database is corrupt.

The code also has a mechanical default. In the error stack initializer, an ERROR or higher level with no later explicit code starts as ERRCODE_INTERNAL_ERROR; WARNING starts as ERRCODE_WARNING (01000); and a level below WARNING starts with 00000 unless it supplies its own code. An explicit errcode() can select another SQLSTATE. Therefore, XX000 can arise from a default elog(ERROR, ...) path or from a deliberate internal-error report.

Severity and connection consequences are path-dependent. ERROR, FATAL, and PANIC are different protocol severities; an explicit XX000 can even accompany a NOTICE in extension test code. Read the severity, transaction status, connection state, source location, and complete diagnostic together.

The representative case internal_error_safety_boundary is source-only. It is recorded as not_applicable on PostgreSQL 18.6 and 10.21 because forcing internal corruption or a fault would cross the safe disposable SQL boundary. No fabricated RAISE is presented as a natural internal server failure.

Field Value
SQLSTATE XX000
Condition internal_error
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INTERNAL_ERROR
Aliases

Meaning and trigger paths

The 18.6 definition is XX000 E ERRCODE_INTERNAL_ERROR internal_error under Class XX. The class comment is intentionally broad. More specific codes exist for data corruption (XX001) and index corruption (XX002); choosing XX000 does not silently upgrade a generic internal report into either diagnosis.

There are two source patterns to distinguish:

  1. Default internal code. A backend path calls elog(ERROR, ...) or otherwise reaches ereport(ERROR, ...) without an explicit SQLSTATE. elog.c initializes that error as XX000. The message and source function still identify the subsystem.
  2. Explicit internal code. A path calls errcode(ERRCODE_INTERNAL_ERROR) because an invariant or an operating-system/service result was considered impossible or unusable. In 18.6, examples include btree rechecking that cannot re-find a tuple, an invalid dynamic shared-memory control segment, an attempt to redefine a non-placeholder configuration parameter, and failure to obtain strong random bytes for UUID generation.

The explicit code does not force one severity. The shared-memory path reports FATAL, while the btree, GUC, and UUID examples report ERROR. A test access-control hook intentionally reports NOTICE with ERRCODE_INTERNAL_ERROR, showing that SQLSTATE and severity are separate fields. That hook is a source example, not evidence that ordinary production notices indicate an internal failure.

Messages and diagnostics

XX000 has no universal primary message. Representative source templates include:

  • failed to re-find tuple within index "%s", with a hint that a non-immutable index expression may be responsible (nbtinsert.c).
  • dynamic shared memory control segment is not valid on the FATAL initialization path (dsm.c).
  • attempt to redefine parameter "%s" (guc.c) and could not generate random values (uuid.c).
  • invalid page pd_lower %u pd_upper %u pd_special %u from a default elog(ERROR, ...) path (bufmask.c); the default mapping supplies XX000 when no explicit code replaces it.

Treat these as path-specific diagnostic templates. Record SQLSTATE, both severity fields, primary message, detail, hint, context, source file, function, line, backend PID, database, and server version. Localized text and template wording can vary; the source path and structured fields are more stable than a message substring.

Diagnosis

Preserve the complete client error and the matching server log record before retrying or restarting anything. First classify the protocol severity:

  • An ERROR normally aborts the current explicit transaction but leaves the backend connection available after rollback.
  • A FATAL ends the backend session; the client must establish a new connection before continuing.
  • A PANIC is a server-wide emergency path whose process and connection effects must be confirmed from the server log and supervision state.
  • A WARNING or NOTICE with an explicit XX000 has different control flow and does not by itself prove an internal failure or abort a transaction.

Then group the event by source function and subsystem. Check for a preceding I/O, memory, extension, index, configuration, or concurrency failure; compare the exact server build and fixed source revision; and look for repeated occurrences. Use read-only catalog, index, or page checks only when the diagnostic points to them. Do not infer corruption from the class name alone, and do not replace the message with a hand-written RAISE EXCEPTION test: that would exercise P0001 by default rather than the server’s internal path.

Response

Follow the severity and the subsystem. Roll back an ERROR transaction before issuing unrelated commands; reconnect after FATAL; and follow the server’s restart and incident procedure after PANIC. Do not blindly retry an internal-error operation, especially when the source points to an invariant, storage, index, or shared-memory boundary.

Collect the server version, exact SQL, backend and server logs, source location, relation or object identity, and recent configuration or extension changes. If the evidence points to corruption, stop writes as appropriate for the incident, preserve a copy or snapshot, and use the documented PostgreSQL recovery and support process. If it points to a deterministic software or extension defect without corruption evidence, isolate the reproducer and compare supported versions. The correct response is determined by that evidence, not by XX000 alone.

Versions

The catalogue records XX000 in the locked 7.4–8.4.22 pre-9.0 formal sources, every formal snapshot from 9.0.23 through 18.6, and the 19 Beta 3 preview. The same-tag REL8_1_4 errcodes.sgml table already lists XX000 as internal_error, confirming that condition-name observation by 8.1.4. The class title is Internal Error (PostgreSQL-specific error class) in the 9.0 header view and changes to Internal Error in the 9.1 text definition. Candidate source gaps remain for 7.0–7.3; these are observed catalogue boundaries, not exact implementation introduction dates.

The fixed 18.6 source commit is 724edf9bde9d356724ad384a2e196edc3c9f80f7. The default severity-to-code mapping and the source paths above are 18.6 evidence. No deterministic safe SQL trigger was accepted for the representative runtime case, so the runtime status remains not_applicable on both targets.

XX001data_corrupted and XX002index_corrupted are more specific corruption conditions. P0001raise_exception is the normal default for an explicit PL/pgSQL RAISE EXCEPTION without a code. 57P01admin_shutdown is a server-connection event with a different class and response. 25P02in_failed_sql_transaction is a follow-on transaction state after an earlier error, not a synonym for XX000.

Sources

The structured evidence is recorded in the public evidence JSON. Source records are pinned to PostgreSQL commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; runtime records retain the exact source-only case ID and both target summaries.

  • src.errcodes.18.6errcodes.txt
  • src.elog.18.6elog.c
  • src.nbtinsert.18.6, src.dsm.18.6, src.guc.18.6, src.uuid.18.6, and src.bufmask.18.6 — source-confirmed internal paths
  • src.oat-hooks.18.6 — explicit internal code at NOTICE
  • doc.protocol.18Error and Notice Message Fields

331 - XX001 — data_corrupted

Source-backed full reference for PostgreSQL SQLSTATE XX001.

XX001

At a glance

XX001 reports an integrity invariant failure. The fixed sources cover corrupted PGLZ TOAST data, impossible MultiXact/XID freeze state in heap processing, and an amcheck B-tree check that can reveal a heap/HOT-chain problem behind an apparent index mismatch.

Field Value
SQLSTATE XX001
Condition data_corrupted
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_DATA_CORRUPTED
Aliases

Meaning

The TOAST decompressor raises ERRCODE_DATA_CORRUPTED when PGLZ cannot decode the stored compressed datum. Heap freezing raises the same code when a MultiXact precedes relminmxid, remains running before the freeze cutoff, or carries an update XID before relfrozenxid or the removable cutoff. These are consistency checks on stored data and transaction metadata, not invalid user input.

The amcheck heapallindexed callback reports a heap tuple lacking its matching index tuple. Its source comments warn that an apparent index-scan problem can still be heap corruption, a bad HOT-safety decision, or another underlying fault; the optional hint only asks for a stronger verification call.

Messages

  • ERROR, SQLSTATE XX001: compressed pglz data is corrupt.
  • ERROR, SQLSTATE XX001: found multixact %u from before relminmxid %u.
  • ERROR, SQLSTATE XX001: multixact %u from before multi freeze cutoff %u found to be still running.
  • ERROR, SQLSTATE XX001: multixact %u contains update XID %u from before relfrozenxid %u.
  • ERROR, SQLSTATE XX001: multixact %u contains committed update XID %u from before removable cutoff %u.
  • ERROR, SQLSTATE XX001: heap tuple (%u,%u) from table "%s" lacks matching index tuple within index "%s".
    • When the check was entered through bt_index_check (which takes AccessShareLock and passes readonly=false to the callback), hint: Retrying verification using the function bt_index_parent_check() might provide a more specific error. The bt_index_parent_check entry point takes ShareLock, passes readonly=true, and does not append this hint. This internal verification mode is unrelated to the SQL transaction’s transaction_read_only setting.

Diagnosis

Preserve the exact message and identifiers, relation/index names, block and page context, checksum and replica comparison, server log, and the first operation that observed the invariant. For TOAST, identify the owning table and compressed datum path. For heap messages, inspect relfrozenxid/relminmxid and MultiXact history without manually editing system catalogs. For amcheck, record whether the call used bt_index_check/AccessShareLock or bt_index_parent_check/ShareLock, and whether the hint was present; do not assume the index is the root cause.

Response

Treat these as integrity incidents. In an explicit transaction, an ERROR requires ROLLBACK or ROLLBACK TO an existing savepoint before more SQL, but rollback does not repair the stored object. Compare trusted backups, replicas, checksums and storage history using a read-only procedure; then restore or rebuild the affected table/TOAST data according to the incident plan. A REINDEX may be appropriate only after evidence shows corruption is index-local; it is not a generic repair for heap, TOAST, XID, or MultiXact invariants. If a separate FATAL or process termination occurred, use a new connection after recovery; do not induce corruption to test this code.

Versions

The locked catalogue records this condition from 7.4; fixed TOAST, heap, and amcheck source coverage is PostgreSQL 18.6. No corruption or crash runtime was run for this source-only page.

XX002, 58030, 72000

Sources

src/backend/access/common/toast_compression.c#L90-L100

src/backend/access/heap/heapam.c#L6983-L7042

contrib/amcheck/verify_nbtree.c#L2760-L2818

contrib/amcheck/verify_nbtree.c#L252-L305

contrib/amcheck/verify_common.c#L60-L149

The structured evidence record records the integrity message groups, conditional hint, and source/runtime boundary.

332 - XX002 — index_corrupted

Source-backed full reference for PostgreSQL SQLSTATE XX002.

XX002

At a glance

XX002 reports an index-structure failure. The fixed sources are method-specific: BRIN checks a range-map pointer, while GiST and hash check page headers, special areas, and method-specific metadata.

Field Value
SQLSTATE XX002
Condition index_corrupted
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INDEX_CORRUPTED
Aliases

Meaning

The BRIN revmap path raises XX002 when a range-map item points past the regular page or to an unused item. GiST and hash page-check functions reject an unexpected zero page or an invalid special area; hash also checks that the page type, magic, and version match the hash access method. These checks can fire during normal index access or validation and do not by themselves prove that the heap is sound.

Messages

  • ERROR, SQLSTATE XX002: corrupted BRIN index: inconsistent range map.
  • ERROR, SQLSTATE XX002 (GiST): index "%s" contains unexpected zero page at block %u; hint Please REINDEX it.
  • ERROR, SQLSTATE XX002 (GiST or hash): index "%s" contains corrupted page at block %u; hint Please REINDEX it.
  • ERROR, SQLSTATE XX002 (hash): index "%s" is not a hash index.
  • ERROR, SQLSTATE XX002 (hash): index "%s" has wrong hash version; hint Please REINDEX it.

The BRIN branch has no fixed REINDEX hint in the cited source. The same message may be reached from more than one page-check guard, so retain the access method and block.

Diagnosis

Record access method, index OID/name, block, page header/special-area detail, primary/detail/hint, and the first query, check, or maintenance operation that observed the failure. Compare the index with the heap, amcheck output, checksums, replicas, and storage history. A repeated failure after a rebuild suggests an underlying heap, storage, or software problem rather than a one-off index page.

Response

For an ERROR in an explicit transaction, roll back or return to an existing savepoint before issuing more SQL. Preserve the original index and evidence before repair. If comparison establishes that corruption is index-local and the heap is trusted, rebuild the affected index with the access method’s documented maintenance procedure; the GiST/hash hints explicitly say REINDEX it, while the BRIN message does not prescribe a repair. Verify the rebuilt index and dependent constraints. REINDEX cannot repair heap/TOAST/storage corruption, and rebuilding a corrupted index over bad heap data can reproduce the problem; if the backend was terminated by a separate FATAL, recover and use a new connection.

Versions

The locked catalogue records this condition from 7.4; fixed BRIN, GiST, and hash source coverage is PostgreSQL 18.6. No index or corruption runtime was induced for this source-only page.

XX001, 58030, 54011

Sources

src/backend/access/brin/brin_revmap.c#L381-L389

src/backend/access/gist/gistutil.c#L796-L812

src/backend/access/hash/hashutil.c#L221-L270

The structured evidence record records access-method-specific message guards, hints, and the source/runtime boundary.