Skip to content

2200F — zero_length_character_string

Source-backed reference for PostgreSQL SQLSTATE 2200F.

2200F

At a glance

The condition identifies an operation that rejects an empty character string. In the fixed fuzzystrmatch path, metaphone returns empty text immediately for empty input; only after that early return does it read reqlen, and a non-positive requested output length raises output cannot be empty string. A separate core array_to_tsvector path rejects an empty lexeme, so the message and function matter.

Field Value
SQLSTATE 2200F
Condition zero_length_character_string
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_ZERO_LENGTH_CHARACTER_STRING
Aliases

Meaning

This condition is reserved for an operation whose contract does not permit an empty character string. The fixed paths have different guards: metaphone(text, reqlen) first returns empty text when its input text is empty; after that early return, a non-positive reqlen on non-empty input raises 2200F. array_to_tsvector(text[]) independently rejects an element whose length is zero. Neither path proves that every empty SQL string is a 2200F error.

Messages

The metaphone guard raises ERROR with primary output cannot be empty string. The array_to_tsvector lexeme guard raises ERROR with primary lexeme array may not contain empty strings. These paths have no separate DETAIL or HINT in the cited branches.

Diagnosis

If the message names metaphone, inspect the supplied text and requested output length: empty input returns an empty result before reqlen is checked, while a non-positive length on non-empty input triggers 2200F. If the message names array_to_tsvector, inspect every lexeme for an empty string and distinguish NULL lexemes, which use 22004. For a different message, identify the named subsystem first; do not pad arbitrary output merely to silence the condition.

Response

Handle the named function’s input requirement explicitly: choose a positive metaphone output length for non-empty input, or remove/repair empty lexemes before array_to_tsvector. Preserve intended empty input semantics where the function permits them; do not pad data merely to suppress the code.

When this branch raises ERROR, an explicit transaction must first be recovered with ROLLBACK or ROLLBACK TO SAVEPOINT for a savepoint established before the statement; in autocommit, retry only the corrected action after the failed statement completes. See the transaction and retry guide for this boundary rule.

Versions

The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6.

22001, 22000

Sources

Fixed metaphone source: fuzzystrmatch.c#L253-287; the separate core lexeme guard is tsvector_op.c#L741-777. The structured evidence record retains both messages and scope boundaries. No natural runtime was run; SQLSTATE selection and message text remain the deciding evidence.