/*
 * Licensed to Crate.io GmbH ("Crate") under one or more contributor
 * license agreements.  See the NOTICE file distributed with this work for
 * additional information regarding copyright ownership.  Crate licenses
 * this file to you under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.  You may
 * obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 *
 * However, if you have executed another commercial license agreement
 * with Crate these terms will supersede the license and you may use the
 * software solely pursuant to the terms of the relevant commercial agreement.
 */

package io.crate.protocols.postgres;

public enum PGErrorStatus {

    SUCCESSFUL_COMPLETION("00000","successful_completion"),
    WARNING("01000","warning"),
    WARNING_DYNAMIC_RESULT_SETS_RETURNED("0100C","dynamic_result_sets_returned"),
    WARNING_IMPLICIT_ZERO_BIT_PADDING("01008","implicit_zero_bit_padding"),
    WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION("01003","null_value_eliminated_in_set_function"),
    WARNING_PRIVILEGE_NOT_GRANTED("01007","privilege_not_granted"),
    WARNING_PRIVILEGE_NOT_REVOKED("01006","privilege_not_revoked"),
    WARNING_STRING_DATA_RIGHT_TRUNCATION("01004","string_data_right_truncation"),
    WARNING_DEPRECATED_FEATURE("01P01","deprecated_feature"),
    NO_DATA("02000","no_data"),
    NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED("02001","no_additional_dynamic_result_sets_returned"),
    SQL_STATEMENT_NOT_YET_COMPLETE("03000","sql_statement_not_yet_complete"),
    CONNECTION_EXCEPTION("08000","connection_exception"),
    CONNECTION_DOES_NOT_EXIST("08003","connection_does_not_exist"),
    CONNECTION_FAILURE("08006","connection_failure"),
    SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION("08001","sqlclient_unable_to_establish_sqlconnection"),
    SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION("08004","sqlserver_rejected_establishment_of_sqlconnection"),
    TRANSACTION_RESOLUTION_UNKNOWN("08007","transaction_resolution_unknown"),
    PROTOCOL_VIOLATION("08P01","protocol_violation"),
    TRIGGERED_ACTION_EXCEPTION("09000","triggered_action_exception"),
    FEATURE_NOT_SUPPORTED("0A000","feature_not_supported"),
    INVALID_TRANSACTION_INITIATION("0B000","invalid_transaction_initiation"),
    LOCATOR_EXCEPTION("0F000","locator_exception"),
    L_E_INVALID_SPECIFICATION("0F001","invalid_locator_specification"),
    INVALID_GRANTOR("0L000","invalid_grantor"),
    INVALID_GRANT_OPERATION("0LP01","invalid_grant_operation"),
    INVALID_ROLE_SPECIFICATION("0P000","invalid_role_specification"),
    DIAGNOSTICS_EXCEPTION("0Z000","diagnostics_exception"),
    STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER("0Z002","stacked_diagnostics_accessed_without_active_handler"),
    CASE_NOT_FOUND("20000","case_not_found"),
    CARDINALITY_VIOLATION("21000","cardinality_violation"),
    DATA_EXCEPTION("22000","data_exception"),
    ARRAY_ELEMENT_ERROR("2202E",""),
    ARRAY_SUBSCRIPT_ERROR("2202E","array_subscript_error"),
    CHARACTER_NOT_IN_REPERTOIRE("22021","character_not_in_repertoire"),
    DATETIME_FIELD_OVERFLOW("22008","datetime_field_overflow"),
    DATETIME_VALUE_OUT_OF_RANGE("22008",""),
    DIVISION_BY_ZERO("22012","division_by_zero"),
    ERROR_IN_ASSIGNMENT("22005","error_in_assignment"),
    ESCAPE_CHARACTER_CONFLICT("2200B","escape_character_conflict"),
    INDICATOR_OVERFLOW("22022","indicator_overflow"),
    INTERVAL_FIELD_OVERFLOW("22015","interval_field_overflow"),
    INVALID_ARGUMENT_FOR_LOG("2201E","invalid_argument_for_logarithm"),
    INVALID_ARGUMENT_FOR_NTILE("22014","invalid_argument_for_ntile_function"),
    INVALID_ARGUMENT_FOR_NTH_VALUE("22016","invalid_argument_for_nth_value_function"),
    INVALID_ARGUMENT_FOR_POWER_FUNCTION("2201F","invalid_argument_for_power_function"),
    INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION("2201G","invalid_argument_for_width_bucket_function"),
    INVALID_CHARACTER_VALUE_FOR_CAST("22018","invalid_character_value_for_cast"),
    INVALID_DATETIME_FORMAT("22007","invalid_datetime_format"),
    INVALID_ESCAPE_CHARACTER("22019","invalid_escape_character"),
    INVALID_ESCAPE_OCTET("2200D","invalid_escape_octet"),
    INVALID_ESCAPE_SEQUENCE("22025","invalid_escape_sequence"),
    NONSTANDARD_USE_OF_ESCAPE_CHARACTER("22P06","nonstandard_use_of_escape_character"),
    INVALID_INDICATOR_PARAMETER_VALUE("22010","invalid_indicator_parameter_value"),
    INVALID_PARAMETER_VALUE("22023","invalid_parameter_value"),
    INVALID_PRECEDING_OR_FOLLOWING_SIZE("22013","invalid_preceding_or_following_size"),
    INVALID_REGULAR_EXPRESSION("2201B","invalid_regular_expression"),
    INVALID_ROW_COUNT_IN_LIMIT_CLAUSE("2201W","invalid_row_count_in_limit_clause"),
    INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE("2201X","invalid_row_count_in_result_offset_clause"),
    INVALID_TABLESAMPLE_ARGUMENT("2202H","invalid_tablesample_argument"),
    INVALID_TABLESAMPLE_REPEAT("2202G","invalid_tablesample_repeat"),
    INVALID_TIME_ZONE_DISPLACEMENT_VALUE("22009","invalid_time_zone_displacement_value"),
    INVALID_USE_OF_ESCAPE_CHARACTER("2200C","invalid_use_of_escape_character"),
    MOST_SPECIFIC_TYPE_MISMATCH("2200G","most_specific_type_mismatch"),
    NULL_VALUE_NOT_ALLOWED("22004","null_value_not_allowed"),
    NULL_VALUE_NO_INDICATOR_PARAMETER("22002","null_value_no_indicator_parameter"),
    NUMERIC_VALUE_OUT_OF_RANGE("22003","numeric_value_out_of_range"),
    SEQUENCE_GENERATOR_LIMIT_EXCEEDED("2200H","sequence_generator_limit_exceeded"),
    STRING_DATA_LENGTH_MISMATCH("22026","string_data_length_mismatch"),
    STRING_DATA_RIGHT_TRUNCATION("22001","string_data_right_truncation"),
    SUBSTRING_ERROR("22011","substring_error"),
    TRIM_ERROR("22027","trim_error"),
    UNTERMINATED_C_STRING("22024","unterminated_c_string"),
    ZERO_LENGTH_CHARACTER_STRING("2200F","zero_length_character_string"),
    FLOATING_POINT_EXCEPTION("22P01","floating_point_exception"),
    INVALID_TEXT_REPRESENTATION("22P02","invalid_text_representation"),
    INVALID_BINARY_REPRESENTATION("22P03","invalid_binary_representation"),
    BAD_COPY_FILE_FORMAT("22P04","bad_copy_file_format"),
    UNTRANSLATABLE_CHARACTER("22P05","untranslatable_character"),
    NOT_AN_XML_DOCUMENT("2200L","not_an_xml_document"),
    INVALID_XML_DOCUMENT("2200M","invalid_xml_document"),
    INVALID_XML_CONTENT("2200N","invalid_xml_content"),
    INVALID_XML_COMMENT("2200S","invalid_xml_comment"),
    INVALID_XML_PROCESSING_INSTRUCTION("2200T","invalid_xml_processing_instruction"),
    DUPLICATE_JSON_OBJECT_KEY_VALUE("22030","duplicate_json_object_key_value"),
    INVALID_JSON_TEXT("22032","invalid_json_text"),
    INVALID_JSON_SUBSCRIPT("22033","invalid_json_subscript"),
    MORE_THAN_ONE_JSON_ITEM("22034","more_than_one_json_item"),
    NO_JSON_ITEM("22035","no_json_item"),
    NON_NUMERIC_JSON_ITEM("22036","non_numeric_json_item"),
    NON_UNIQUE_KEYS_IN_JSON_OBJECT("22037","non_unique_keys_in_json_object"),
    SINGLETON_JSON_ITEM_REQUIRED("22038","singleton_json_item_required"),
    JSON_ARRAY_NOT_FOUND("22039","json_array_not_found"),
    JSON_MEMBER_NOT_FOUND("2203A","json_member_not_found"),
    JSON_NUMBER_NOT_FOUND("2203B","json_number_not_found"),
    JSON_OBJECT_NOT_FOUND("2203C","object_not_found"),
    JSON_SCALAR_REQUIRED("2203F","json_scalar_required"),
    TOO_MANY_JSON_ARRAY_ELEMENTS("2203D","too_many_json_array_elements"),
    TOO_MANY_JSON_OBJECT_MEMBERS("2203E","too_many_json_object_members"),
    INTEGRITY_CONSTRAINT_VIOLATION("23000","integrity_constraint_violation"),
    RESTRICT_VIOLATION("23001","restrict_violation"),
    NOT_NULL_VIOLATION("23502","not_null_violation"),
    FOREIGN_KEY_VIOLATION("23503","foreign_key_violation"),
    UNIQUE_VIOLATION("23505","unique_violation"),
    CHECK_VIOLATION("23514","check_violation"),
    EXCLUSION_VIOLATION("23P01","exclusion_violation"),
    INVALID_CURSOR_STATE("24000","invalid_cursor_state"),
    INVALID_TRANSACTION_STATE("25000","invalid_transaction_state"),
    ACTIVE_SQL_TRANSACTION("25001","active_sql_transaction"),
    BRANCH_TRANSACTION_ALREADY_ACTIVE("25002","branch_transaction_already_active"),
    HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL("25008","held_cursor_requires_same_isolation_level"),
    INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION("25003","inappropriate_access_mode_for_branch_transaction"),
    INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION("25004","inappropriate_isolation_level_for_branch_transaction"),
    NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION("25005","no_active_sql_transaction_for_branch_transaction"),
    READ_ONLY_SQL_TRANSACTION("25006","read_only_sql_transaction"),
    SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED("25007","schema_and_data_statement_mixing_not_supported"),
    NO_ACTIVE_SQL_TRANSACTION("25P01","no_active_sql_transaction"),
    IN_FAILED_SQL_TRANSACTION("25P02","in_failed_sql_transaction"),
    IDLE_IN_TRANSACTION_SESSION_TIMEOUT("25P03","idle_in_transaction_session_timeout"),
    INVALID_SQL_STATEMENT_NAME("26000","invalid_sql_statement_name"),
    TRIGGERED_DATA_CHANGE_VIOLATION("27000","triggered_data_change_violation"),
    INVALID_AUTHORIZATION_SPECIFICATION("28000","invalid_authorization_specification"),
    INVALID_PASSWORD("28P01","invalid_password"),
    DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST("2B000","dependent_privilege_descriptors_still_exist"),
    DEPENDENT_OBJECTS_STILL_EXIST("2BP01","dependent_objects_still_exist"),
    INVALID_TRANSACTION_TERMINATION("2D000","invalid_transaction_termination"),
    SQL_ROUTINE_EXCEPTION("2F000","sql_routine_exception"),
    S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT("2F005","function_executed_no_return_statement"),
    S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED("2F002","modifying_sql_data_not_permitted"),
    S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED("2F003","prohibited_sql_statement_attempted"),
    S_R_E_READING_SQL_DATA_NOT_PERMITTED("2F004","reading_sql_data_not_permitted"),
    INVALID_CURSOR_NAME("34000","invalid_cursor_name"),
    EXTERNAL_ROUTINE_EXCEPTION("38000","external_routine_exception"),
    E_R_E_CONTAINING_SQL_NOT_PERMITTED("38001","containing_sql_not_permitted"),
    E_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED("38002","modifying_sql_data_not_permitted"),
    E_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED("38003","prohibited_sql_statement_attempted"),
    E_R_E_READING_SQL_DATA_NOT_PERMITTED("38004","reading_sql_data_not_permitted"),
    EXTERNAL_ROUTINE_INVOCATION_EXCEPTION("39000","external_routine_invocation_exception"),
    E_R_I_E_INVALID_SQLSTATE_RETURNED("39001","invalid_sqlstate_returned"),
    E_R_I_E_NULL_VALUE_NOT_ALLOWED("39004","null_value_not_allowed"),
    E_R_I_E_TRIGGER_PROTOCOL_VIOLATED("39P01","trigger_protocol_violated"),
    E_R_I_E_SRF_PROTOCOL_VIOLATED("39P02","srf_protocol_violated"),
    E_R_I_E_EVENT_TRIGGER_PROTOCOL_VIOLATED("39P03","event_trigger_protocol_violated"),
    SAVEPOINT_EXCEPTION("3B000","savepoint_exception"),
    S_E_INVALID_SPECIFICATION("3B001","invalid_savepoint_specification"),
    INVALID_CATALOG_NAME("3D000","invalid_catalog_name"),
    INVALID_SCHEMA_NAME("3F000","invalid_schema_name"),
    TRANSACTION_ROLLBACK("40000","transaction_rollback"),
    T_R_INTEGRITY_CONSTRAINT_VIOLATION("40002","transaction_integrity_constraint_violation"),
    T_R_SERIALIZATION_FAILURE("40001","serialization_failure"),
    T_R_STATEMENT_COMPLETION_UNKNOWN("40003","statement_completion_unknown"),
    T_R_DEADLOCK_DETECTED("40P01","deadlock_detected"),
    SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION("42000","syntax_error_or_access_rule_violation"),
    SYNTAX_ERROR("42601","syntax_error"),
    INSUFFICIENT_PRIVILEGE("42501","insufficient_privilege"),
    CANNOT_COERCE("42846","cannot_coerce"),
    GROUPING_ERROR("42803","grouping_error"),
    WINDOWING_ERROR("42P20","windowing_error"),
    INVALID_RECURSION("42P19","invalid_recursion"),
    INVALID_FOREIGN_KEY("42830","invalid_foreign_key"),
    INVALID_NAME("42602","invalid_name"),
    NAME_TOO_LONG("42622","name_too_long"),
    RESERVED_NAME("42939","reserved_name"),
    DATATYPE_MISMATCH("42804","datatype_mismatch"),
    INDETERMINATE_DATATYPE("42P18","indeterminate_datatype"),
    COLLATION_MISMATCH("42P21","collation_mismatch"),
    INDETERMINATE_COLLATION("42P22","indeterminate_collation"),
    WRONG_OBJECT_TYPE("42809","wrong_object_type"),
    GENERATED_ALWAYS("428C9","generated_always"),
    UNDEFINED_COLUMN("42703","undefined_column"),
    UNDEFINED_CURSOR("34000",""),
    UNDEFINED_DATABASE("3D000",""),
    UNDEFINED_FUNCTION("42883","undefined_function"),
    UNDEFINED_PSTATEMENT("26000",""),
    UNDEFINED_SCHEMA("3F000",""),
    UNDEFINED_TABLE("42P01","undefined_table"),
    UNDEFINED_PARAMETER("42P02","undefined_parameter"),
    UNDEFINED_OBJECT("42704","undefined_object"),
    DUPLICATE_COLUMN("42701","duplicate_column"),
    DUPLICATE_CURSOR("42P03","duplicate_cursor"),
    DUPLICATE_DATABASE("42P04","duplicate_database"),
    DUPLICATE_FUNCTION("42723","duplicate_function"),
    DUPLICATE_PSTATEMENT("42P05","duplicate_prepared_statement"),
    DUPLICATE_SCHEMA("42P06","duplicate_schema"),
    DUPLICATE_TABLE("42P07","duplicate_table"),
    DUPLICATE_ALIAS("42712","duplicate_alias"),
    DUPLICATE_OBJECT("42710","duplicate_object"),
    AMBIGUOUS_COLUMN("42702","ambiguous_column"),
    AMBIGUOUS_FUNCTION("42725","ambiguous_function"),
    AMBIGUOUS_PARAMETER("42P08","ambiguous_parameter"),
    AMBIGUOUS_ALIAS("42P09","ambiguous_alias"),
    INVALID_COLUMN_REFERENCE("42P10","invalid_column_reference"),
    INVALID_COLUMN_DEFINITION("42611","invalid_column_definition"),
    INVALID_CURSOR_DEFINITION("42P11","invalid_cursor_definition"),
    INVALID_DATABASE_DEFINITION("42P12","invalid_database_definition"),
    INVALID_FUNCTION_DEFINITION("42P13","invalid_function_definition"),
    INVALID_PSTATEMENT_DEFINITION("42P14","invalid_prepared_statement_definition"),
    INVALID_SCHEMA_DEFINITION("42P15","invalid_schema_definition"),
    INVALID_TABLE_DEFINITION("42P16","invalid_table_definition"),
    INVALID_OBJECT_DEFINITION("42P17","invalid_object_definition"),
    WITH_CHECK_OPTION_VIOLATION("44000","with_check_option_violation"),
    INSUFFICIENT_RESOURCES("53000","insufficient_resources"),
    DISK_FULL("53100","disk_full"),
    OUT_OF_MEMORY("53200","out_of_memory"),
    TOO_MANY_CONNECTIONS("53300","too_many_connections"),
    CONFIGURATION_LIMIT_EXCEEDED("53400","configuration_limit_exceeded"),
    PROGRAM_LIMIT_EXCEEDED("54000","program_limit_exceeded"),
    STATEMENT_TOO_COMPLEX("54001","statement_too_complex"),
    TOO_MANY_COLUMNS("54011","too_many_columns"),
    TOO_MANY_ARGUMENTS("54023","too_many_arguments"),
    OBJECT_NOT_IN_PREREQUISITE_STATE("55000","object_not_in_prerequisite_state"),
    OBJECT_IN_USE("55006","object_in_use"),
    CANT_CHANGE_RUNTIME_PARAM("55P02","cant_change_runtime_param"),
    LOCK_NOT_AVAILABLE("55P03","lock_not_available"),
    UNSAFE_NEW_ENUM_VALUE_USAGE("55P04","unsafe_new_enum_value_usage"),
    OPERATOR_INTERVENTION("57000","operator_intervention"),
    QUERY_CANCELED("57014","query_canceled"),
    ADMIN_SHUTDOWN("57P01","admin_shutdown"),
    CRASH_SHUTDOWN("57P02","crash_shutdown"),
    CANNOT_CONNECT_NOW("57P03","cannot_connect_now"),
    DATABASE_DROPPED("57P04","database_dropped"),
    SYSTEM_ERROR("58000","system_error"),
    IO_ERROR("58030","io_error"),
    UNDEFINED_FILE("58P01","undefined_file"),
    DUPLICATE_FILE("58P02","duplicate_file"),
    SNAPSHOT_TOO_OLD("72000","snapshot_too_old"),
    CONFIG_FILE_ERROR("F0000","config_file_error"),
    LOCK_FILE_EXISTS("F0001","lock_file_exists"),
    FDW_ERROR("HV000","fdw_error"),
    FDW_COLUMN_NAME_NOT_FOUND("HV005","fdw_column_name_not_found"),
    FDW_DYNAMIC_PARAMETER_VALUE_NEEDED("HV002","fdw_dynamic_parameter_value_needed"),
    FDW_FUNCTION_SEQUENCE_ERROR("HV010","fdw_function_sequence_error"),
    FDW_INCONSISTENT_DESCRIPTOR_INFORMATION("HV021","fdw_inconsistent_descriptor_information"),
    FDW_INVALID_ATTRIBUTE_VALUE("HV024","fdw_invalid_attribute_value"),
    FDW_INVALID_COLUMN_NAME("HV007","fdw_invalid_column_name"),
    FDW_INVALID_COLUMN_NUMBER("HV008","fdw_invalid_column_number"),
    FDW_INVALID_DATA_TYPE("HV004","fdw_invalid_data_type"),
    FDW_INVALID_DATA_TYPE_DESCRIPTORS("HV006","fdw_invalid_data_type_descriptors"),
    FDW_INVALID_DESCRIPTOR_FIELD_IDENTIFIER("HV091","fdw_invalid_descriptor_field_identifier"),
    FDW_INVALID_HANDLE("HV00B","fdw_invalid_handle"),
    FDW_INVALID_OPTION_INDEX("HV00C","fdw_invalid_option_index"),
    FDW_INVALID_OPTION_NAME("HV00D","fdw_invalid_option_name"),
    FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH("HV090","fdw_invalid_string_length_or_buffer_length"),
    FDW_INVALID_STRING_FORMAT("HV00A","fdw_invalid_string_format"),
    FDW_INVALID_USE_OF_NULL_POINTER("HV009","fdw_invalid_use_of_null_pointer"),
    FDW_TOO_MANY_HANDLES("HV014","fdw_too_many_handles"),
    FDW_OUT_OF_MEMORY("HV001","fdw_out_of_memory"),
    FDW_NO_SCHEMAS("HV00P","fdw_no_schemas"),
    FDW_OPTION_NAME_NOT_FOUND("HV00J","fdw_option_name_not_found"),
    FDW_REPLY_HANDLE("HV00K","fdw_reply_handle"),
    FDW_SCHEMA_NOT_FOUND("HV00Q","fdw_schema_not_found"),
    FDW_TABLE_NOT_FOUND("HV00R","fdw_table_not_found"),
    FDW_UNABLE_TO_CREATE_EXECUTION("HV00L","fdw_unable_to_create_execution"),
    FDW_UNABLE_TO_CREATE_REPLY("HV00M","fdw_unable_to_create_reply"),
    FDW_UNABLE_TO_ESTABLISH_CONNECTION("HV00N","fdw_unable_to_establish_connection"),
    PLPGSQL_ERROR("P0000","plpgsql_error"),
    RAISE_EXCEPTION("P0001","raise_exception"),
    NO_DATA_FOUND("P0002","no_data_found"),
    TOO_MANY_ROWS("P0003","too_many_rows"),
    ASSERT_FAILURE("P0004","assert_failure"),
    INTERNAL_ERROR("XX000","internal_error"),
    DATA_CORRUPTED("XX001","data_corrupted"),
    INDEX_CORRUPTED("XX002","index_corrupted");

    PGErrorStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    private final String code;
    private final String description;

    public String code() {
        return code;
    }

    public String description() {
        return description;
    }

}
