github.com/cockroachdb/cockroachdb-parser@v0.23.3-0.20240213214944-911057d40c9a/pkg/sql/pgwire/pgcode/plpgsql_codenames.go (about)

     1  // Copyright 2023 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  package pgcode
    12  
    13  // PLpgSQLConditionNameToCode maps from PG error condition names to error codes.
    14  // Most of the condition names map to one code, but a few (moved to the bottom)
    15  // map to two codes. This is used for PLpgSQL exception handling.
    16  //
    17  // PLpgSQLConditionNameToCode was generated using the generate_names.sh script,
    18  // then manually edited.
    19  var PLpgSQLConditionNameToCode = map[string][]string{
    20  	// Section: Class 00 - Successful Completion
    21  	"successful_completion": {"00000"},
    22  	// Section: Class 01 - Warning
    23  	"warning":                               {"01000"},
    24  	"dynamic_result_sets_returned":          {"0100C"},
    25  	"implicit_zero_bit_padding":             {"01008"},
    26  	"null_value_eliminated_in_set_function": {"01003"},
    27  	"privilege_not_granted":                 {"01007"},
    28  	"privilege_not_revoked":                 {"01006"},
    29  	"deprecated_feature":                    {"01P01"},
    30  	// Section: Class 02 - No Data (this is also a warning class per the SQL standard)
    31  	"no_data": {"02000"},
    32  	"no_additional_dynamic_result_sets_returned": {"02001"},
    33  	// Section: Class 03 - SQL Statement Not Yet Complete
    34  	"sql_statement_not_yet_complete": {"03000"},
    35  	// Section: Class 08 - Connection Exception
    36  	"connection_exception":                              {"08000"},
    37  	"connection_does_not_exist":                         {"08003"},
    38  	"connection_failure":                                {"08006"},
    39  	"sqlclient_unable_to_establish_sqlconnection":       {"08001"},
    40  	"sqlserver_rejected_establishment_of_sqlconnection": {"08004"},
    41  	"transaction_resolution_unknown":                    {"08007"},
    42  	"protocol_violation":                                {"08P01"},
    43  	// Section: Class 09 - Triggered Action Exception
    44  	"triggered_action_exception": {"09000"},
    45  	// Section: Class 0A - Feature Not Supported
    46  	"feature_not_supported": {"0A000"},
    47  	// Section: Class 0B - Invalid Transaction Initiation
    48  	"invalid_transaction_initiation": {"0B000"},
    49  	// Section: Class 0F - Locator Exception
    50  	"locator_exception":             {"0F000"},
    51  	"invalid_locator_specification": {"0F001"},
    52  	// Section: Class 0L - Invalid Grantor
    53  	"invalid_grantor":         {"0L000"},
    54  	"invalid_grant_operation": {"0LP01"},
    55  	// Section: Class 0P - Invalid Role Specification
    56  	"invalid_role_specification": {"0P000"},
    57  	// Section: Class 0Z - Diagnostics Exception
    58  	"diagnostics_exception":                               {"0Z000"},
    59  	"stacked_diagnostics_accessed_without_active_handler": {"0Z002"},
    60  	// Section: Class 20 - Case Not Found
    61  	"case_not_found": {"20000"},
    62  	// Section: Class 21 - Cardinality Violation
    63  	"cardinality_violation": {"21000"},
    64  	// Section: Class 22 - Data Exception
    65  	"data_exception":                             {"22000"},
    66  	"array_subscript_error":                      {"2202E"},
    67  	"character_not_in_repertoire":                {"22021"},
    68  	"datetime_field_overflow":                    {"22008"},
    69  	"division_by_zero":                           {"22012"},
    70  	"error_in_assignment":                        {"22005"},
    71  	"escape_character_conflict":                  {"2200B"},
    72  	"indicator_overflow":                         {"22022"},
    73  	"interval_field_overflow":                    {"22015"},
    74  	"invalid_argument_for_logarithm":             {"2201E"},
    75  	"invalid_argument_for_ntile_function":        {"22014"},
    76  	"invalid_argument_for_nth_value_function":    {"22016"},
    77  	"invalid_argument_for_power_function":        {"2201F"},
    78  	"invalid_argument_for_width_bucket_function": {"2201G"},
    79  	"invalid_character_value_for_cast":           {"22018"},
    80  	"invalid_datetime_format":                    {"22007"},
    81  	"invalid_escape_character":                   {"22019"},
    82  	"invalid_escape_octet":                       {"2200D"},
    83  	"invalid_escape_sequence":                    {"22025"},
    84  	"nonstandard_use_of_escape_character":        {"22P06"},
    85  	"invalid_indicator_parameter_value":          {"22010"},
    86  	"invalid_parameter_value":                    {"22023"},
    87  	"invalid_regular_expression":                 {"2201B"},
    88  	"invalid_row_count_in_limit_clause":          {"2201W"},
    89  	"invalid_row_count_in_result_offset_clause":  {"2201X"},
    90  	"invalid_tablesample_argument":               {"2202H"},
    91  	"invalid_tablesample_repeat":                 {"2202G"},
    92  	"invalid_time_zone_displacement_value":       {"22009"},
    93  	"invalid_use_of_escape_character":            {"2200C"},
    94  	"most_specific_type_mismatch":                {"2200G"},
    95  	"null_value_no_indicator_parameter":          {"22002"},
    96  	"numeric_value_out_of_range":                 {"22003"},
    97  	"string_data_length_mismatch":                {"22026"},
    98  	"substring_error":                            {"22011"},
    99  	"trim_error":                                 {"22027"},
   100  	"unterminated_c_string":                      {"22024"},
   101  	"zero_length_character_string":               {"2200F"},
   102  	"floating_point_exception":                   {"22P01"},
   103  	"invalid_text_representation":                {"22P02"},
   104  	"invalid_binary_representation":              {"22P03"},
   105  	"bad_copy_file_format":                       {"22P04"},
   106  	"untranslatable_character":                   {"22P05"},
   107  	"not_an_xml_document":                        {"2200L"},
   108  	"invalid_xml_document":                       {"2200M"},
   109  	"invalid_xml_content":                        {"2200N"},
   110  	"invalid_xml_comment":                        {"2200S"},
   111  	"invalid_xml_processing_instruction":         {"2200T"},
   112  	// Section: Class 23 - Integrity Constraint Violation
   113  	"integrity_constraint_violation": {"23000"},
   114  	"restrict_violation":             {"23001"},
   115  	"not_null_violation":             {"23502"},
   116  	"foreign_key_violation":          {"23503"},
   117  	"unique_violation":               {"23505"},
   118  	"check_violation":                {"23514"},
   119  	"exclusion_violation":            {"23P01"},
   120  	// Section: Class 24 - Invalid Cursor State
   121  	"invalid_cursor_state": {"24000"},
   122  	// Section: Class 25 - Invalid Transaction State
   123  	"invalid_transaction_state":                            {"25000"},
   124  	"active_sql_transaction":                               {"25001"},
   125  	"branch_transaction_already_active":                    {"25002"},
   126  	"held_cursor_requires_same_isolation_level":            {"25008"},
   127  	"inappropriate_access_mode_for_branch_transaction":     {"25003"},
   128  	"inappropriate_isolation_level_for_branch_transaction": {"25004"},
   129  	"no_active_sql_transaction_for_branch_transaction":     {"25005"},
   130  	"read_only_sql_transaction":                            {"25006"},
   131  	"schema_and_data_statement_mixing_not_supported":       {"25007"},
   132  	"no_active_sql_transaction":                            {"25P01"},
   133  	"in_failed_sql_transaction":                            {"25P02"},
   134  	// Section: Class 26 - Invalid SQL Statement Name
   135  	"invalid_sql_statement_name": {"26000"},
   136  	// Section: Class 27 - Triggered Data Change Violation
   137  	"triggered_data_change_violation": {"27000"},
   138  	// Section: Class 28 - Invalid Authorization Specification
   139  	"invalid_authorization_specification": {"28000"},
   140  	"invalid_password":                    {"28P01"},
   141  	// Section: Class 2B - Dependent Privilege Descriptors Still Exist
   142  	"dependent_privilege_descriptors_still_exist": {"2B000"},
   143  	"dependent_objects_still_exist":               {"2BP01"},
   144  	// Section: Class 2D - Invalid Transaction Termination
   145  	"invalid_transaction_termination": {"2D000"},
   146  	// Section: Class 2F - SQL Routine Exception
   147  	"sql_routine_exception":                 {"2F000"},
   148  	"function_executed_no_return_statement": {"2F005"},
   149  	// Section: Class 34 - Invalid Cursor Name
   150  	"invalid_cursor_name": {"34000"},
   151  	// Section: Class 38 - External Routine Exception
   152  	"external_routine_exception":   {"38000"},
   153  	"containing_sql_not_permitted": {"38001"},
   154  	// Section: Class 39 - External Routine Invocation Exception
   155  	"external_routine_invocation_exception": {"39000"},
   156  	"invalid_sqlstate_returned":             {"39001"},
   157  	"trigger_protocol_violated":             {"39P01"},
   158  	"srf_protocol_violated":                 {"39P02"},
   159  	"event_trigger_protocol_violated":       {"39P03"},
   160  	// Section: Class 3B - Savepoint Exception
   161  	"savepoint_exception":             {"3B000"},
   162  	"invalid_savepoint_specification": {"3B001"},
   163  	// Section: Class 3D - Invalid Catalog Name
   164  	"invalid_catalog_name": {"3D000"},
   165  	// Section: Class 3F - Invalid Schema Name
   166  	"invalid_schema_name": {"3F000"},
   167  	// Section: Class 40 - Transaction Rollback
   168  	"transaction_rollback":                       {"40000"},
   169  	"transaction_integrity_constraint_violation": {"40002"},
   170  	"serialization_failure":                      {"40001"},
   171  	"statement_completion_unknown":               {"40003"},
   172  	"deadlock_detected":                          {"40P01"},
   173  	// Section: Class 42 - Syntax Error or Access Rule Violation
   174  	"syntax_error_or_access_rule_violation": {"42000"},
   175  	"syntax_error":                          {"42601"},
   176  	"insufficient_privilege":                {"42501"},
   177  	"cannot_coerce":                         {"42846"},
   178  	"grouping_error":                        {"42803"},
   179  	"windowing_error":                       {"42P20"},
   180  	"invalid_recursion":                     {"42P19"},
   181  	"invalid_foreign_key":                   {"42830"},
   182  	"invalid_name":                          {"42602"},
   183  	"name_too_long":                         {"42622"},
   184  	"reserved_name":                         {"42939"},
   185  	"datatype_mismatch":                     {"42804"},
   186  	"indeterminate_datatype":                {"42P18"},
   187  	"collation_mismatch":                    {"42P21"},
   188  	"indeterminate_collation":               {"42P22"},
   189  	"wrong_object_type":                     {"42809"},
   190  	"undefined_column":                      {"42703"},
   191  	"undefined_function":                    {"42883"},
   192  	"undefined_table":                       {"42P01"},
   193  	"undefined_parameter":                   {"42P02"},
   194  	"undefined_object":                      {"42704"},
   195  	"duplicate_column":                      {"42701"},
   196  	"duplicate_cursor":                      {"42P03"},
   197  	"duplicate_database":                    {"42P04"},
   198  	"duplicate_function":                    {"42723"},
   199  	"duplicate_prepared_statement":          {"42P05"},
   200  	"duplicate_schema":                      {"42P06"},
   201  	"duplicate_table":                       {"42P07"},
   202  	"duplicate_alias":                       {"42712"},
   203  	"duplicate_object":                      {"42710"},
   204  	"ambiguous_column":                      {"42702"},
   205  	"ambiguous_function":                    {"42725"},
   206  	"ambiguous_parameter":                   {"42P08"},
   207  	"ambiguous_alias":                       {"42P09"},
   208  	"invalid_column_reference":              {"42P10"},
   209  	"invalid_column_definition":             {"42611"},
   210  	"invalid_cursor_definition":             {"42P11"},
   211  	"invalid_database_definition":           {"42P12"},
   212  	"invalid_function_definition":           {"42P13"},
   213  	"invalid_prepared_statement_definition": {"42P14"},
   214  	"invalid_schema_definition":             {"42P15"},
   215  	"invalid_table_definition":              {"42P16"},
   216  	"invalid_object_definition":             {"42P17"},
   217  	// Section: Class 44 - WITH CHECK OPTION Violation
   218  	"with_check_option_violation": {"44000"},
   219  	// Section: Class 53 - Insufficient Resources
   220  	"insufficient_resources":       {"53000"},
   221  	"disk_full":                    {"53100"},
   222  	"out_of_memory":                {"53200"},
   223  	"too_many_connections":         {"53300"},
   224  	"configuration_limit_exceeded": {"53400"},
   225  	// Section: Class 54 - Program Limit Exceeded
   226  	"program_limit_exceeded": {"54000"},
   227  	"statement_too_complex":  {"54001"},
   228  	"too_many_columns":       {"54011"},
   229  	"too_many_arguments":     {"54023"},
   230  	// Section: Class 55 - Object Not In Prerequisite State
   231  	"object_not_in_prerequisite_state": {"55000"},
   232  	"object_in_use":                    {"55006"},
   233  	"cant_change_runtime_param":        {"55P02"},
   234  	"lock_not_available":               {"55P03"},
   235  	// Section: Class 57 - Operator Intervention
   236  	"operator_intervention": {"57000"},
   237  	"query_canceled":        {"57014"},
   238  	"admin_shutdown":        {"57P01"},
   239  	"crash_shutdown":        {"57P02"},
   240  	"cannot_connect_now":    {"57P03"},
   241  	"database_dropped":      {"57P04"},
   242  	// Section: Class 58 - System Error
   243  	"system_error":   {"58000"},
   244  	"io_error":       {"58030"},
   245  	"undefined_file": {"58P01"},
   246  	"duplicate_file": {"58P02"},
   247  	// Section: Class F0 - Configuration File Error
   248  	"config_file_error": {"F0000"},
   249  	"lock_file_exists":  {"F0001"},
   250  	// Section: Class HV - Foreign Data Wrapper Error (SQL/MED)
   251  	"fdw_error":                                  {"HV000"},
   252  	"fdw_column_name_not_found":                  {"HV005"},
   253  	"fdw_dynamic_parameter_value_needed":         {"HV002"},
   254  	"fdw_function_sequence_error":                {"HV010"},
   255  	"fdw_inconsistent_descriptor_information":    {"HV021"},
   256  	"fdw_invalid_attribute_value":                {"HV024"},
   257  	"fdw_invalid_column_name":                    {"HV007"},
   258  	"fdw_invalid_column_number":                  {"HV008"},
   259  	"fdw_invalid_data_type":                      {"HV004"},
   260  	"fdw_invalid_data_type_descriptors":          {"HV006"},
   261  	"fdw_invalid_descriptor_field_identifier":    {"HV091"},
   262  	"fdw_invalid_handle":                         {"HV00B"},
   263  	"fdw_invalid_option_index":                   {"HV00C"},
   264  	"fdw_invalid_option_name":                    {"HV00D"},
   265  	"fdw_invalid_string_length_or_buffer_length": {"HV090"},
   266  	"fdw_invalid_string_format":                  {"HV00A"},
   267  	"fdw_invalid_use_of_null_pointer":            {"HV009"},
   268  	"fdw_too_many_handles":                       {"HV014"},
   269  	"fdw_out_of_memory":                          {"HV001"},
   270  	"fdw_no_schemas":                             {"HV00P"},
   271  	"fdw_option_name_not_found":                  {"HV00J"},
   272  	"fdw_reply_handle":                           {"HV00K"},
   273  	"fdw_schema_not_found":                       {"HV00Q"},
   274  	"fdw_table_not_found":                        {"HV00R"},
   275  	"fdw_unable_to_create_execution":             {"HV00L"},
   276  	"fdw_unable_to_create_reply":                 {"HV00M"},
   277  	"fdw_unable_to_establish_connection":         {"HV00N"},
   278  	// Section: Class P0 - PL/pgSQL Error
   279  	"plpgsql_error":   {"P0000"},
   280  	"raise_exception": {"P0001"},
   281  	"no_data_found":   {"P0002"},
   282  	"too_many_rows":   {"P0003"},
   283  	"assert_failure":  {"P0004"},
   284  	// Section: Class XX - Internal Error
   285  	"internal_error":  {"XX000"},
   286  	"data_corrupted":  {"XX001"},
   287  	"index_corrupted": {"XX002"},
   288  	// Section: Condition names that map to multiple codes.
   289  	"null_value_not_allowed":             {"22004", "39004"},
   290  	"string_data_right_truncation":       {"01004", "22001"},
   291  	"modifying_sql_data_not_permitted":   {"2F002", "38002"},
   292  	"prohibited_sql_statement_attempted": {"2F003", "38003"},
   293  	"reading_sql_data_not_permitted":     {"2F004", "38004"},
   294  }