百科 / 错误代码 / Class 22 数据异常
2201F invalid_argument_for_power_function
ERROR 源码确认 参考 未实测
- 条件名
invalid_argument_for_power_function- 宏名称
ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION- 启用版本
- 8.0
- 状态
- 活跃
版本覆盖
速览
幂函数会拒绝实数结果未定义的操作数。固定 numeric 路径报告 zero raised to a negative power is undefined 或 a negative number raised to a non-integer power yields a complex result。
含义
2201F 覆盖两个不同的幂运算守卫:零底数配负指数,以及负底数配非整数指数。普通有限 numeric 路径和特殊值路径都存在相应检查。按 POSIX 规则,numeric 的 NaN 可能返回 NaN 或 1,若干无穷组合也有定义结果;负底数配整数指数并不自动触发本码。
报文模板
源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。
zero raised to a negative power is undefined
来源:src/backend/utils/adt/numeric.c @ REL_18_6 · src/backend/utils/adt/numeric.c @ REL_18_6
a negative number raised to a non-integer power yields a complex result
来源:src/backend/utils/adt/numeric.c @ REL_18_6 · src/backend/utils/adt/numeric.c @ REL_18_6
诊断
检查解析后的底数、指数类型和首要报文。非整数小数指数与负整数指数不是同一种情况,改小数位数或无关 cast 不能修复定义域。特殊值要单独判断,不要把所有 NaN 或无穷值都当成无效幂运算。
处理
选择具有预期实数结果的底数/指数,或明确改变业务规则。如果 ERROR 发生在显式事务中,应先 ROLLBACK 或回滚到既有保存点再重试;自动提交客户端可直接重试修正后的操作。
版本
锁定目录从 8.0.0 起记录该条件;本页固定源码路径为 PostgreSQL 18.6。未声称本页有自然运行观察。
来源
- 上游源码 src/backend/utils/errcodes.txt 第 176 行
- 上游源码 src/backend/utils/adt/numeric.c 第 4208 行
- 上游源码 src/backend/utils/adt/numeric.c 第 11373 行
- 上游源码 src/backend/utils/adt/numeric.c 第 4045 行
证据
断言
每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。
-
2201F is invalid_argument_for_power_function in SQLSTATE Class 22
-
Fixed PostgreSQL 18.6 numeric power paths bind zero-negative-exponent and negative-base-non-integral guards, including finite and special-value branches.
-
The locked catalogue records 2201F from 8.0.0 without proving an exact implementation introduction date.
同类错误代码
Class 22 数据异常 下的其他成员。
22000data_exception22001string_data_right_truncation22002null_value_no_indicator_parameter22003numeric_value_out_of_range22004null_value_not_allowed22005error_in_assignment22007invalid_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_logarithm2201Ginvalid_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