↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / SQLSTATE

2202G — invalid_tablesample_repeat

The TABLESAMPLE REPEATABLE seed is invalid when it is NULL. The fixed executor path reports TABLESAMPLE REPEATABLE parameter cannot be null.

English manual coverage begins with PostgreSQL 8.1. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

aliases
Unknown
class name
Data Exception
condition name
invalid_tablesample_repeat
lang
en
sqlstate
2202G

Definition PG 18

2202G

At a glance {#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 {#messages}

The executor guard uses this primary text:

| Guard | Primary | | --- | --- | | NULL REPEATABLE expression | TABLESAMPLE REPEATABLE parameter cannot be null |

Meaning {#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 {#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 {#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 {#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.

Related {#related}

2202H, 22004

Sources {#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.

Compare versions

SQLSTATE evidence and recorded runtime versions

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read fixed definition.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "2202G is invalid_tablesample_repeat in SQLSTATE Class 22."
}
claims · resolved-path
{
  "claim_id": "resolved-path",
  "limits": "Source confirmation is not natural runtime.",
  "method": "Read the complete fixed source context.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.0"
  ],
  "statement": "Fixed source supports the representative 2202G path described."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue boundary.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 2202G from 9.5.0 without proving exact implementation introduction."
}
messages · message.0
{
  "limits": "",
  "message_id": "message.0",
  "path": "",
  "position": 0,
  "raw": {
    "id": "message.0",
    "primary_template": "TABLESAMPLE REPEATABLE parameter cannot be null",
    "severity_source": "ERROR",
    "sources": [
      "src.path.0"
    ],
    "sqlstate": "2202G"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.0"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "TABLESAMPLE REPEATABLE parameter cannot be null",
      "position": 0,
      "role": "",
      "template": "TABLESAMPLE REPEATABLE parameter cannot be null"
    }
  ]
}
sources · src.errcodes.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/errcodes.txt",
  "position": 0,
  "sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
  "source_id": "src.errcodes.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L191"
}
sources · src.path.0
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/executor/nodeSamplescan.c",
  "position": 1,
  "sha256": "59ddce276a131990661664393bf645d62693a722f382bd040f6b1c2584e7b2a5",
  "source_id": "src.path.0",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/executor/nodeSamplescan.c#L254"
}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · english-manuals:8089c1baa70237500965dc3647843a3ae0d42c903b31570646e6a84750dc4ca0

Text language: en · english-manuals:8089c1baa70237500965dc3647843a3ae0d42c903b31570646e6a84750dc4ca0