22033
Read PG 18 manual ↗invalid_sql_json_subscript
- SQLSTATE
- 22033
- Condition name
- invalid_sql_json_subscript
- Class
- Data Exception
- Source macro
- ERRCODE_INVALID_SQL_JSON_SUBSCRIPT
- Evidence
- Source path confirmed
English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗
At a glance
A SQL/JSON array subscript is invalid. Fixed jsonpath paths distinguish out-of-bounds, non-single-numeric, and integer-range variants.
Messages
The fixed subscript guards use these primary texts:
| Guard | Primary |
|---|---|
| subscript is not one numeric item | jsonpath array subscript is not a single numeric value |
| numeric subscript outside int32 | jsonpath array subscript is out of integer range |
| strict array bound failure | jsonpath array subscript is out of bounds |
Meaning
The jsonpath executor evaluates each subscript expression as a result list. getArrayIndex requires exactly one numeric scalar, truncates it to an integer, and reports 22033 when the result is not a single numeric item or cannot fit the integer range. The later array-bound guard reports the same code for a negative start, reversed range, or upper bound past the array in strict mode. Lax mode ignores that structural out-of-bounds error and clamps the range to the available array; it does not turn a non-numeric or overflowing subscript into a valid index.
Diagnosis
Inspect the subscript expression’s cardinality and type before inspecting array length. A path that yields multiple items, a non-numeric value, or an integer overflow uses the conversion messages; a numeric index or range that violates strict array bounds uses the out-of-bounds message. Record whether the path is strict or lax, because lax structural handling can produce an empty or clamped result instead of this ERROR. A later no-item behavior is 22035 when its SQL/JSON operation chooses to raise it.
Response
Make the subscript expression return one finite numeric value in the integer range, and keep strict-mode bounds within the target array with a non-reversed range. If lax clamping or an empty result is intended, confirm that the path mode and surrounding SQL/JSON behavior express that intent. If an ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected expression.
Versions
The locked catalogue records this condition from 12.0; the fixed jsonpath source paths here are PostgreSQL 18.6. No natural runtime observation is claimed for this page.
Sources
Array-bound handling is src/backend/utils/adt/jsonpath_exec.c#L892-929. Subscript cardinality, truncation, and integer conversion are #L3442-3477. The structured evidence record retains all three 22033 guard roles; no natural runtime was run.
Source evidence
Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.
22033 is invalid_sql_json_subscript in SQLSTATE Class 22.
Method: Read fixed definition.
The fixed jsonpath executor evaluates each subscript to one numeric item, truncates it to int32, and raises 22033 for a non-single numeric result or integer-range overflow; strict mode also raises for invalid array bounds, while lax mode ignores structural out-of-bounds errors and clamps the range.
Method: Read the complete array-subscript execution and getArrayIndex conversion guards.
Limits: Source confirmation is not a natural runtime observation.
The locked catalogue records 22033 from 12.0 without proving exact implementation introduction.
Method: Use catalogue boundary.
- src/backend/utils/errcodes.txt · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/utils/adt/jsonpath_exec.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/utils/adt/jsonpath_exec.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7
Message templates
ERROR · message.0
Primary
jsonpath array subscript is out of bounds
ERROR · message.non-single-numeric
Primary
jsonpath array subscript is not a single numeric value
ERROR · message.integer-range
Primary
jsonpath array subscript is out of integer range
Reproduction & repair cases
No reproduction case is attached to this condition.
Recorded runtime evidence
No runtime observation is attached to this entry.
Version history 1
- PG 11 → 12added
Definition snapshot: english-manuals:2f87dd98ee93810faefeba375ad… · English manual source