# 2201X — invalid_row_count_in_result_offset_clause

> Source-backed reference for PostgreSQL SQLSTATE 2201X.
---

# 2201X

## At a glance {#at-a-glance}
An OFFSET expression is negative after evaluation. The fixed executor path reports `OFFSET must not be negative`.

<!-- BEGIN SQLSTATE FACTS: generated by scripts/generate.py; do not edit -->

| 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 | `—` |

<!-- source facts: data/errcodes/2201X.json -->
<!-- END SQLSTATE FACTS -->

## Meaning {#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 {#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 {#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 {#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 {#related}
[`2201W`](../2201w/), [`22003`](../22003/)

## Sources {#sources}
The executor’s NULL-to-zero and negative guard are in [`src/backend/executor/nodeLimit.c#L356-375`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/executor/nodeLimit.c#L356). The structured [evidence record](../data/evidence/2201x.json) retains the exact primary template and source boundary; no natural runtime was run.
