↑↓ select↵ open⌫ change scopeOpen full search

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

Wiki / SQLSTATE

22P05 — untranslatable_character

PostgreSQL could identify a source character but could not represent it in the destination encoding. The fixed helper reports the offending bytes and both encoding names with primary character with byte sequence %s in encoding "%s" has no equivalent in encoding "%s" at ERROR severity.

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
untranslatable_character
lang
en
sqlstate
22P05

Definition PG 18

22P05

At a glance {#at-a-glance}

PostgreSQL could identify a source character but could not represent it in the destination encoding. The fixed helper reports the offending bytes and both encoding names with primary character with byte sequence %s in encoding "%s" has no equivalent in encoding "%s" at ERROR severity.

Meaning {#meaning}

report_untranslatable_char(src_encoding, dest_encoding, ...) determines the source multibyte length, formats the offending bytes as 0x.., and raises 22P05 when the destination conversion table has no equivalent character. This means the source character is valid enough to identify, but the target representation cannot carry it. It is different from malformed source bytes: the fixed conversion loop can call report_invalid_encoding, which uses 22021 instead.

Messages {#messages}

  • ERROR primary: character with byte sequence %s in encoding "%s" has no equivalent in encoding "%s"
  • The fixed call supplies no DETAIL or HINT.

Diagnosis {#diagnosis}

Read the exact byte sequence, source encoding, destination encoding, and conversion direction from the primary. Check client_encoding, server/database encoding, import or COPY file encoding, and the actual conversion boundary. Do not treat the presence of a non-ASCII character as proof of 22P05; malformed source bytes and ordinary type-input failures have different paths.

Response {#response}

Choose a destination encoding that represents the data, or correct the producer and conversion boundary while preserving the character. Do not silently replace or discard it unless loss is an explicit data policy. Because the cited path is ERROR, an explicit transaction needs ROLLBACK or ROLLBACK TO SAVEPOINT before retrying; in autocommit, correct the encoding or input and submit again. This source path does not imply a connection reset or a FATAL session end.

Versions {#versions}

The locked catalogue records this condition from PostgreSQL 7.4. The reporting helper and representative conversion branch cited here are from PostgreSQL 18.6 REL_18_6; no encoding runtime was executed.

Related {#related}

22021, 22P02

Sources {#sources}

src/backend/utils/mb/mbutils.c#L1862-L1902

src/backend/utils/mb/conv.c#L674-L684

The structured evidence record records the exact primary and the valid-character versus malformed-byte boundary.

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": "22P05 is untranslatable_character in SQLSTATE Class 22."
}
claims · conversion-path
{
  "claim_id": "conversion-path",
  "limits": "",
  "method": "Read the complete reporting function.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.report"
  ],
  "statement": "report_untranslatable_char computes source multibyte character bytes and reports source and destination encoding names when conversion has no equivalent destination character."
}
claims · invalid-source-boundary
{
  "claim_id": "invalid-source-boundary",
  "limits": "The cited loop is representative; other conversion procedures call the same reporting helper.",
  "method": "Read the conversion failure and invalid-input branches.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.path.convert",
    "src.path.report"
  ],
  "statement": "The conversion loop calls report_untranslatable_char for a valid source character with no destination mapping, while malformed remaining UTF-8 bytes fall through to report_invalid_encoding and 22021."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue boundary.",
  "position": 3,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 22P05 from 7.4; that boundary does not prove exact implementation introduction."
}
messages · message.convert
{
  "limits": "",
  "message_id": "message.convert",
  "path": "",
  "position": 0,
  "raw": {
    "id": "message.convert",
    "primary_template": "character with byte sequence %s in encoding \"%s\" has no equivalent in encoding \"%s\"",
    "severity_source": "ERROR",
    "sources": [
      "src.path.report"
    ],
    "sqlstate": "22P05"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.report"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "character with byte sequence in encoding \" \" has no equivalent in encoding \" \"",
      "position": 0,
      "role": "",
      "template": "character with byte sequence %s in encoding \"%s\" has no equivalent in encoding \"%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#L209"
}
sources · src.path.report
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/mb/mbutils.c",
  "position": 1,
  "sha256": "2c034d792a3fbc402d673d6e08bd6a2198651bfd3c057176d4098f7e4a215dfb",
  "source_id": "src.path.report",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/mb/mbutils.c#L1862"
}
sources · src.path.convert
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/mb/conv.c",
  "position": 2,
  "sha256": "75d962d1178bbe5dd7781b6b65b1c1135a391ece21042b249876560103933e27",
  "source_id": "src.path.convert",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/mb/conv.c#L674"
}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · english-manuals:5fd4a112f74a8a25ae4b5ca37dd47bb09572036e2ef2afed347e9098330f937c

Text language: en · english-manuals:5fd4a112f74a8a25ae4b5ca37dd47bb09572036e2ef2afed347e9098330f937c