百科 / 错误代码 / Class 22 数据异常
22026 string_data_length_mismatch
ERROR 源码确认 参考 未实测
- 条件名
string_data_length_mismatch- 宏名称
ERRCODE_STRING_DATA_LENGTH_MISMATCH- 启用版本
- 7.4
- 状态
- 活跃
版本覆盖
速览
位串值与声明长度不匹配。固定 varbit.c 路径报告 bit string length %d does not match type bit(%d);位运算操作数有单独的长度不匹配报文。
报文
固定守卫使用以下首要文本:
| 守卫 | 首要文本 |
|---|---|
bit(n) 长度不匹配 |
bit string length %d does not match type bit(%d) |
bit_and 操作数 |
cannot AND bit strings of different sizes |
bit_or 操作数 |
cannot OR bit strings of different sizes |
bitxor 操作数 |
cannot XOR bit strings of different sizes |
报文模板
源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。
bit string length %d does not match type bit(%d)
cannot AND bit strings of different sizes
cannot OR bit strings of different sizes
cannot XOR bit strings of different sizes
含义
22026 覆盖精确长度的 bit(n) 边界和位运算。固定 bit() 输入路径将实际位长与声明的 bit(n) 长度比较;隐式转换会报告 bit string length %d does not match type bit(%d),显式 bit(n) 转换则会截断或补零。varbit(n) 使用不同约束:隐式值过长时使用 22001,显式转换会截断到最大长度。AND、OR 和 XOR 函数另行比较两个操作数的长度,长度不同时使用 22026。
诊断
先判断首要报文指出的是 bit(n) typmod 还是位运算符。对于 typmod 报文,比较源位长和目标精确长度,并确认边界是隐式赋值/转换还是明确要求的显式转换。varbit(n) 过长应寻找 22001;位运算报文则检查两个操作数。字符宽度和编码失败属于其他 SQLSTATE 路径。
处理
使隐式 bit(n) 值恰好达到声明长度。只有在确实需要截断或补零时才使用显式转换;位运算需要同长时,先调整两个操作数。如果 ERROR 发生在显式事务中,应先 ROLLBACK 或回滚到既有保存点再重试;自动提交可重试修正后的动作。
版本
锁定目录从 7.4 起记录该条件;本页固定源码路径为 PostgreSQL 18.6。未声称本页有自然运行观察。
来源
- 上游源码 src/backend/utils/errcodes.txt 第 199 行
- 上游源码 src/backend/utils/adt/varbit.c 第 354 行
- 上游源码 src/backend/utils/adt/varbit.c 第 385 行
- 上游源码 src/backend/utils/adt/varbit.c 第 1257 行
- 上游源码 src/backend/utils/adt/varbit.c 第 736 行
证据
断言
每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。
-
22026 is string_data_length_mismatch in SQLSTATE Class 22.
-
The fixed varbit source separates exact bit typmod assignment from explicit bit(n) casts, and uses 22026 for unequal bitwise operand lengths; explicit bit(n) casts truncate or zero-pad, while implicit varbit(n) overlength uses 22001.
-
The locked catalogue records 22026 from 7.4 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_sequence22027trim_error2202Earray_subscript_error2202Ginvalid_tablesample_repeat2202Hinvalid_tablesample_argument22030duplicate_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