{
  "schema": 1,
  "sqlstate": "42P21",
  "condition_name": "collation_mismatch",
  "sources": [
    {
      "id": "src.errcodes.42P21.18.6",
      "kind": "upstream_source",
      "source_role": "condition_definition",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "src/backend/utils/errcodes.txt",
      "location": "line 352",
      "sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L352"
    },
    {
      "id": "src.call.42P21.69245d264e1d0e386e33036f",
      "kind": "upstream_source",
      "source_role": "source_call",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "src/backend/parser/parse_collate.c",
      "location": "lines 226-232",
      "sha256": "e92a01d1a7279f108ddfac1f0324f6d142b1496360ddac3dfb778564c4226940",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/parser/parse_collate.c#L226-L232"
    },
    {
      "id": "src.call.42P21.0ba27778e76c3d44b1cc79f6",
      "kind": "upstream_source",
      "source_role": "source_call",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "src/backend/parser/parse_collate.c",
      "location": "lines 853-858",
      "sha256": "e92a01d1a7279f108ddfac1f0324f6d142b1496360ddac3dfb778564c4226940",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/parser/parse_collate.c#L853-L858"
    },
    {
      "id": "src.call.42P21.93a028fdb350e0d054f123d8",
      "kind": "upstream_source",
      "source_role": "source_call",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "src/backend/parser/parse_cte.c",
      "location": "lines 394-401",
      "sha256": "908eef14ac26654fe0b9c176ef50e56ba710b7fcd8e1239b944d7c2152fc2d6b",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/parser/parse_cte.c#L394-L401"
    },
    {
      "id": "src.call.42P21.16107e45585553ed56b18241",
      "kind": "upstream_source",
      "source_role": "source_call",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "src/backend/commands/tablecmds.c",
      "location": "lines 3297-3303",
      "sha256": "422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablecmds.c#L3297-L3303"
    },
    {
      "id": "src.call.42P21.5fcad21fbefb1ae15acf4c73",
      "kind": "upstream_source",
      "source_role": "source_call",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "src/backend/commands/tablecmds.c",
      "location": "lines 3463-3469",
      "sha256": "422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablecmds.c#L3463-L3469"
    },
    {
      "id": "src.call.42P21.ef5edd918af762963c8e072c",
      "kind": "upstream_source",
      "source_role": "source_call",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "src/backend/commands/tablecmds.c",
      "location": "lines 7292-7298",
      "sha256": "422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablecmds.c#L7292-L7298"
    },
    {
      "id": "src.call.42P21.04a0360be247ab8ca050e826",
      "kind": "upstream_source",
      "source_role": "source_call",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "src/backend/commands/tablecmds.c",
      "location": "lines 10474-10483",
      "sha256": "422dc8e833df4940755973c757e338295822ba3e4c7266c40669f49f96eb15a9",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablecmds.c#L10474-L10483"
    },
    {
      "id": "src.context.42P21.parse_collate.common",
      "kind": "upstream_source",
      "source_role": "source_context",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "src/backend/parser/parse_collate.c",
      "location": "lines 208-234 and 804-835",
      "sha256": "e92a01d1a7279f108ddfac1f0324f6d142b1496360ddac3dfb778564c4226940",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/parser/parse_collate.c#L208"
    },
    {
      "id": "src.calls.REL_18_6.42P21",
      "kind": "local_artifact",
      "source_role": "source_call_scan",
      "sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf"
    }
  ],
  "claims": [
    {
      "id": "identity.class-and-condition",
      "statement": "42P21 is the collation_mismatch condition in Class 42.",
      "method": "Read fixed REL_18_6 errcodes.txt and locked facts.",
      "limits": "Identity does not enumerate all source branches or client failures.",
      "sources": [
        "src.errcodes.42P21.18.6"
      ]
    },
    {
      "id": "mechanism.selected-source-path",
      "statement": "Selected fixed 18.6 paths reject explicit collation conflicts immediately, emit implicit conflicts only when a caller requires one common collation, and check recursive output, inherited or child columns, and foreign-key collation compatibility.",
      "method": "Read complete parse_collate.c derivation context and the selected resolved report groups in parse_cte.c and tablecmds.c.",
      "limits": "Representative confirmed core paths only; not exhaustive historical or extension coverage.",
      "sources": [
        "src.call.42P21.69245d264e1d0e386e33036f",
        "src.call.42P21.0ba27778e76c3d44b1cc79f6",
        "src.call.42P21.93a028fdb350e0d054f123d8",
        "src.call.42P21.16107e45585553ed56b18241",
        "src.call.42P21.5fcad21fbefb1ae15acf4c73",
        "src.call.42P21.ef5edd918af762963c8e072c",
        "src.call.42P21.04a0360be247ab8ca050e826",
        "src.context.42P21.parse_collate.common"
      ]
    },
    {
      "id": "boundary.implicit-none-ok",
      "statement": "select_common_collation(..., none_ok=true) may return InvalidOid while retaining an implicit COLLATE_CONFLICT; a later caller that requires a collation can then report a separate indeterminate-collation condition.",
      "method": "Read select_common_collation and the COLLATE_CONFLICT/COLLATE_EXPLICIT branches in fixed parse_collate.c.",
      "limits": "This is source control-flow evidence, not a natural runtime observation.",
      "sources": [
        "src.context.42P21.parse_collate.common"
      ]
    },
    {
      "id": "versions.catalogue-boundary",
      "statement": "Locked catalogue snapshots show this condition by PostgreSQL 9.1.0; source behavior here is fixed at PostgreSQL 18.6.",
      "method": "Read locked catalogue facts and definition snapshot.",
      "limits": "First observed release is a lower bound, not precise behavioral introduction.",
      "sources": [
        "src.errcodes.42P21.18.6"
      ]
    }
  ],
  "messages": [
    {
      "id": "message.variant-1",
      "sqlstate": "42P21",
      "severity_source": "ERROR",
      "primary_template": "collation mismatch between implicit collations \"%s\" and \"%s\"",
      "detail_templates": [],
      "hint_templates": [
        "You can choose the collation by applying the COLLATE clause to one or both expressions."
      ],
      "roles": [
        {
          "role": "errmsg",
          "template": "collation mismatch between implicit collations \"%s\" and \"%s\""
        },
        {
          "role": "errhint",
          "template": "You can choose the collation by applying the COLLATE clause to one or both expressions."
        }
      ],
      "sources": [
        "src.call.42P21.69245d264e1d0e386e33036f"
      ],
      "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed."
    },
    {
      "id": "message.variant-2",
      "sqlstate": "42P21",
      "severity_source": "ERROR",
      "primary_template": "collation mismatch between explicit collations \"%s\" and \"%s\"",
      "detail_templates": [],
      "hint_templates": [],
      "roles": [
        {
          "role": "errmsg",
          "template": "collation mismatch between explicit collations \"%s\" and \"%s\""
        }
      ],
      "sources": [
        "src.call.42P21.0ba27778e76c3d44b1cc79f6"
      ],
      "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed."
    },
    {
      "id": "message.variant-3",
      "sqlstate": "42P21",
      "severity_source": "ERROR",
      "primary_template": "recursive query \"%s\" column %d has collation \"%s\" in non-recursive term but collation \"%s\" overall",
      "detail_templates": [],
      "hint_templates": [
        "Use the COLLATE clause to set the collation of the non-recursive term."
      ],
      "roles": [
        {
          "role": "errmsg",
          "template": "recursive query \"%s\" column %d has collation \"%s\" in non-recursive term but collation \"%s\" overall"
        },
        {
          "role": "errhint",
          "template": "Use the COLLATE clause to set the collation of the non-recursive term."
        }
      ],
      "sources": [
        "src.call.42P21.93a028fdb350e0d054f123d8"
      ],
      "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed."
    },
    {
      "id": "message.variant-4",
      "sqlstate": "42P21",
      "severity_source": "ERROR",
      "primary_template": "column \"%s\" has a collation conflict",
      "detail_templates": [
        "\"%s\" versus \"%s\""
      ],
      "hint_templates": [],
      "roles": [
        {
          "role": "errmsg",
          "template": "column \"%s\" has a collation conflict"
        },
        {
          "role": "errdetail",
          "template": "\"%s\" versus \"%s\""
        }
      ],
      "sources": [
        "src.call.42P21.16107e45585553ed56b18241"
      ],
      "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed."
    },
    {
      "id": "message.variant-5",
      "sqlstate": "42P21",
      "severity_source": "ERROR",
      "primary_template": "inherited column \"%s\" has a collation conflict",
      "detail_templates": [
        "\"%s\" versus \"%s\""
      ],
      "hint_templates": [],
      "roles": [
        {
          "role": "errmsg",
          "template": "inherited column \"%s\" has a collation conflict"
        },
        {
          "role": "errdetail",
          "template": "\"%s\" versus \"%s\""
        }
      ],
      "sources": [
        "src.call.42P21.5fcad21fbefb1ae15acf4c73"
      ],
      "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed."
    },
    {
      "id": "message.variant-6",
      "sqlstate": "42P21",
      "severity_source": "ERROR",
      "primary_template": "child table \"%s\" has different collation for column \"%s\"",
      "detail_templates": [
        "\"%s\" versus \"%s\""
      ],
      "hint_templates": [],
      "roles": [
        {
          "role": "errmsg",
          "template": "child table \"%s\" has different collation for column \"%s\""
        },
        {
          "role": "errdetail",
          "template": "\"%s\" versus \"%s\""
        }
      ],
      "sources": [
        "src.call.42P21.ef5edd918af762963c8e072c"
      ],
      "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed."
    },
    {
      "id": "message.variant-7",
      "sqlstate": "42P21",
      "severity_source": "ERROR",
      "primary_template": "foreign key constraint \"%s\" cannot be implemented",
      "detail_templates": [
        "Key columns \"%s\" of the referencing table and \"%s\" of the referenced table have incompatible collations: \"%s\" and \"%s\".  If either collation is nondeterministic, then both collations have to be the same."
      ],
      "hint_templates": [],
      "roles": [
        {
          "role": "errmsg",
          "template": "foreign key constraint \"%s\" cannot be implemented"
        },
        {
          "role": "errdetail",
          "template": "Key columns \"%s\" of the referencing table and \"%s\" of the referenced table have incompatible collations: \"%s\" and \"%s\".  If either collation is nondeterministic, then both collations have to be the same."
        }
      ],
      "sources": [
        "src.call.42P21.04a0360be247ab8ca050e826"
      ],
      "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed."
    }
  ],
  "usage_evidence": [
    {
      "scope": "SQLSTATE definition and release identity",
      "status": "definition_only",
      "evidence_ids": [
        "identity.class-and-condition",
        "src.errcodes.42P21.18.6"
      ]
    },
    {
      "scope": "Selected PostgreSQL 18.6 source emitters and message roles",
      "status": "source_path_confirmed",
      "evidence_ids": [
        "mechanism.selected-source-path"
      ]
    },
    {
      "scope": "Natural runtime execution for this batch",
      "status": "unknown",
      "evidence_ids": []
    }
  ],
  "runtime": []
}
