2201X — invalid_row_count_in_result_offset_clause
2201X
At a glance
An OFFSET expression is negative after evaluation. The fixed executor path reports OFFSET must not be negative.
| Field | Value |
|---|---|
| SQLSTATE | 2201X |
| Condition | invalid_row_count_in_result_offset_clause |
| Status | active |
| Known present by | 8.4.0 |
| Locked snapshots | 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3 |
| Macros | ERRCODE_INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE |
| Aliases | — |
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.
Related
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.