↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / SQLSTATE

2200F — zero_length_character_string

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 arraytotsvector path rejects an empty lexeme, so the message and function matter.

English manual coverage begins with PostgreSQL 8.1. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

aliases
Unknown
class name
Data Exception
condition name
zero_length_character_string
lang
en
sqlstate
2200F

Definition PG 18

2200F

At a glance {#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.

Meaning {#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 {#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 {#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 {#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 {#versions}

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

Related {#related}

22001, 22000

Sources {#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.

Compare versions

SQLSTATE evidence and recorded runtime versions

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read fixed definition.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "2200F is zero_length_character_string in SQLSTATE Class 22."
}
claims · mechanism.metaphone
{
  "claim_id": "mechanism.metaphone",
  "limits": "The empty-input early return precedes the reqlen guard; this path does not make every empty SQL string a 2200F error.",
  "method": "Read the complete metaphone length guards.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.metaphone"
  ],
  "statement": "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."
}
claims · mechanism.tsvector
{
  "claim_id": "mechanism.tsvector",
  "limits": "The tsvector path is distinct from metaphone and needs its own input repair.",
  "method": "Read the lexeme validation loop.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.path.tsvector-empty"
  ],
  "statement": "array_to_tsvector rejects an empty lexeme with 2200F and primary lexeme array may not contain empty strings."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue boundary.",
  "position": 3,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 2200F from 7.4 without proving an exact implementation introduction date."
}
messages · message.metaphone
{
  "limits": "",
  "message_id": "message.metaphone",
  "path": "",
  "position": 0,
  "raw": {
    "id": "message.metaphone",
    "primary_template": "output cannot be empty string",
    "severity_source": "ERROR",
    "sources": [
      "src.path.metaphone"
    ],
    "sqlstate": "2200F"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.metaphone"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "output cannot be empty string",
      "position": 0,
      "role": "",
      "template": "output cannot be empty string"
    }
  ]
}
messages · message.tsvector
{
  "limits": "",
  "message_id": "message.tsvector",
  "path": "",
  "position": 1,
  "raw": {
    "id": "message.tsvector",
    "primary_template": "lexeme array may not contain empty strings",
    "severity_source": "ERROR",
    "sources": [
      "src.path.tsvector-empty"
    ],
    "sqlstate": "2200F"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.tsvector-empty"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "lexeme array may not contain empty strings",
      "position": 0,
      "role": "",
      "template": "lexeme array may not contain empty strings"
    }
  ]
}
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#L204"
}
sources · src.calls.REL_18_6
{
  "commit": "",
  "docs_url": "",
  "kind": "local_artifact",
  "location": "",
  "path": "raw/calls/REL_18_6.jsonl",
  "position": 1,
  "sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
  "source_id": "src.calls.REL_18_6",
  "tag": "",
  "url": ""
}
sources · src.path.metaphone
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "contrib/fuzzystrmatch/fuzzystrmatch.c",
  "position": 2,
  "sha256": "bd5b12031fa6ca844b8d4e2c2ced490b7233cc9e35c77ef681cb620c7367a591",
  "source_id": "src.path.metaphone",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/fuzzystrmatch/fuzzystrmatch.c#L253-L287"
}
sources · src.path.tsvector-empty
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/adt/tsvector_op.c",
  "position": 3,
  "sha256": "5ea1783f4023be82a092fbfc66a59d2586cd63352c375e2c8d599bc98bccfe8f",
  "source_id": "src.path.tsvector-empty",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/tsvector_op.c#L741-L777"
}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · english-manuals:8043f72e38dd0f102d02ee6a9d3b8b9f17221d088909caed384815793df7dce7

Text language: en · english-manuals:8043f72e38dd0f102d02ee6a9d3b8b9f17221d088909caed384815793df7dce7