2202G
Read PG 18 manual ↗invalid_tablesample_repeat
- SQLSTATE
- 2202G
- Condition name
- invalid_tablesample_repeat
- Class
- Data Exception
- Source macro
- ERRCODE_INVALID_TABLESAMPLE_REPEAT
- Evidence
- Source path confirmed
English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗
At a glance
The TABLESAMPLE REPEATABLE seed is invalid when it is NULL. The fixed executor path reports TABLESAMPLE REPEATABLE parameter cannot be null.
Messages
The executor guard uses this primary text:
| Guard | Primary |
|---|---|
NULL REPEATABLE expression |
TABLESAMPLE REPEATABLE parameter cannot be null |
Meaning
During tablesample_init, PostgreSQL evaluates each TABLESAMPLE method argument first and reports 2202H when one is NULL. It then evaluates the optional REPEATABLE expression separately; a NULL result takes the 2202G branch. A non-NULL REPEATABLE value has already been coerced to float8 by the parser and is hashed with hashfloat8 to make the sampling seed. This code therefore covers the repeat-seed NULL contract, not a negative seed or a method percentage range.
Diagnosis
Inspect the evaluated REPEATABLE expression, including a parameter or function that may become SQL NULL. Keep it separate from a NULL TABLESAMPLE method argument, which uses 2202H, and from a non-NULL but invalid percentage, size, or time argument, which is checked by the selected sampling method. The primary text identifies the repeat-seed branch.
Response
Supply a non-NULL expression to REPEATABLE, or omit the clause when deterministic repetition is not required. Correct the method argument separately if its own 2202H guard fires. If an 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 9.5.0; the fixed source path here is PostgreSQL 18.6. No natural runtime observation is claimed for this page.
Sources
The executor evaluates method arguments and then the optional repeat expression in src/backend/executor/nodeSamplescan.c#L232-267. The structured evidence record retains the 2202G guard and its boundary with 2202H; 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.
2202G is invalid_tablesample_repeat in SQLSTATE Class 22.
Method: Read fixed definition.
Fixed source supports the representative 2202G path described.
Method: Read the complete fixed source context.
Limits: Source confirmation is not natural runtime.
The locked catalogue records 2202G from 9.5.0 without proving exact implementation introduction.
Method: Use catalogue boundary.
- src/backend/utils/errcodes.txt · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/executor/nodeSamplescan.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7
Message templates
ERROR · message.0
Primary
TABLESAMPLE REPEATABLE parameter cannot be null
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 9.4 → 9.5added
Definition snapshot: english-manuals:2e036ae5288b5de921a8aba550a… · English manual source