↑↓ 选择↵ 打开⌫ 切换范围完整搜索

PG.CENTER 连接 PostgreSQL 文档、百科与生态知识。由 Pigsty 维护。

Wiki / SQLSTATE

2202H — invalid_tablesample_argument

TABLESAMPLE 方法收到越界的采样参数。

英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。

当前阅读 PG 18·选择有来源记录的版本

aliases
未知
class name
Data Exception
condition name
invalid_tablesample_argument
lang
en
sqlstate
2202H

版本定义 PG 18

2202H

速览 {#at-a-glance}

TABLESAMPLE 方法收到无效参数。固定核心和 contrib 方法会以方法专属报文拒绝越界百分比或负样本数量。

报文 {#messages}

固定执行器和采样方法使用以下首要文本:

| 归属/守卫 | 首要文本 | | --- | --- | | 方法参数为 NULL | TABLESAMPLE parameter cannot be null | | Bernoulli/system 百分比(包括 NaN) | sample percentage must be between 0 and 100 | | system_rows 数量为负 | sample size must not be negative | | system_time 时间为负或 NaN | sample collection time must not be negative |

含义 {#meaning}

2202H 是方法参数代码,不是一个适用于所有 TABLESAMPLE 的统一范围。执行器在调用方法前拒绝 NULL 方法参数。核心 Bernoulli 和 system 方法接受包含端点的 0 到 100 百分比,并拒绝 NaN。system_rows contrib 方法只拒绝负的请求行数,因此零是允许的;system_time 拒绝负值或 NaN 的采样时间,因此零是允许的;该 guard 没有设置有限的上界,正 Infinity 不会被这个比较本身拒绝。REPEATABLE NULL 属于独立的 2202G 分支,其他采样扩展也可能有自己的参数守卫。

诊断 {#diagnosis}

先定位采样方法和参数位置,再修改值。方法参数为 NULL 指向执行器守卫;0 到 100 之外或 NaN 的 Bernoulli/system 百分比指向核心方法;负的 system_rows 数量以及负或 NaN 的 system_time 属于 contrib 方法;该 guard 本身不会把正 Infinity 分类为错误。结合首要报文区分这些情况和 NULL REPEATABLE seed(2202G)。

处理 {#response}

按所选方法使用非 NULL 参数、包含端点的有限 0 到 100 百分比、非负行数或通过其负值/NaN guard 的 system_time 值。不要通过修改方法百分比来修复 2202G 的重复 seed 错误。如果 ERROR 发生在显式事务中,应先 ROLLBACK 或回滚到既有保存点再重试;自动提交可重试修正后的语句。

版本 {#versions}

锁定目录从 9.5.0 起记录该条件;本页固定核心及 contrib 源码路径为 PostgreSQL 18.6。未声称本页有自然运行观察。

相关 {#related}

2202G、22023

来源 {#sources}

执行器 NULL 守卫见 src/backend/executor/nodeSamplescan.c#L232-245。核心百分比守卫见 src/backend/access/tablesample/bernoulli.c#L137-149 和 src/backend/access/tablesample/system.c#L140-152。contrib 范围见 contrib/tsm_system_rows/tsm_system_rows.c#L178-187 和 contrib/tsm_system_time/tsm_system_time.c#L193-203。结构化证据记录保留方法专属报文和范围;本页未运行自然案例。

比较版本

SQLSTATE 证据与已记录的运行版本

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read fixed definition.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "2202H is invalid_tablesample_argument in SQLSTATE Class 22."
}
claims · resolved-path
{
  "claim_id": "resolved-path",
  "limits": "Source confirmation is not a natural runtime observation.",
  "method": "Read the executor parameter loop and complete core/contrib BeginSampleScan guards.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.0",
    "src.nodeSamplescan.argument",
    "src.system.tablesample",
    "src.system_rows.tablesample",
    "src.system_time.tablesample"
  ],
  "statement": "Fixed core and contrib TABLESAMPLE methods share 2202H for method-argument validation: Bernoulli/system reject percentages outside 0..100 and NaN, the executor rejects a NULL method parameter, system_rows rejects negative size, and system_time rejects negative or NaN collection time. The shown system_time guard does not impose a finite upper bound, so positive Infinity is not rejected by that comparison itself."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue boundary.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 2202H 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": "sample percentage must be between 0 and 100",
    "severity_source": "ERROR",
    "sources": [
      "src.path.0"
    ],
    "sqlstate": "2202H"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.0"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "sample percentage must be between 0 and 100",
      "position": 0,
      "role": "",
      "template": "sample percentage must be between 0 and 100"
    }
  ]
}
messages · message.parameter-null
{
  "limits": "",
  "message_id": "message.parameter-null",
  "path": "",
  "position": 1,
  "raw": {
    "id": "message.parameter-null",
    "primary_template": "TABLESAMPLE parameter cannot be null",
    "severity_source": "ERROR",
    "sources": [
      "src.nodeSamplescan.argument"
    ],
    "sqlstate": "2202H"
  },
  "severity": "ERROR",
  "sources": [
    "src.nodeSamplescan.argument"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "TABLESAMPLE parameter cannot be null",
      "position": 0,
      "role": "",
      "template": "TABLESAMPLE parameter cannot be null"
    }
  ]
}
messages · message.sample-percentage
{
  "limits": "",
  "message_id": "message.sample-percentage",
  "path": "",
  "position": 2,
  "raw": {
    "id": "message.sample-percentage",
    "primary_template": "sample percentage must be between 0 and 100",
    "severity_source": "ERROR",
    "sources": [
      "src.path.0"
    ],
    "sqlstate": "2202H"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.0"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "sample percentage must be between 0 and 100",
      "position": 0,
      "role": "",
      "template": "sample percentage must be between 0 and 100"
    }
  ]
}
messages · message.sample-size
{
  "limits": "",
  "message_id": "message.sample-size",
  "path": "",
  "position": 3,
  "raw": {
    "id": "message.sample-size",
    "primary_template": "sample size must not be negative",
    "severity_source": "ERROR",
    "sources": [
      "src.system_rows.tablesample"
    ],
    "sqlstate": "2202H"
  },
  "severity": "ERROR",
  "sources": [
    "src.system_rows.tablesample"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "sample size must not be negative",
      "position": 0,
      "role": "",
      "template": "sample size must not be negative"
    }
  ]
}
messages · message.sample-time
{
  "limits": "",
  "message_id": "message.sample-time",
  "path": "",
  "position": 4,
  "raw": {
    "id": "message.sample-time",
    "primary_template": "sample collection time must not be negative",
    "severity_source": "ERROR",
    "sources": [
      "src.system_time.tablesample"
    ],
    "sqlstate": "2202H"
  },
  "severity": "ERROR",
  "sources": [
    "src.system_time.tablesample"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "sample collection time must not be negative",
      "position": 0,
      "role": "",
      "template": "sample collection time must not be negative"
    }
  ]
}
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#L190"
}
sources · src.path.0
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/access/tablesample/bernoulli.c",
  "position": 1,
  "sha256": "19ab17ceb139db5fbf8ae210b1933bd9632a11cf1307b21228228fa9578d5dce",
  "source_id": "src.path.0",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/access/tablesample/bernoulli.c#L146"
}
sources · src.nodeSamplescan.argument
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/executor/nodeSamplescan.c",
  "position": 2,
  "sha256": "59ddce276a131990661664393bf645d62693a722f382bd040f6b1c2584e7b2a5",
  "source_id": "src.nodeSamplescan.argument",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/executor/nodeSamplescan.c#L232"
}
sources · src.system.tablesample
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/access/tablesample/system.c",
  "position": 3,
  "sha256": "68775686cd9e9c9bc4bcb34bad5ff8fa3993aea3b7db56ecacd07251e42aada5",
  "source_id": "src.system.tablesample",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/access/tablesample/system.c#L140"
}
sources · src.system_rows.tablesample
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "contrib/tsm_system_rows/tsm_system_rows.c",
  "position": 4,
  "sha256": "192b921607c93979a09625f9d54d583d6f2e8ee8566aeb8cc09152271d04066c",
  "source_id": "src.system_rows.tablesample",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/tsm_system_rows/tsm_system_rows.c#L178"
}
sources · src.system_time.tablesample
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "contrib/tsm_system_time/tsm_system_time.c",
  "position": 5,
  "sha256": "c3dc4faa00302e4bb993a468f7c62612da3db97cf85152c4cb3fe5b5d18d89c9",
  "source_id": "src.system_time.tablesample",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/tsm_system_time/tsm_system_time.c#L193"
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:92ccccbac24b4c97299bb23f5abdf72b5e4448117705ab408904efba31d73b33

正文语言: zh-Hans · english-manuals:92ccccbac24b4c97299bb23f5abdf72b5e4448117705ab408904efba31d73b33