{
  "schema": 1,
  "sqlstate": "P0001",
  "condition_name": "raise_exception",
  "sources": [
    {
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "id": "src.errcodes.18.6",
      "location": "lines 487-494",
      "path": "src/backend/utils/errcodes.txt",
      "sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
      "tag": "REL_18_6",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt"
    },
    {
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "id": "src.pl-exec.18.6",
      "location": "lines 3889-3923, exec_stmt_raise default and ereport",
      "path": "src/pl/plpgsql/src/pl_exec.c",
      "sha256": "0df3c70a6bccf6dddf443fb99e152a16a67009827c44a820597e98e585cb8b20",
      "tag": "REL_18_6",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/pl/plpgsql/src/pl_exec.c#L3889-L3923"
    },
    {
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "id": "doc.plpgsql.18",
      "location": "lines 2815-2860, 2957-2968, 3768-3775, 3836-3858, 4008-4013",
      "path": "doc/src/sgml/plpgsql.sgml",
      "sha256": "43d705adbded343336341fd3e34ea8940432e8a8211f737d36ba3041ad0a4a51",
      "tag": "PG18-docs",
      "url": "https://www.postgresql.org/docs/18/plpgsql-errors-and-messages.html"
    },
    {
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "id": "doc.protocol.18",
      "location": "lines 6254-6290, severity and diagnostic fields",
      "path": "doc/src/sgml/protocol.sgml",
      "sha256": "745339e07ebbc2bb67d98b258e25772ada644ef26011e3cd6b3fcbb435235f89",
      "tag": "PG18-docs",
      "url": "https://www.postgresql.org/docs/18/protocol-error-fields.html"
    },
    {
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "id": "doc.transactions.18",
      "location": "transaction rollback and savepoint behavior",
      "path": "doc/src/sgml/xact.sgml",
      "sha256": "b48fbe8bd02ce3d1181a350c88c8baa6e11c73edc90a936e77b180daef328c5c",
      "tag": "PG18-docs",
      "url": "https://www.postgresql.org/docs/18/tutorial-transactions.html"
    },
    {
      "commit": "313a720f95a3f41b59f853786b184f38f82172d9",
      "id": "doc.errcodes.8.1.4",
      "kind": "upstream_source",
      "location": "REL8_1_4 table rows 1303-1308",
      "path": "doc/src/sgml/errcodes.sgml",
      "release": "8.1.4",
      "sha256": "fdd6f5470b19970d3b60219a44e66b33193647975d346adfe2a98178f706b776",
      "url": "https://github.com/postgres/postgres/blob/313a720f95a3f41b59f853786b184f38f82172d9/doc/src/sgml/errcodes.sgml#L1303-L1308"
    },
    {
      "id": "manifest.P0001",
      "kind": "local_artifact",
      "location": "snapshots and definition_blobs entries for the P0001 definition",
      "sha256": "1727a275f336988ff96b4f9990a4ca253080f73fc5d316e7def165c8cf3708a8"
    },
    {
      "id": "case-manifest.P0001",
      "kind": "local_artifact",
      "location": "plpgsql_raise_exception",
      "sha256": "0976d6bce923e005cd20d0b74ffb82b98793c2136497e4f9b281c9168f3fc2f9"
    },
    {
      "id": "snippet-registry.P0001.final",
      "kind": "local_artifact",
      "location": "plpgsql_raise_exception ordered function, call, and followup",
      "sha256": "1728525c9f6f073807ce34df0d9a4ee60f1c8bce5179c8bca91c92ca79aa795a"
    }
  ],
  "claims": [
    {
      "id": "identity.class-and-condition",
      "limits": "The directory identifies the condition; it does not say that every application error should use P0001.",
      "method": "Read the Class P0 section and P0001 row in the frozen errcodes.txt snapshot.",
      "sources": [
        "src.errcodes.18.6"
      ],
      "statement": "P0001 is the raise_exception condition in PostgreSQL-specific Class P0, PL/pgSQL Error."
    },
    {
      "id": "raise.default-code",
      "limits": "An explicit condition, SQLSTATE, or ERRCODE selects another code; the default applies to an EXCEPTION-level raise.",
      "method": "Read the executor's default err_code branch and the official RAISE documentation.",
      "sources": [
        "src.pl-exec.18.6",
        "doc.plpgsql.18"
      ],
      "statement": "A RAISE EXCEPTION with no condition name and no SQLSTATE defaults to raise_exception, P0001."
    },
    {
      "id": "raise.levels-and-fields",
      "limits": "Client and server visibility also depends on message configuration; an explicit SQLSTATE can accompany a lower level.",
      "method": "Read the RAISE syntax, level behavior, USING options, and ereport construction.",
      "sources": [
        "doc.plpgsql.18",
        "src.pl-exec.18.6"
      ],
      "statement": "RAISE supports DEBUG, LOG, INFO, NOTICE, WARNING, and EXCEPTION levels; EXCEPTION normally aborts the current transaction, while lower levels generate messages, and USING can supply structured fields."
    },
    {
      "id": "raise.handler-subtransaction",
      "limits": "The handler's own errors propagate outward, and local variables follow PL/pgSQL's documented handler rules.",
      "method": "Read the official error-trapping and subtransaction descriptions.",
      "sources": [
        "doc.plpgsql.18"
      ],
      "statement": "A PL/pgSQL block with an EXCEPTION clause runs its protected body in a subtransaction; persistent changes made by the body are rolled back before the matching handler runs."
    },
    {
      "id": "raise.others-boundary",
      "limits": "OTHERS is a broad handler; this claim does not recommend swallowing all errors.",
      "method": "Read the condition matching and handler propagation paragraphs.",
      "sources": [
        "doc.plpgsql.18"
      ],
      "statement": "OTHERS matches every error type except QUERY_CANCELED and ASSERT_FAILURE, and a new error raised by the selected handler is not caught by that same clause."
    },
    {
      "id": "raise.diagnostics",
      "limits": "The exact fields present depend on the raised condition and the client interface.",
      "method": "Read the PL/pgSQL exception diagnostics section and the protocol field reference.",
      "sources": [
        "doc.plpgsql.18",
        "doc.protocol.18"
      ],
      "statement": "Inside an exception handler, SQLSTATE and SQLERRM identify the active exception and GET STACKED DIAGNOSTICS can retrieve its fields."
    },
    {
      "id": "runtime.raise-case",
      "limits": "This is an intentional PL/pgSQL exception case; it does not test custom SQLSTATEs, explicit transactions, or handler recovery.",
      "method": "Read the stable case and ordered snippet registry, then compare the case_result diagnostics and follow-up status in both final target summaries and raw records.",
      "sources": [
        "case-manifest.P0001",
        "snippet-registry.P0001.final",
        "runtime.P0001-snippet-registry-final-20260909.latest",
        "runtime.P0001-snippet-registry-final-20260909.pg10"
      ],
      "statement": "plpgsql_raise_exception returned P0001 with the caller-supplied calibration exception message on PostgreSQL 18.6 and 10.21; both autocommit connections remained IDLE and accepted SELECT 1."
    },
    {
      "id": "runtime.transaction-context",
      "limits": "No explicit transaction was run in this P0001 case; handler blocks have the separate subtransaction contract above.",
      "method": "Read the transaction contract and compare it with the observed IDLE/follow-up result.",
      "sources": [
        "doc.transactions.18",
        "runtime.P0001-snippet-registry-final-20260909.latest",
        "runtime.P0001-snippet-registry-final-20260909.pg10"
      ],
      "statement": "An unhandled EXCEPTION in an explicit transaction normally requires rollback before unrelated commands, while the representative autocommit call leaves the connection usable."
    },
    {
      "id": "versions.catalogue-boundary",
      "limits": "The pre-9.0 source set is locked through 8.4.22 but candidate source gaps remain for 7.0–7.3; the observed condition-name and class-title changes are not exact implementation introduction dates.",
      "method": "Read the manifest snapshot and the same-tag REL8_1_4 errcodes.sgml row for the code; the generated per-code history is a derived view.",
      "sources": [
        "manifest.P0001",
        "doc.errcodes.8.1.4"
      ],
      "statement": "The locked catalogue records P0001 in the 8.0.0–8.4.22 pre-9.0 formal sources, every listed formal snapshot from 9.0.23 through 18.6, and 19beta3. The same-tag REL8_1_4 errcodes.sgml row already lists P0001 as raise_exception, confirming that condition-name observation by 8.1.4. The class title changes between the 9.0 header and 9.1 text definitions; candidate source gaps remain for 7.0–7.3. These are presence boundaries, not asserted implementation introduction dates."
    }
  ],
  "messages": [
    {
      "id": "message.raise-user",
      "limits": "There is no universal P0001 primary text; the default message when no text is supplied is the condition name or SQLSTATE.",
      "primary_template": "caller-supplied RAISE format, condition, or MESSAGE expression",
      "severity_source": "default EXCEPTION level",
      "sources": [
        "src.pl-exec.18.6",
        "doc.plpgsql.18"
      ],
      "sqlstate": "P0001"
    },
    {
      "id": "message.runtime-calibration",
      "limits": "This literal is specific to the representative function and is not a built-in P0001 message template.",
      "primary_template": "calibration exception",
      "severity_source": "EXCEPTION",
      "sources": [
        "runtime.P0001-snippet-registry-final-20260909.latest",
        "runtime.P0001-snippet-registry-final-20260909.pg10"
      ],
      "sqlstate": "P0001"
    }
  ],
  "usage_evidence": [
    {
      "evidence_ids": [
        "identity.class-and-condition",
        "src.errcodes.18.6"
      ],
      "scope": "directory_definition",
      "status": "definition_only"
    },
    {
      "evidence_ids": [
        "raise.default-code",
        "raise.levels-and-fields",
        "src.pl-exec.18.6",
        "doc.plpgsql.18"
      ],
      "scope": "raise_default_and_levels",
      "status": "source_path_confirmed"
    },
    {
      "evidence_ids": [
        "raise.handler-subtransaction",
        "raise.others-boundary",
        "doc.plpgsql.18"
      ],
      "scope": "handler_transaction_and_others",
      "status": "source_path_confirmed"
    },
    {
      "evidence_ids": [
        "runtime.raise-case",
        "snippet-registry.P0001.final",
        "runtime.P0001-snippet-registry-final-20260909.latest",
        "runtime.P0001-snippet-registry-final-20260909.pg10"
      ],
      "scope": "representative_runtime",
      "status": "observed_runtime"
    },
    {
      "evidence_ids": [
        "versions.catalogue-boundary",
        "manifest.P0001",
        "doc.errcodes.8.1.4"
      ],
      "scope": "version_presence",
      "status": "definition_only"
    }
  ],
  "runtime": [
    {
      "cases": [
        "plpgsql_raise_exception"
      ],
      "id": "runtime.P0001-snippet-registry-final-20260909.latest",
      "observed": {
        "followup": 1,
        "message_primary": "calibration exception",
        "severity": "ERROR",
        "source_file": "pl_exec.c",
        "source_function": "exec_stmt_raise",
        "source_line": "3923",
        "sqlstate": "P0001",
        "status_after_error": "IDLE"
      },
      "raw_sha256": "f0ce5f0fcbeaeba978fbb959a418c24eac2ec1db2b0393b9bc15f24d3936ed1b",
      "run_id": "P0001-snippet-registry-final-20260909",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "snippet_registry": {
        "sha256": "1728525c9f6f073807ce34df0d9a4ee60f1c8bce5179c8bca91c92ca79aa795a"
      },
      "status": "passed",
      "summary_sha256": "6c298799062a8c47fd2eee07194afc0a6e53d7e1ef87639c9f996951f4de3c9b",
      "target": "latest"
    },
    {
      "cases": [
        "plpgsql_raise_exception"
      ],
      "id": "runtime.P0001-snippet-registry-final-20260909.pg10",
      "image": "postgres@sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
      "observed": {
        "followup": 1,
        "message_primary": "calibration exception",
        "severity": "ERROR",
        "source_file": "pl_exec.c",
        "source_function": "exec_stmt_raise",
        "source_line": "3337",
        "sqlstate": "P0001",
        "status_after_error": "IDLE"
      },
      "raw_sha256": "4308e016521aed455b575094b061162077e06f83884e53e96074db1d7b144dac",
      "run_id": "P0001-snippet-registry-final-20260909",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "snippet_registry": {
        "sha256": "1728525c9f6f073807ce34df0d9a4ee60f1c8bce5179c8bca91c92ca79aa795a"
      },
      "status": "passed",
      "summary_sha256": "5fe9b2e2a9147aebe3bd43af67cd60ff768dddbbe10ae92bb0a5a6d9dcad230c",
      "target": "pg10"
    }
  ]
}
