选择 打开 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

百科 / 错误代码 / Class 22 数据异常

2200F zero_length_character_string

ERROR 源码确认 参考 未实测

类别
Class 22 数据异常
严重等级
ERROR
条件名
zero_length_character_string
宏名称
ERRCODE_ZERO_LENGTH_CHARACTER_STRING
启用版本
7.4
状态
活跃

版本覆盖

速览

该条件表示某项操作拒绝空字符字符串。在固定的 fuzzystrmatch 路径中,metaphone 会先对空输入返回空文本;只有经过这个提前返回后才读取 reqlen,非正的请求输出长度才会报告 output cannot be empty string。另一个核心 array_to_tsvector 路径会拒绝空 lexeme,因此必须结合报文和函数判断。

含义

本条件用于某项操作的输入要求不允许空字符字符串的情况。固定路径有不同 guard:metaphone(text, reqlen) 先在输入为空时返回空文本;对非空输入才检查 reqlenreqlen <= 0 时触发 2200F。array_to_tsvector(text[]) 则独立拒绝长度为零的元素。两条路径都不能证明每个空 SQL 字符串都会产生 2200F。

报文

metaphone guard 以 ERROR 严重性报告 primary:output cannot be empty stringarray_to_tsvector lexeme guard 以 ERROR 报告 primary:lexeme array may not contain empty strings。引用分支没有独立 DETAIL 或 HINT。

报文模板

源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。

主消息 output cannot be empty string

来源:contrib/fuzzystrmatch/fuzzystrmatch.c @ REL_18_6

主消息 lexeme array may not contain empty strings

来源:src/backend/utils/adt/tsvector_op.c @ REL_18_6

诊断

如果报文指向 metaphone,检查传入文本和请求输出长度:空输入在检查 reqlen 前返回空结果,只有非空输入的非正长度才会触发 2200F。如果报文指向 array_to_tsvector,检查每个 lexeme 是否为空,并区分使用 22004 的 NULL lexeme。若报文不同,先定位其中点名的子系统;不要为了消除条件而随意填充输出。

处理

明确处理报文所指函数的输入要求:为非空 metaphone 输入选择正的输出长度,或在 array_to_tsvector 前移除/修正空 lexeme。函数允许时保留有意的空输入语义;不要只为压制代码而填充数据。

该分支抛出 ERROR 时,显式事务应先用 ROLLBACK 恢复,或对语句前已建立的保存点执行 ROLLBACK TO SAVEPOINT,再重试;自动提交下只在失败语句结束后重试修正后的动作。事务边界规则见事务与重试指南。

版本

锁定目录从 7.4 起记录该条件;固定源码覆盖 PostgreSQL 18.6。

来源

证据

断言

每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。

  • 2200F is zero_length_character_string in SQLSTATE Class 22.

    核实方式Read fixed definition.

    来源src/backend/utils/errcodes.txt

  • The contrib fuzzystrmatch metaphone function returns an empty text result at its empty-input early return; after that return, a non-empty input with non-positive requested output length raises 2200F with primary output cannot be empty string.

    核实方式Read the complete metaphone length guards.

    不覆盖The empty-input early return precedes the reqlen guard; this path does not make every empty SQL string a 2200F error.

    来源contrib/fuzzystrmatch/fuzzystrmatch.c

  • array_to_tsvector rejects an empty lexeme with 2200F and primary lexeme array may not contain empty strings.

    核实方式Read the lexeme validation loop.

    不覆盖The tsvector path is distinct from metaphone and needs its own input repair.

    来源src/backend/utils/adt/tsvector_op.c

  • The locked catalogue records 2200F from 7.4 without proving an exact implementation introduction date.

    核实方式Use catalogue boundary.

    来源src/backend/utils/errcodes.txt

同类错误代码

Class 22 数据异常 下的其他成员。