百科 / 错误代码 / Class 22 数据异常
22005 error_in_assignment
ERROR 源码确认 参考 未实测
- 条件名
error_in_assignment- 宏名称
ERRCODE_ERROR_IN_ASSIGNMENT- 启用版本
- 7.4
- 状态
- 活跃
版本覆盖
速览
22005 是 error_in_assignment,表示赋值操作违反了目标变量的赋值契约。固定 PL/pgSQL 路径报告常量变量被赋值:variable "%s" is declared CONSTANT。
含义
固定 PL/pgSQL 路径报告常量变量被赋值:variable "%s" is declared CONSTANT。
exec_check_assignable 会对 PL/pgSQL 变量、promise 变量和 isconst 为真的 record 执行该检查;record field 会递归检查父 record,而 row datum 本身可赋值。因此诊断时要结合 routine 上下文和报文中的 datum 名称。
报文
已确认分支以 ERROR 严重性报告 primary:variable "%s" is declared CONSTANT。固定源码没有 DETAIL 或 HINT。本页只有源码证据,没有自然运行观察。
报文模板
源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。
variable "%s" is declared CONSTANT
诊断
读取 message 中的变量名和 routine 上下文;固定路径是 PL/pgSQL 常量赋值错误,不是一般类型转换错误。
处置
移除该赋值、在确需可变时调整声明,或写入另一个变量;先修正 routine 再重做业务操作。显式事务中,未捕获的 ERROR 会使事务失败,应回滚整个事务或回滚到调用前建立的保存点。若 routine 有意使用 PL/pgSQL EXCEPTION 块处理错误,则可由其子事务隔离;本页没有运行案例证明特定 handler 的行为。
版本
锁定目录从 7.4 记录该条件,并在列出的正式快照及 19beta3 中出现;固定源码覆盖为 PostgreSQL 18.6。
来源
- 上游源码 src/backend/utils/errcodes.txt 第 169 行
- 上游源码 src/pl/plpgsql/src/pl_exec.c 第 8565–8582 行
- 核验材料 raw/calls/REL_18_6.jsonl
证据
断言
每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。
-
22005 is error_in_assignment in SQLSTATE Class 22.
-
PL/pgSQL assignment checking rejects writes to a variable marked CONSTANT and reports the variable name.
-
The locked catalogue records 22005 from 7.4 without proving an exact implementation introduction date.
同类错误代码
Class 22 数据异常 下的其他成员。
22000data_exception22001string_data_right_truncation22002null_value_no_indicator_parameter22003numeric_value_out_of_range22004null_value_not_allowed22007invalid_datetime_format22008datetime_field_overflow22009invalid_time_zone_displacement_value2200Bescape_character_conflict2200Cinvalid_use_of_escape_character2200Dinvalid_escape_octet2200Fzero_length_character_string2200Gmost_specific_type_mismatch2200Hsequence_generator_limit_exceeded2200Lnot_an_xml_document2200Minvalid_xml_document2200Ninvalid_xml_content2200Sinvalid_xml_comment2200Tinvalid_xml_processing_instruction22010invalid_indicator_parameter_value22011substring_error22012division_by_zero22013invalid_preceding_or_following_size22014invalid_argument_for_ntile_function22015interval_field_overflow22016invalid_argument_for_nth_value_function22018invalid_character_value_for_cast22019invalid_escape_character2201Binvalid_regular_expression2201Einvalid_argument_for_logarithm2201Finvalid_argument_for_power_function2201Ginvalid_argument_for_width_bucket_function2201Winvalid_row_count_in_limit_clause2201Xinvalid_row_count_in_result_offset_clause22021character_not_in_repertoire22022indicator_overflow22023invalid_parameter_value22024unterminated_c_string22025invalid_escape_sequence22026string_data_length_mismatch22027trim_error2202Earray_subscript_error2202Ginvalid_tablesample_repeat2202Hinvalid_tablesample_argument22030duplicate_json_object_key_value22031invalid_argument_for_sql_json_datetime_function22032invalid_json_text22033invalid_sql_json_subscript22034more_than_one_sql_json_item22035no_sql_json_item22036non_numeric_sql_json_item22037non_unique_keys_in_a_json_object22038singleton_sql_json_item_required22039sql_json_array_not_found2203Asql_json_member_not_found2203Bsql_json_number_not_found2203Csql_json_object_not_found2203Dtoo_many_json_array_elements2203Etoo_many_json_object_members2203Fsql_json_scalar_required2203Gsql_json_item_cannot_be_cast_to_target_type22P01floating_point_exception22P02invalid_text_representation22P03invalid_binary_representation22P04bad_copy_file_format22P05untranslatable_character22P06nonstandard_use_of_escape_character