{
  "schema": 1,
  "sqlstate": "39P01",
  "condition_name": "trigger_protocol_violated",
  "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#L311",
      "lines": "311"
    },
    {
      "id": "src.calls.REL_18_6",
      "kind": "local_artifact",
      "source_role": "source_call_scan",
      "sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf"
    },
    {
      "id": "src.path.trigger",
      "kind": "upstream_source",
      "source_role": "resolved_report_context",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "src/backend/commands/trigger.c",
      "sha256": "0a539af85b0de1a04779f92202e7bfc77d85ae6da1747ea32527c67f39084fbd",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/trigger.c#L2388-L2394",
      "lines": "2388-2394,2448-2453,2677-2682,2949-2954"
    },
    {
      "id": "src.path.tcn",
      "kind": "upstream_source",
      "source_role": "resolved_report_context",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "contrib/tcn/tcn.c",
      "sha256": "fd1b0dfa65a4b3f15bddc5ae6d4b71505e448a5febdaa20c5da8839d2b54350d",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/tcn/tcn.c#L77-L110",
      "lines": "77-110,178-180"
    },
    {
      "id": "src.path.plperl",
      "kind": "upstream_source",
      "source_role": "resolved_report_context",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "src/pl/plperl/plperl.c",
      "sha256": "90789190fd0bf5b53773b57b8c3287c88c35fbebdfa8310acab3f2d89910e4ba",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/pl/plperl/plperl.c#L2607-L2618",
      "lines": "2607-2618"
    }
  ],
  "claims": [
    {
      "id": "identity",
      "statement": "39P01 is trigger_protocol_violated in Class 39.",
      "sources": [
        "src.errcodes.18.6"
      ],
      "method": "Read the fixed definition row."
    },
    {
      "id": "core-trigger",
      "statement": "The core trigger manager reports this code when a trigger function sets the isnull flag, and for invalid BEFORE STATEMENT return values.",
      "sources": [
        "src.path.trigger"
      ],
      "method": "Read each fixed trigger-manager context and its message."
    },
    {
      "id": "tcn-contract",
      "statement": "contrib/tcn checks trigger invocation context, AFTER timing, row level, argument count, and primary-key setup with this code.",
      "sources": [
        "src.path.tcn"
      ],
      "method": "Read the complete tcn checks around each report."
    },
    {
      "id": "language-severity",
      "statement": "PL/Perl has a WARNING variant for an ignored DELETE-row modification and an ERROR variant for an invalid trigger return value.",
      "sources": [
        "src.path.plperl"
      ],
      "method": "Compare ereport levels and exact messages."
    }
  ],
  "messages": [
    {
      "id": "message.trigger-null",
      "sqlstate": "39P01",
      "primary_template": "trigger function %u returned null value",
      "severity_source": "ERROR",
      "sources": [
        "src.path.trigger"
      ]
    },
    {
      "id": "message.before-statement",
      "sqlstate": "39P01",
      "primary_template": "BEFORE STATEMENT trigger cannot return a value",
      "severity_source": "ERROR",
      "sources": [
        "src.path.trigger"
      ]
    },
    {
      "id": "message.tcn-called-as-trigger",
      "sqlstate": "39P01",
      "primary_template": "triggered_change_notification: must be called as trigger",
      "severity_source": "ERROR",
      "sources": [
        "src.path.tcn"
      ]
    },
    {
      "id": "message.tcn-after-change",
      "sqlstate": "39P01",
      "primary_template": "triggered_change_notification: must be called after the change",
      "severity_source": "ERROR",
      "sources": [
        "src.path.tcn"
      ]
    },
    {
      "id": "message.tcn-each-row",
      "sqlstate": "39P01",
      "primary_template": "triggered_change_notification: must be called for each row",
      "severity_source": "ERROR",
      "sources": [
        "src.path.tcn"
      ]
    },
    {
      "id": "message.tcn-one-parameter",
      "sqlstate": "39P01",
      "primary_template": "triggered_change_notification: must not be called with more than one parameter",
      "severity_source": "ERROR",
      "sources": [
        "src.path.tcn"
      ]
    },
    {
      "id": "message.tcn-primary-key",
      "sqlstate": "39P01",
      "primary_template": "triggered_change_notification: must be called on a table with a primary key",
      "severity_source": "ERROR",
      "sources": [
        "src.path.tcn"
      ]
    },
    {
      "id": "message.plperl-delete-warning",
      "sqlstate": "39P01",
      "primary_template": "ignoring modified row in DELETE trigger",
      "severity_source": "WARNING",
      "sources": [
        "src.path.plperl"
      ]
    },
    {
      "id": "message.plperl-invalid-return",
      "sqlstate": "39P01",
      "primary_template": "result of PL/Perl trigger function must be undef, \"SKIP\", or \"MODIFY\"",
      "severity_source": "ERROR",
      "sources": [
        "src.path.plperl"
      ]
    }
  ],
  "usage_evidence": [
    {
      "scope": "definition",
      "status": "definition_only",
      "evidence_ids": [
        "identity"
      ]
    },
    {
      "scope": "core-trigger",
      "status": "source_path_confirmed",
      "evidence_ids": [
        "core-trigger"
      ]
    },
    {
      "scope": "tcn",
      "status": "source_path_confirmed",
      "evidence_ids": [
        "tcn-contract"
      ]
    },
    {
      "scope": "language-handler",
      "status": "source_path_confirmed",
      "evidence_ids": [
        "language-severity"
      ]
    },
    {
      "scope": "natural-runtime",
      "status": "unknown",
      "evidence_ids": [
        "core-trigger"
      ]
    }
  ],
  "runtime": []
}
