select open change scope Open full search

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

SQLSTATE / CLASS 42 · SYNTAX ERROR OR ACCESS RULE VIOLATION

name_too_long

SQLSTATE
42622
Condition name
name_too_long
Class
Syntax Error or Access Rule Violation
Source macro
ERRCODE_NAME_TOO_LONG
Evidence
Source path confirmed
Analysis & operational context

English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗

<h1>42622</h1>

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.

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.

Source evidence

Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.

42622 is the name_too_long condition in Class 42.

Method: Read fixed errcodes.txt and the locked catalogue metadata.

Limits: Directory identity does not identify every backend path.

src.errcodes.18.6

The fixed source calls for 42622 include the mechanism and message boundary selected for this page.

Method: Trace the resolved REL_18_6 and REL_10_23 source call records at the locked commits.

Limits: Other calls can use the same SQLSTATE with different context or dynamic fields.

src.name-recv-too-long.18.6 src.name-recv-too-long.10.23 src.identifier-truncate.18.6 src.identifier-truncate.10.23

The parser truncates an overlong SQL identifier and can emit a 42622 NOTICE when the scanner requests warning, while binary namerecv emits the separate 42622 ERROR path.

Method: Read truncate_identifier and its scanner call guard in fixed scansup.c/scan.l call context.

Limits: No natural runtime is selected for either branch in this batch; ordinary namein text input may be silent.

src.identifier-truncate.18.6 src.identifier-truncate.10.23 src.name-recv-too-long.18.6 src.name-recv-too-long.10.23

The locked catalogue records 42622; runtime scope is limited to the selected targets.

Method: Read generated facts and selected summaries.

Limits: Definition presence is not an exact behavioral introduction.

src.errcodes.18.6 src.calls.REL_18_6 src.calls.REL_10_23

Message templates

explicit ERROR · message.name-recv

Primary

identifier too long

Detail

Identifier must be less than %d characters.

Only the binary name receive path is source-confirmed here.

explicit NOTICE · message.identifier-truncate-notice

Primary

identifier "%s" will be truncated to "%.*s"

Primary

identifier "%s" will be truncated to "%s"

Scanner identifier path only; 18.6 and 10.23 use different formatting for the clipped second value.

Reproduction & repair cases

identifier_too_long_boundary · PG 10, 18

Preconditions

  • The fixed REL_18_6 and REL_10_23 source paths are available.

Trigger: No ordinary SQL cast is claimed: fixed source shows 42622 in binary name receive, while text casts truncate identifiers before that path.

Expected assertions

    Repair: Use a protocol path that validates the name value before retrying, or keep long user text outside the name type.

    Cleanup: No persistent objects; close the runner connection.

    Recorded runtime evidence

    No runtime observation is attached to this entry.

    Definition snapshot: english-manuals:239bc095a2f44c7c4aec6527013… · English manual source