{
  "schema": 1,
  "sqlstate": "23001",
  "condition_name": "restrict_violation",
  "sources": [
    {
      "id": "src.errcodes.18.6",
      "kind": "upstream_source",
      "source_role": "condition_definition",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "src/backend/utils/errcodes.txt",
      "sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt"
    },
    {
      "id": "src.calls.REL_18_6",
      "kind": "local_artifact",
      "source_role": "source_call_scan",
      "sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf"
    },
    {
      "id": "src.ri_triggers.18.6",
      "kind": "upstream_source",
      "source_role": "source_path",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "src/backend/utils/adt/ri_triggers.c",
      "sha256": "a3fed49fbda88fe0fe5bcf35eb019fced28596ae4046233f2acb2eb9f90ab1da",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/ri_triggers.c#L2785-L2797"
    },
    {
      "id": "doc.ddl-constraints.18.6",
      "kind": "upstream_source",
      "source_role": "official_documentation",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "doc/src/sgml/ddl.sgml",
      "sha256": "ce1919d9236f2e71672660e1a347146472e966e4d19b77fde5ae345dd1db6ec7",
      "docs_url": "https://www.postgresql.org/docs/18/ddl-constraints.html#DDL-CONSTRAINTS-FK",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ddl.sgml"
    }
  ],
  "claims": [
    {
      "id": "identity",
      "statement": "23001 is restrict_violation, a specific Class 23 condition.",
      "sources": [
        "src.errcodes.18.6"
      ],
      "method": "Read the condition definition and macro.",
      "limits": "The code is narrower than the general foreign-key violation code 23503."
    },
    {
      "id": "restrict-path",
      "statement": "The RI trigger reports 23001 when an immediate ON DELETE or ON UPDATE RESTRICT action finds a referencing row.",
      "sources": [
        "src.ri_triggers.18.6",
        "src.calls.REL_18_6",
        "doc.ddl-constraints.18.6"
      ],
      "method": "Trace the fixed ri_ReportViolation call and compare the documented action timing.",
      "limits": "The exact DETAIL depends on privileges and key values; do not treat one rendered DETAIL as a static format string."
    },
    {
      "id": "no-action-boundary",
      "statement": "RESTRICT is checked immediately and is not deferrable; NO ACTION can be deferred when the constraint is declared DEFERRABLE, and PostgreSQL 10 uses the general 23503 path for the tested RESTRICT delete.",
      "sources": [
        "src.ri_triggers.18.6",
        "doc.ddl-constraints.18.6",
        "runtime.23001-batch1-pg10b-20260909.pg10"
      ],
      "method": "Read action semantics and the two selected runs.",
      "limits": "The PG10 result is a version/path boundary, not evidence that the user operation succeeded."
    },
    {
      "id": "runtime",
      "statement": "The selected PG18 run returned 23001, entered INERROR, recovered after ROLLBACK, and committed deletion after removing the dependent row; PG10 returned 23503 for the same mechanism.",
      "sources": [
        "runtime.23001-batch1-latest2-20260909.latest",
        "runtime.23001-batch1-pg10b-20260909.pg10"
      ],
      "method": "Compare summaries and raw diagnostics with the shared registry.",
      "limits": "Only the PG18 result is an observed runtime for code 23001; the PG10 case is explicitly not_applicable for that code."
    },
    {
      "id": "runtime.pg17-boundary",
      "statement": "On the fixed PG17.11 boundary case, the same referenced-parent ON DELETE RESTRICT operation returned the general foreign_key_violation 23503 rather than dedicated 23001; the failed transaction moved from INERROR to IDLE after ROLLBACK and cleanup assertions passed.",
      "sources": [
        "restrict-path",
        "runtime.23001-boundary-pg17-final-20260909.pg17"
      ],
      "method": "Read the PG17 boundary summary for the exact primary/detail, SQLSTATE, transaction statuses, and final counts.",
      "limits": "This is one PG17.11 comparison point and is not a universal claim for every PostgreSQL 11–17 minor release. It is not an observed 23001 runtime."
    }
  ],
  "messages": [
    {
      "id": "restrict",
      "sqlstate": "23001",
      "primary_template": "update or delete on table \"%s\" violates RESTRICT setting of foreign key constraint \"%s\" on table \"%s\"",
      "severity_source": "ERROR",
      "sources": [
        "src.ri_triggers.18.6"
      ],
      "limits": "The privilege-aware branch can instead emit the source detail template without key values.",
      "detail_template": "Key (%s)=(%s) is referenced from table \"%s\"."
    }
  ],
  "usage_evidence": [
    {
      "scope": "pg18-restrict-runtime",
      "status": "observed_runtime",
      "evidence_ids": [
        "runtime",
        "runtime.23001-batch1-latest2-20260909.latest"
      ]
    },
    {
      "scope": "pg10-version-boundary",
      "status": "source_path_confirmed",
      "evidence_ids": [
        "no-action-boundary",
        "runtime.23001-batch1-pg10b-20260909.pg10"
      ]
    },
    {
      "scope": "identity-and-source",
      "status": "source_path_confirmed",
      "evidence_ids": [
        "identity",
        "restrict-path"
      ]
    },
    {
      "scope": "pg17-version-boundary",
      "status": "source_path_confirmed",
      "evidence_ids": [
        "runtime.pg17-boundary",
        "runtime.23001-boundary-pg17-final-20260909.pg17"
      ],
      "notes": "The PG17.11 case confirms the same RESTRICT operation reports 23503, preserves the INERROR-to-IDLE recovery boundary, and is not counted as 23001 coverage."
    }
  ],
  "runtime": [
    {
      "id": "runtime.23001-batch1-latest2-20260909.latest",
      "run_id": "23001-batch1-latest2-20260909",
      "target": "latest",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "status": "passed",
      "cases": [
        "restrict_delete_referenced_parent"
      ],
      "summary_sha256": "e38c907a737001707b5409de058e959f9da3711d7ab2c72c318d37f043351fc1",
      "raw_sha256": "4f5c32e84c543203a9ebb757c2a3567b2441bd2f7aaf6f0ec0daa3d187474ea9",
      "snippet_registry": {
        "sha256": "6086c1ce982afa5438bbcd29b86ec4cd0cbe0c76fa6152c1eb4a330a7706d5c8"
      },
      "case_manifest": {
        "sha256": "eca00a2f8f981d7f1ccf77e661b52690631bfedc399003f73ccc43de6a06a1bc"
      },
      "observed": {
        "sqlstate": "23001",
        "primary": "update or delete on table \"parents\" violates RESTRICT setting of foreign key constraint \"children_parent_id_fkey\" on table \"children\"",
        "detail": "Key (id)=(1) is referenced from table \"children\".",
        "after_error": "INERROR",
        "after_rollback": "IDLE",
        "final_counts": [
          0,
          0
        ]
      }
    },
    {
      "id": "runtime.23001-batch1-pg10b-20260909.pg10",
      "run_id": "23001-batch1-pg10b-20260909",
      "target": "pg10",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "status": "not_applicable",
      "cases": [
        "restrict_delete_referenced_parent"
      ],
      "summary_sha256": "ab114f4849fce773011f9069f644fd10d73abb66329ae931160fc8ecea295026",
      "raw_sha256": "92928af8522d2224aaaf21e8eb7a2d974e433a80d6f2b1bf33296588738d21b7",
      "snippet_registry": {
        "sha256": "6086c1ce982afa5438bbcd29b86ec4cd0cbe0c76fa6152c1eb4a330a7706d5c8"
      },
      "case_manifest": {
        "sha256": "eca00a2f8f981d7f1ccf77e661b52690631bfedc399003f73ccc43de6a06a1bc"
      },
      "observed": {
        "sqlstate": "23503",
        "primary": "update or delete on table \"parents\" violates foreign key constraint \"children_parent_id_fkey\" on table \"children\"",
        "detail": "Key (id)=(1) is still referenced from table \"children\".",
        "after_error": "INERROR",
        "after_rollback": "IDLE",
        "final_counts": [
          0,
          0
        ]
      },
      "reason": "PostgreSQL 10 reports this RESTRICT delete through the general foreign-key violation path 23503; the dedicated 23001 path is observed on PostgreSQL 18."
    },
    {
      "id": "runtime.23001-boundary-pg17-final-20260909.pg17",
      "run_id": "23001-boundary-pg17-final-20260909",
      "target": "pg17",
      "server_version": "17.11 (Debian 17.11-1.pgdg13+2)",
      "server_version_num": 170011,
      "status": "not_applicable",
      "case_status": "not_applicable",
      "target_status": "passed",
      "cases": [
        "restrict_delete_referenced_parent"
      ],
      "summary_sha256": "54174fb5450b9bade0e1788e288be5bf24792f161e71e9299b7095e1f40333e6",
      "raw_sha256": "2929c03723d90f76192e3d3ffc2f4f5a8a643f9a5f0eb898f7245f3cf6439c87",
      "snippet_registry": {
        "sha256": "6086c1ce982afa5438bbcd29b86ec4cd0cbe0c76fa6152c1eb4a330a7706d5c8"
      },
      "case_manifest": {
        "sha256": "eca00a2f8f981d7f1ccf77e661b52690631bfedc399003f73ccc43de6a06a1bc"
      },
      "observed": {
        "expected_sqlstate": "23503",
        "sqlstate": "23503",
        "severity": "ERROR",
        "primary": "update or delete on table \"parents\" violates foreign key constraint \"children_parent_id_fkey\" on table \"children\"",
        "detail": "Key (id)=(1) is still referenced from table \"children\".",
        "constraint_name": "children_parent_id_fkey",
        "after_error": "INERROR",
        "after_rollback": "IDLE",
        "final_counts": [
          0,
          0
        ],
        "natural_23001_observed": false
      },
      "selection_status": "selected_boundary_comparison",
      "reason": "The bounded PG17.11 RESTRICT delete uses the general 23503 path; the dedicated 23001 path is not applicable on this target."
    }
  ]
}
