↑↓ select↵ open⌫ change scopeOpen full search

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

Wiki / SQLSTATE

42622 — name_too_long

SQLSTATE 42622 is name_too_long in Class 42. 42622 is nametoolong. 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.

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
Syntax Error or Access Rule Violation
condition name
name_too_long
lang
en
sqlstate
42622

Definition PG 18

42622

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

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

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

Related {#related}

Sources {#sources}

  • src.errcodes.18.6 — fixed errcodes.txt definition at commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.name-recv-too-long.18.6 — src/backend/utils/adt/name.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 4c4b4dc71f55ba73dbc24dd94b3385986fdb3179702b3d100cbad7ab00db7762 (source).
  • src.name-recv-too-long.10.23 — src/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.

Compare versions

SQLSTATE evidence and recorded runtime versions

cases · identifier_too_long_boundary
{
  "assertions": [],
  "case_id": "identifier_too_long_boundary",
  "cleanup": "No persistent objects; close the runner connection.",
  "has_snippet": false,
  "position": 0,
  "preconditions": [
    "The fixed REL_18_6 and REL_10_23 source paths are available."
  ],
  "repair": "Use a protocol path that validates the name value before retrying, or keep long user text outside the name type.",
  "trigger": "No ordinary SQL cast is claimed: fixed source shows 42622 in binary name receive, while text casts truncate identifiers before that path.",
  "versions": [
    "10",
    "18"
  ]
}
claims · identity.class-and-condition
{
  "claim_id": "identity.class-and-condition",
  "limits": "Directory identity does not identify every backend path.",
  "method": "Read fixed errcodes.txt and the locked catalogue metadata.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "42622 is the name_too_long condition in Class 42."
}
claims · mechanism.backend-path
{
  "claim_id": "mechanism.backend-path",
  "limits": "Other calls can use the same SQLSTATE with different context or dynamic fields.",
  "method": "Trace the resolved REL_18_6 and REL_10_23 source call records at the locked commits.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.name-recv-too-long.18.6",
    "src.name-recv-too-long.10.23",
    "src.identifier-truncate.18.6",
    "src.identifier-truncate.10.23"
  ],
  "statement": "The fixed source calls for 42622 include the mechanism and message boundary selected for this page."
}
claims · mechanism.identifier-truncation-notice
{
  "claim_id": "mechanism.identifier-truncation-notice",
  "limits": "No natural runtime is selected for either branch in this batch; ordinary namein text input may be silent.",
  "method": "Read truncate_identifier and its scanner call guard in fixed scansup.c/scan.l call context.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.identifier-truncate.18.6",
    "src.identifier-truncate.10.23",
    "src.name-recv-too-long.18.6",
    "src.name-recv-too-long.10.23"
  ],
  "statement": "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."
}
claims · versions.catalogue-boundary
{
  "claim_id": "versions.catalogue-boundary",
  "limits": "Definition presence is not an exact behavioral introduction.",
  "method": "Read generated facts and selected summaries.",
  "position": 3,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6",
    "src.calls.REL_18_6",
    "src.calls.REL_10_23"
  ],
  "statement": "The locked catalogue records 42622; runtime scope is limited to the selected targets."
}
messages · message.name-recv
{
  "limits": "Only the binary name receive path is source-confirmed here.",
  "message_id": "message.name-recv",
  "path": "",
  "position": 0,
  "raw": {
    "detail_template": "Identifier must be less than %d characters.",
    "id": "message.name-recv",
    "limits": "Only the binary name receive path is source-confirmed here.",
    "primary_template": "identifier too long",
    "severity_source": "explicit ERROR",
    "sources": [
      "src.name-recv-too-long.18.6",
      "src.name-recv-too-long.10.23"
    ],
    "sqlstate": "42622"
  },
  "severity": "explicit ERROR",
  "sources": [
    "src.name-recv-too-long.18.6",
    "src.name-recv-too-long.10.23"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "identifier too long",
      "position": 0,
      "role": "",
      "template": "identifier too long"
    },
    {
      "kind": "detail",
      "literal": "Identifier must be less than characters.",
      "position": 1,
      "role": "",
      "template": "Identifier must be less than %d characters."
    }
  ]
}
messages · message.identifier-truncate-notice
{
  "limits": "Scanner identifier path only; 18.6 and 10.23 use different formatting for the clipped second value.",
  "message_id": "message.identifier-truncate-notice",
  "path": "",
  "position": 1,
  "raw": {
    "id": "message.identifier-truncate-notice",
    "limits": "Scanner identifier path only; 18.6 and 10.23 use different formatting for the clipped second value.",
    "primary_variants": [
      {
        "source": "src.identifier-truncate.18.6",
        "target": "REL_18_6",
        "template": "identifier \"%s\" will be truncated to \"%.*s\""
      },
      {
        "source": "src.identifier-truncate.10.23",
        "target": "REL_10_23",
        "template": "identifier \"%s\" will be truncated to \"%s\""
      }
    ],
    "severity_source": "explicit NOTICE",
    "sources": [
      "src.identifier-truncate.18.6",
      "src.identifier-truncate.10.23"
    ],
    "sqlstate": "42622"
  },
  "severity": "explicit NOTICE",
  "sources": [
    "src.identifier-truncate.18.6",
    "src.identifier-truncate.10.23"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "identifier \" \" will be truncated to \"%.*s\"",
      "position": 0,
      "role": "REL_18_6",
      "template": "identifier \"%s\" will be truncated to \"%.*s\""
    },
    {
      "kind": "primary",
      "literal": "identifier \" \" will be truncated to \" \"",
      "position": 1,
      "role": "REL_10_23",
      "template": "identifier \"%s\" will be truncated to \"%s\""
    }
  ]
}
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"
}
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.calls.REL_10_23
{
  "commit": "",
  "docs_url": "",
  "kind": "local_artifact",
  "location": "",
  "path": "raw/calls/REL_10_23.jsonl",
  "position": 2,
  "sha256": "00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c",
  "source_id": "src.calls.REL_10_23",
  "tag": "",
  "url": ""
}
sources · src.name-recv-too-long.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/adt/name.c",
  "position": 3,
  "sha256": "4c4b4dc71f55ba73dbc24dd94b3385986fdb3179702b3d100cbad7ab00db7762",
  "source_id": "src.name-recv-too-long.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/name.c#L91-L95"
}
sources · src.name-recv-too-long.10.23
{
  "commit": "02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/adt/name.c",
  "position": 4,
  "sha256": "7c7da791e528aafdbf26930cd4bd34386806818c19d2ee4b78bbe138b93f4a84",
  "source_id": "src.name-recv-too-long.10.23",
  "tag": "REL_10_23",
  "url": "https://github.com/postgres/postgres/blob/02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4/src/backend/utils/adt/name.c#L89-L93"
}
sources · src.identifier-truncate.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/parser/scansup.c",
  "position": 5,
  "sha256": "99cc6839927c19a9f85a1e5fbc8e848b376a7073477a04a0bbfe106ecdb2273f",
  "source_id": "src.identifier-truncate.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/parser/scansup.c#L91-L102"
}
sources · src.identifier-truncate.10.23
{
  "commit": "02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/parser/scansup.c",
  "position": 6,
  "sha256": "3c59a33f3cb5eaa0c3932859eb15e927f459a5feb5f40ca96fef5ef74495d67c",
  "source_id": "src.identifier-truncate.10.23",
  "tag": "REL_10_23",
  "url": "https://github.com/postgres/postgres/blob/02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4/src/backend/parser/scansup.c#L187-L208"
}
sources · manifest.42622
{
  "commit": "",
  "docs_url": "",
  "kind": "local_artifact",
  "location": "",
  "path": "verify/cases/42622/cases.json",
  "position": 7,
  "sha256": "798c2ea09dacbb975c6ba84458e71f2f20fe4aeb7d790193f16425bce09d6abf",
  "source_id": "manifest.42622",
  "tag": "",
  "url": ""
}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · english-manuals:661ff6a1944ccdf36f48095a18eaa138aa2c9f70efe6a74c191b9e1b105a60c1

Text language: en · english-manuals:661ff6a1944ccdf36f48095a18eaa138aa2c9f70efe6a74c191b9e1b105a60c1