{
  "schema": 1,
  "sqlstate": "P0004",
  "condition_name": "assert_failure",
  "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#L494",
      "lines": "494"
    },
    {
      "id": "src.calls.REL_18_6",
      "kind": "local_artifact",
      "source_role": "source_call_scan",
      "sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf"
    },
    {
      "id": "src.path.plpgsql",
      "kind": "upstream_source",
      "source_role": "resolved_report_context",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "src/pl/plpgsql/src/pl_exec.c",
      "sha256": "0df3c70a6bccf6dddf443fb99e152a16a67009827c44a820597e98e585cb8b20",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/pl/plpgsql/src/pl_exec.c#L3965-L3968",
      "lines": "3965-3968"
    },
    {
      "id": "runtime.P0004-same-session-latest-final.latest",
      "kind": "local_artifact",
      "source_role": "runtime_result",
      "sha256": "5246ae67ee8dd29e769c3a03db7bfb6cde2f201c9f45993201fb269cc53988ad"
    },
    {
      "id": "runtime.P0004-same-session-latest-final.latest.raw",
      "kind": "local_artifact",
      "source_role": "runtime_raw",
      "sha256": "2b03b5469ea34a0e49ad4a71e93cef4b19df0d01d86fc1156e478d88bc93168c"
    },
    {
      "id": "runtime.P0004-same-session-pg10-final.pg10",
      "kind": "local_artifact",
      "source_role": "runtime_result",
      "sha256": "50819f9620584f17766ffb62e2bb1c14e5aaa9162f91ec6cd26795cced3e6d30"
    },
    {
      "id": "runtime.P0004-same-session-pg10-final.pg10.raw",
      "kind": "local_artifact",
      "source_role": "runtime_raw",
      "sha256": "2369b62eb7c22d99122c9929134a878f2f3c0fe828887ae657f87b7b95e07ac8"
    },
    {
      "id": "snippet-registry.P0004",
      "kind": "local_artifact",
      "source_role": "runtime_input",
      "sha256": "ef124f75ec61be666abc87ff431ebfb496dfa3352f78a3bee4432430dd68c229"
    },
    {
      "id": "doc.plpgsql.18",
      "kind": "upstream_source",
      "source_role": "official_documentation",
      "tag": "PG18-docs",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "doc/src/sgml/plpgsql.sgml",
      "sha256": "43d705adbded343336341fd3e34ea8940432e8a8211f737d36ba3041ad0a4a51",
      "url": "https://www.postgresql.org/docs/18/plpgsql-errors-and-messages.html",
      "lines": "2815-2860,2957-2968,3768-3775,3836-3858,4008-4013"
    },
    {
      "id": "doc.plpgsql-control.18",
      "kind": "upstream_source",
      "source_role": "exception_trapping_documentation",
      "tag": "PG18-docs",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "doc/src/sgml/plpgsql.sgml",
      "sha256": "43d705adbded343336341fd3e34ea8940432e8a8211f737d36ba3041ad0a4a51",
      "url": "https://www.postgresql.org/docs/18/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING",
      "lines": "2783-2860"
    }
  ],
  "claims": [
    {
      "id": "identity",
      "statement": "P0004 is assert_failure in PostgreSQL-specific Class P0.",
      "sources": [
        "src.errcodes.18.6"
      ],
      "method": "Read the fixed definition row."
    },
    {
      "id": "assert-path",
      "statement": "PL/pgSQL assertion execution reports P0004 at ERROR level, using the evaluated message when present and `assertion failed` when no message is supplied.",
      "sources": [
        "src.path.plpgsql"
      ],
      "method": "Read the fixed `ASSERT` execution path and both errmsg branches."
    },
    {
      "id": "runtime.assertion-case",
      "statement": "The shared assertion_failure_recovery case passed on PostgreSQL 18.6 and PostgreSQL 10.21: the false ASSERT returned P0004 with value must be positive, the explicit transaction was INERROR until ROLLBACK, a valid input succeeded, and the disabled-assert control returned zero.",
      "sources": [
        "runtime.P0004-same-session-latest-final.latest",
        "runtime.P0004-same-session-pg10-final.pg10",
        "snippet-registry.P0004"
      ],
      "method": "Read both target summaries and the fixed snippet registry.",
      "limits": "This is a bounded case for the shared function and ASSERT setting; it does not establish behavior for arbitrary assertion messages or non-PL/pgSQL code."
    },
    {
      "id": "runtime.diagnostics",
      "statement": "The latest target recorded ERROR/P0004 from exec_stmt_assert at pl_exec.c:3968 with context at ASSERT; the PG10 target recorded the same SQLSTATE and diagnostic with its version-specific source line.",
      "sources": [
        "runtime.P0004-same-session-latest-final.latest",
        "runtime.P0004-same-session-pg10-final.pg10"
      ],
      "method": "Compare structured diagnostics in both target summaries."
    },
    {
      "id": "assert-semantics",
      "statement": "The fixed PL/pgSQL ASSERT path reports P0004 when its Boolean condition evaluates false or NULL; the supplied message expression is used as primary text, otherwise the executor uses assertion failed.",
      "sources": [
        "src.path.plpgsql",
        "doc.plpgsql.18"
      ],
      "method": "Read the fixed executor branch and the official PL/pgSQL ASSERT documentation."
    },
    {
      "id": "settings-and-handler-boundary",
      "statement": "plpgsql.check_asserts controls assertion checking for the session, and the PL/pgSQL handler rules exclude ASSERT_FAILURE from WHEN OTHERS while allowing a named ASSERT_FAILURE condition.",
      "sources": [
        "doc.plpgsql-control.18",
        "src.path.plpgsql"
      ],
      "method": "Read the PL/pgSQL control-structures error-trapping section for EXCEPTION subtransactions and condition matching; read the fixed executor for the session setting boundary.",
      "limits": "The setting is session-scoped; this claim does not make a connection-level setting change global."
    },
    {
      "id": "transaction-recovery",
      "statement": "The observed case entered INERROR after P0004, returned to IDLE after ROLLBACK, and then accepted a valid call; disabling check_asserts suppressed the false assertion in the control branch.",
      "sources": [
        "runtime.P0004-same-session-latest-final.latest",
        "runtime.P0004-same-session-pg10-final.pg10",
        "snippet-registry.P0004"
      ],
      "method": "Read both passed target summaries and the ordered shared registry."
    }
  ],
  "messages": [
    {
      "id": "message.assert",
      "sqlstate": "P0004",
      "primary_template": "assertion failed",
      "alternate_template": "%s",
      "severity_source": "ERROR",
      "sources": [
        "src.path.plpgsql"
      ]
    }
  ],
  "usage_evidence": [
    {
      "scope": "definition",
      "status": "definition_only",
      "evidence_ids": [
        "identity"
      ]
    },
    {
      "scope": "plpgsql-assert-path",
      "status": "source_path_confirmed",
      "evidence_ids": [
        "assert-path",
        "assert-semantics",
        "settings-and-handler-boundary"
      ]
    },
    {
      "scope": "natural-runtime",
      "status": "observed_runtime",
      "evidence_ids": [
        "runtime.P0004-same-session-latest-final.latest",
        "runtime.P0004-same-session-pg10-final.pg10",
        "transaction-recovery"
      ]
    }
  ],
  "runtime": [
    {
      "id": "runtime.P0004-same-session-latest-final.latest",
      "run_id": "P0004-same-session-latest-final",
      "target": "latest",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "status": "passed",
      "summary_sha256": "5246ae67ee8dd29e769c3a03db7bfb6cde2f201c9f45993201fb269cc53988ad",
      "raw_sha256": "2b03b5469ea34a0e49ad4a71e93cef4b19df0d01d86fc1156e478d88bc93168c",
      "cases": [
        "assertion_failure_recovery"
      ],
      "observed": {
        "sqlstate": "P0004",
        "severity": "ERROR",
        "message_primary": "value must be positive",
        "after_error": "INERROR",
        "after_rollback": "IDLE",
        "repair_result": 1,
        "disabled_control_result": 0
      }
    },
    {
      "id": "runtime.P0004-same-session-pg10-final.pg10",
      "run_id": "P0004-same-session-pg10-final",
      "target": "pg10",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "status": "passed",
      "summary_sha256": "50819f9620584f17766ffb62e2bb1c14e5aaa9162f91ec6cd26795cced3e6d30",
      "raw_sha256": "2369b62eb7c22d99122c9929134a878f2f3c0fe828887ae657f87b7b95e07ac8",
      "cases": [
        "assertion_failure_recovery"
      ],
      "observed": {
        "sqlstate": "P0004",
        "severity": "ERROR",
        "message_primary": "value must be positive",
        "after_error": "INERROR",
        "after_rollback": "IDLE",
        "repair_result": 1,
        "disabled_control_result": 0
      }
    }
  ]
}
