2201X
Read PG 18 manual ↗invalid_row_count_in_result_offset_clause
- SQLSTATE
- 2201X
- Condition name
- invalid_row_count_in_result_offset_clause
- Class
- Data Exception
- Source macro
- ERRCODE_INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE
- Evidence
- Source path confirmed
English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗
At a glance
An OFFSET expression is negative after evaluation. The fixed executor path reports OFFSET must not be negative.
Meaning
During LIMIT-node recomputation, a NULL OFFSET is interpreted as zero (no offset), zero is valid, and only a negative evaluated offset reaches 2201X. This is the OFFSET-specific sibling of 2201W; LIMIT count rules must be diagnosed from their own SQLSTATE.
Diagnosis
Inspect the evaluated OFFSET expression after parameter substitution and type resolution. Distinguish NULL/no offset and zero from a negative value, and do not relabel a LIMIT or FETCH row-count failure as 2201X.
Response
Supply a non-negative OFFSET, or NULL when the intended result is no offset. If the ERROR occurred in an explicit transaction, roll back or roll back to the existing savepoint before retrying; autocommit can retry the corrected statement.
Versions
The locked catalogue records this condition from 8.4.0; the fixed source path here is PostgreSQL 18.6. No natural runtime observation is claimed for this page.
Sources
The executor’s NULL-to-zero and negative guard are in src/backend/executor/nodeLimit.c#L356-375. The structured evidence record retains the exact primary template and source boundary; 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.
2201X is invalid_row_count_in_result_offset_clause in SQLSTATE Class 22
Method: Read the fixed errcodes row and macro.
Fixed PostgreSQL 18.6 executor recomputation maps NULL OFFSET to zero and emits 2201X only for a negative evaluated offset.
Method: Read complete source contexts for the representative guards.
Limits: Source confirmation is not a natural runtime observation.
The locked catalogue records 2201X from 8.4.0 without proving an exact implementation introduction date.
Method: Use catalogue presence and history boundaries.
- src/backend/utils/errcodes.txt · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/executor/nodeLimit.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7
Message templates
ERROR · message.offset-negative
Primary
OFFSET must not be negative
Reproduction & repair cases
No reproduction case is attached to this condition.
Recorded runtime evidence
No runtime observation is attached to this entry.
Definition snapshot: english-manuals:10088c28ec2c7b7cfc3cdd869bb… · English manual source