Skip to content

22036 — non_numeric_sql_json_item

Source-backed reference for PostgreSQL SQLSTATE 22036.

22036

At a glance

A JSON path item method received a value that cannot satisfy its numeric or conversion contract. The fixed paths cover .number(), .decimal(), .integer(), .bigint(), .double(), .boolean(), .abs(), .floor(), .ceiling(), and the corresponding type checks in .string().

Field Value
SQLSTATE 22036
Condition non_numeric_sql_json_item
Status active
Known present by 12.0
Locked snapshots 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_NON_NUMERIC_SQL_JSON_ITEM
Aliases

Messages

Representative primary texts from the fixed jsonpath methods are:

Guard Primary
.abs(), .floor(), or .ceiling() receives a non-numeric item jsonpath item method .%s() can only be applied to a numeric value
A conversion method receives neither a string nor numeric item jsonpath item method .%s() can only be applied to a string or numeric value
.boolean() receives an unsupported item jsonpath item method .%s() can only be applied to a boolean, string, or numeric value
A string or numeric value cannot be converted to the target type argument "%s" of jsonpath item method .%s() is invalid for type %s
Numeric conversion produces NaN or Infinity NaN or Infinity is not allowed for jsonpath item method .%s()
.string() receives an unsupported item jsonpath item method .%s() can only be applied to a boolean, string, numeric, or datetime value

Meaning

The jsonpath executor dispatches each item method according to its input type. String inputs for .integer(), .bigint(), .double(), and the string side of .number()/.decimal() use their target input or numeric parser with an ErrorSaveContext or explicit error flag. Existing numeric items take 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; .abs(), .floor(), and .ceiling() require a numeric scalar. Numeric and double paths reject NaN or Infinity. .string() has a wider contract and accepts boolean, string, numeric, or datetime items; arrays can be unwrapped only when the path mode permits it.

Diagnosis

Read the method name, item type, and value in the primary. Separate string parsing from an existing numeric item: .number() can pass an existing numeric through, .integer()/.bigint() use numeric range checks, .decimal() may apply precision/scale typmod, and .boolean() has direct, numeric, and parse_bool branches. An object, array, or unsupported item is an item-type case. Remove or guard non-finite numeric values where the method rejects them. Do not assign every lower-level precision/scale diagnostic from make_numeric_typmod_safe to 22036; keep only the shown jsonpath error branches in scope. Keep this condition separate from 2203B, which is the unary arithmetic operand check, and from 22031, which covers JSON path datetime methods.

Response

Change the path to select the intended scalar, normalize the document before conversion, or use a method whose input contract matches the value. Validate numeric text and finite values before invoking the method when the source can vary. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected action.

Versions

The locked catalogue records this condition from 12.0; the fixed conversion and item-method paths are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

2203B, 22031, 22038

Sources

The numeric item-method checks are jsonpath_exec.c#L1129-1588, the .string() type contract is #L1592-1647, and numeric-only methods are #L2280-2310. The strict/lax and throw-return macros are #L235-249. The structured evidence record binds these guards and messages; no natural runtime was run.