2202G
PostgreSQLERRORNotableData ExceptionHIGH confidence

invalid tablesample repeat

What this means

SQLSTATE 2202G is raised when the REPEATABLE seed value passed to a TABLESAMPLE clause is invalid.

Why it happens
  1. 1Passing an out-of-range or NULL seed value to TABLESAMPLE BERNOULLI(p) REPEATABLE(seed)
How to reproduce

TABLESAMPLE with an invalid REPEATABLE seed.

trigger — this will error
trigger — this will error
SELECT * FROM orders TABLESAMPLE SYSTEM(10) REPEATABLE(NULL);

expected output

ERROR:  tablesample_repeat must not be null

Fix

Provide a valid non-NULL numeric seed to REPEATABLE

WHEN When reproducible sampling is needed.

Provide a valid non-NULL numeric seed to REPEATABLE
SELECT * FROM orders TABLESAMPLE SYSTEM(10) REPEATABLE(42);

Why this works

The REPEATABLE seed must be a non-NULL numeric value. The same seed produces the same sample across runs (for SYSTEM method).

Version notes
Postgres 9.5+

TABLESAMPLE and REPEATABLE introduced in 9.5.

Sources
Official documentation ↗

Class 22 — Data Exception

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All PostgreSQL errors