百科 / 错误代码 / Class 22 数据异常
22036 non_numeric_sql_json_item
ERROR 源码确认 参考 未实测
- 条件名
non_numeric_sql_json_item- 宏名称
ERRCODE_NON_NUMERIC_SQL_JSON_ITEM- 启用版本
- 12
- 状态
- 活跃
版本覆盖
速览
JSON 路径项方法收到的值不满足数值或转换约束。固定路径覆盖 .number()、.decimal()、.integer()、.bigint()、.double()、.boolean()、.abs()、.floor()、.ceiling(),以及 .string() 的相应类型检查。
报文
固定 jsonpath 方法的代表性首要报文如下:
| 触发条件 | 首要报文 |
|---|---|
.abs()、.floor() 或 .ceiling() 收到非数值项 |
jsonpath item method .%s() can only be applied to a numeric value |
| 转换方法收到的既不是字符串也不是数值项 | jsonpath item method .%s() can only be applied to a string or numeric value |
.boolean() 收到不支持的项 |
jsonpath item method .%s() can only be applied to a boolean, string, or numeric value |
| 字符串或数值不能转换为目标类型 | argument "%s" of jsonpath item method .%s() is invalid for type %s |
| 数值转换得到 NaN 或 Infinity | NaN or Infinity is not allowed for jsonpath item method .%s() |
.string() 收到不支持的项 |
jsonpath item method .%s() can only be applied to a boolean, string, numeric, or datetime value |
报文模板
源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。
jsonpath item method .%s() can only be applied to a numeric value
jsonpath item method .%s() can only be applied to a string or numeric value
jsonpath item method .%s() can only be applied to a boolean, string, or numeric value
argument "%s" of jsonpath item method .%s() is invalid for type %s
NaN or Infinity is not allowed for jsonpath item method .%s()
jsonpath item method .%s() can only be applied to a boolean, string, numeric, or datetime value
含义
jsonpath 执行器会按输入类型分派各项方法。.integer()、.bigint()、.double() 以及 .number()/.decimal() 处理字符串输入时,会使用目标输入例程或数值解析,并通过 ErrorSaveContext 或显式错误标志记录失败。已有数值项走各自分支:.number() 可直接保留数值,.integer() 和 .bigint() 使用 numeric_int4_opt_error/numeric_int8_opt_error,.decimal() 再应用精度/小数位 typmod。.boolean() 直接接受布尔值,用 int4in 转换数值,用 parse_bool 解析字符串;.abs()、.floor() 和 .ceiling() 要求数值标量。数值和 double 路径拒绝 NaN 或 Infinity。.string() 的约束更宽,可接受布尔、字符串、数值或日期时间项;只有路径模式允许时才会解包数组。
诊断
查看首要报文中的方法名、项类型和值。区分字符串解析和已有数值项:.number() 可直接处理已有数值,.integer()/.bigint() 做数值范围检查,.decimal() 可能应用精度/小数位 typmod,.boolean() 有直接、数值和 parse_bool 分支。对象、数组或不支持的项属于类型问题。若方法拒绝非有限数值,应在调用前移除或拦截它。不要把 make_numeric_typmod_safe 的所有底层精度/小数位诊断都归为 22036,只保留已展示的 jsonpath 报错分支。不要把本码与一元算术操作数检查条件 2203B,或 JSON 路径日期时间方法 22031 混淆。
处理
修改路径以选中预期标量,在转换前规范化文档,或改用符合该值输入约束的方法。若源数据可能变化,应在调用方法前验证数值文本和有限性。如果 ERROR 发生在显式事务中,应先 ROLLBACK 或回滚到既有保存点再重试;自动提交可重试修正后的动作。
版本
锁定目录从 12.0 起记录该条件;固定的转换和项方法路径来自 PostgreSQL 18.6。本页未声称有自然运行观察。
来源
- 上游源码 src/backend/utils/errcodes.txt 第 221 行
- 上游源码 src/backend/utils/adt/jsonpath_exec.c 第 235 行
- 上游源码 src/backend/utils/adt/jsonpath_exec.c 第 654 行
- 上游源码 src/backend/utils/adt/jsonpath_exec.c 第 1129 行
- 上游源码 src/backend/utils/adt/jsonpath_exec.c 第 2280 行
- 上游源码 src/backend/utils/adt/jsonpath_exec.c 第 1592 行
证据
断言
每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。
-
22036 is non_numeric_sql_json_item in SQLSTATE Class 22.
-
The fixed jsonpath numeric item-method branches dispatch by input type. String inputs for .integer(), .bigint(), .double(), and the string side of .number()/.decimal() use target input or numeric parsing with ErrorSaveContext or an explicit error flag. Existing numeric items use 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. Numeric-only methods reject nonnumeric items; .string() accepts boolean, string, numeric, or datetime items. Non-finite values are rejected by the shown numeric/double branches. Source confirmation is not a natural runtime observation.
-
The locked catalogue records 22036 from 12.0 without proving exact implementation introduction.
同类错误代码
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_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_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