Skip to content

42622 — name_too_long

PostgreSQL SQLSTATE 42622: name_too_long, source-backed diagnosis and recovery guidance.

42622

At a glance

SQLSTATE 42622 is name_too_long in Class 42. 42622 is name_too_long. Fixed source paths include a scanner NOTICE for an overlong SQL identifier and a binary name receive ERROR; ordinary text input can truncate without either diagnostic.

Field Value
SQLSTATE 42622
Condition name_too_long
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_NAME_TOO_LONG
Aliases

Meaning

42622 is name_too_long with more than one producer. The binary name receive function namerecv reads external text with pq_getmsgtext, compares the byte count with NAMEDATALEN, and raises ERROR identifier too long with a length DETAIL before copying the value. The parser’s truncate_identifier path handles an overlong SQL identifier differently: it clips to a multibyte boundary, then, when called with warn = true by the scanner, emits a NOTICE with SQLSTATE 42622 saying that the identifier will be truncated. Ordinary text input uses the separate namein path and can clip without that scanner NOTICE; it does not enter namerecv.

Diagnosis

First classify the boundary and severity. A binary type receive failure has the identifier too long primary and length DETAIL; a SQL identifier can produce a NOTICE with the original and truncated names; a text cast to name can silently truncate. Record the format code and type OID for binary input, or the exact SQL identifier and server NOTICE for scanner input. This batch deliberately has no selected natural runtime: a text cast to name truncates on the selected targets and would be false evidence for either source branch. The fixed guards do not make every long value or identifier an instance of the same observed path.

Response

Validate the relevant input boundary and keep long application values in text or another suitable type. If a binary client really sends an oversized name value, fix the encoder or application schema at that boundary; if the parser NOTICE is the problem, shorten or rename the SQL identifier and inspect the resulting catalog name. Do not manufacture this SQLSTATE with RAISE, turn silent text truncation into evidence, or relabel one severity/path as the other.

Messages

The fixed scanner branch emits an explicit NOTICE with SQLSTATE 42622. On REL_18_6 its raw primary template is identifier "%s" will be truncated to "%.*s"; on REL_10_23 it is identifier "%s" will be truncated to "%s". The fixed namerecv branch emits an explicit ERROR with primary identifier too long and DETAIL Identifier must be less than %d characters.; %d is NAMEDATALEN in that source path. Both are source-confirmed only here, and the text-input path can be silent. A client exception or notice without the server SQLSTATE and the relevant scanner/binary context is not sufficient to identify a 42622 path.

Representative case

This page has no selected natural SQL run. The fixed source boundary is recorded without a synthetic trigger.

Versions

No natural SQL run is selected here. The fixed REL_18_6/REL_10_23 source boundary does not establish behavior for every intermediate release.

Sources

  • src.errcodes.18.6 — fixed errcodes.txt definition at commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.name-recv-too-long.18.6src/backend/utils/adt/name.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 4c4b4dc71f55ba73dbc24dd94b3385986fdb3179702b3d100cbad7ab00db7762 (source).
  • src.name-recv-too-long.10.23src/backend/utils/adt/name.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 7c7da791e528aafdbf26930cd4bd34386806818c19d2ee4b78bbe138b93f4a84 (source).
  • src.identifier-truncate.18.6 / src.identifier-truncate.10.23 — fixed parser truncate_identifier NOTICE branches; blob SHA-256 99cc6839927c19a9f85a1e5fbc8e848b376a7073477a04a0bbfe106ecdb2273f / 3c59a33f3cb5eaa0c3932859eb15e927f459a5feb5f40ca96fef5ef74495d67c (18.6 source, 10.23 source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.