百科 / 错误代码 / Class 22 数据异常
2202H invalid_tablesample_argument
ERROR 源码确认 参考 未实测
- 条件名
invalid_tablesample_argument- 宏名称
ERRCODE_INVALID_TABLESAMPLE_ARGUMENT- 启用版本
- 9.5
- 状态
- 活跃
版本覆盖
速览
TABLESAMPLE 方法收到无效参数。固定核心和 contrib 方法会以方法专属报文拒绝越界百分比或负样本数量。
报文
固定执行器和采样方法使用以下首要文本:
| 归属/守卫 | 首要文本 |
|---|---|
| 方法参数为 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 |
报文模板
源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。
sample percentage must be between 0 and 100
TABLESAMPLE parameter cannot be null
sample percentage must be between 0 and 100
sample size must not be negative
sample collection time must not be negative
含义
2202H 是方法参数代码,不是一个适用于所有 TABLESAMPLE 的统一范围。执行器在调用方法前拒绝 NULL 方法参数。核心 Bernoulli 和 system 方法接受包含端点的 0 到 100 百分比,并拒绝 NaN。system_rows contrib 方法只拒绝负的请求行数,因此零是允许的;system_time 拒绝负值或 NaN 的采样时间,因此零是允许的;该 guard 没有设置有限的上界,正 Infinity 不会被这个比较本身拒绝。REPEATABLE NULL 属于独立的 2202G 分支,其他采样扩展也可能有自己的参数守卫。
诊断
先定位采样方法和参数位置,再修改值。方法参数为 NULL 指向执行器守卫;0 到 100 之外或 NaN 的 Bernoulli/system 百分比指向核心方法;负的 system_rows 数量以及负或 NaN 的 system_time 属于 contrib 方法;该 guard 本身不会把正 Infinity 分类为错误。结合首要报文区分这些情况和 NULL REPEATABLE seed(2202G)。
处理
按所选方法使用非 NULL 参数、包含端点的有限 0 到 100 百分比、非负行数或通过其负值/NaN guard 的 system_time 值。不要通过修改方法百分比来修复 2202G 的重复 seed 错误。如果 ERROR 发生在显式事务中,应先 ROLLBACK 或回滚到既有保存点再重试;自动提交可重试修正后的语句。
版本
锁定目录从 9.5.0 起记录该条件;本页固定核心及 contrib 源码路径为 PostgreSQL 18.6。未声称本页有自然运行观察。
来源
- 上游源码 src/backend/utils/errcodes.txt 第 190 行
- 上游源码 src/backend/executor/nodeSamplescan.c 第 232 行
- 上游源码 src/backend/access/tablesample/bernoulli.c 第 146 行
- 上游源码 src/backend/access/tablesample/system.c 第 140 行
- 上游源码 contrib/tsm_system_rows/tsm_system_rows.c 第 178 行
- 上游源码 contrib/tsm_system_time/tsm_system_time.c 第 193 行
证据
断言
每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。
-
2202H is invalid_tablesample_argument in SQLSTATE Class 22.
-
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.
-
The locked catalogue records 2202H from 9.5.0 without proving exact implementation introduction.
同类错误代码
Class 22 数据异常 下的其他成员。
22000data_exception22001string_data_right_truncation22002null_value_no_indicator_parameter22003numeric_value_out_of_range22004null_value_not_allowed22005error_in_assignment22007invalid_datetime_format22008datetime_field_overflow22009invalid_time_zone_displacement_value2200Bescape_character_conflict2200Cinvalid_use_of_escape_character2200Dinvalid_escape_octet2200Fzero_length_character_string2200Gmost_specific_type_mismatch2200Hsequence_generator_limit_exceeded2200Lnot_an_xml_document2200Minvalid_xml_document2200Ninvalid_xml_content2200Sinvalid_xml_comment2200Tinvalid_xml_processing_instruction22010invalid_indicator_parameter_value22011substring_error22012division_by_zero22013invalid_preceding_or_following_size22014invalid_argument_for_ntile_function22015interval_field_overflow22016invalid_argument_for_nth_value_function22018invalid_character_value_for_cast22019invalid_escape_character2201Binvalid_regular_expression2201Einvalid_argument_for_logarithm2201Finvalid_argument_for_power_function2201Ginvalid_argument_for_width_bucket_function2201Winvalid_row_count_in_limit_clause2201Xinvalid_row_count_in_result_offset_clause22021character_not_in_repertoire22022indicator_overflow22023invalid_parameter_value22024unterminated_c_string22025invalid_escape_sequence22026string_data_length_mismatch22027trim_error2202Earray_subscript_error2202Ginvalid_tablesample_repeat22030duplicate_json_object_key_value22031invalid_argument_for_sql_json_datetime_function22032invalid_json_text22033invalid_sql_json_subscript22034more_than_one_sql_json_item22035no_sql_json_item22036non_numeric_sql_json_item22037non_unique_keys_in_a_json_object22038singleton_sql_json_item_required22039sql_json_array_not_found2203Asql_json_member_not_found2203Bsql_json_number_not_found2203Csql_json_object_not_found2203Dtoo_many_json_array_elements2203Etoo_many_json_object_members2203Fsql_json_scalar_required2203Gsql_json_item_cannot_be_cast_to_target_type22P01floating_point_exception22P02invalid_text_representation22P03invalid_binary_representation22P04bad_copy_file_format22P05untranslatable_character22P06nonstandard_use_of_escape_character