{
  "schema": 1,
  "sqlstate": "44000",
  "condition_name": "with_check_option_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.execMain.18.6",
      "kind": "upstream_source",
      "source_role": "source_path",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "src/backend/executor/execMain.c",
      "sha256": "33b97337fa23a649c5e7a092e1bd405a54e8503529236c62c9d5bb93a1774a8d",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/executor/execMain.c#L2322-L2327"
    },
    {
      "id": "src.execMain.10.23",
      "kind": "upstream_source",
      "source_role": "source_path",
      "tag": "REL_10_23",
      "commit": "02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4",
      "path": "src/backend/executor/execMain.c",
      "sha256": "386d09f7e964ebc426a554cf51ac7cb505c67cc95b971ee7acad1a6e0a9d0c1a",
      "url": "https://github.com/postgres/postgres/blob/02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4/src/backend/executor/execMain.c#L2178-L2183"
    },
    {
      "id": "doc.create-view.18.6",
      "kind": "upstream_source",
      "source_role": "official_documentation",
      "tag": "REL_18_6",
      "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
      "path": "doc/src/sgml/ref/create_view.sgml",
      "sha256": "d2c2aae6e102594deaa2f5aabc7910cdaada11d714e49e818511a57bb21fec57",
      "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ref/create_view.sgml",
      "docs_url": "https://www.postgresql.org/docs/18/sql-createview.html"
    }
  ],
  "claims": [
    {
      "id": "identity",
      "statement": "44000 is the with_check_option_violation condition in Class 44.",
      "sources": [
        "src.errcodes.18.6"
      ],
      "method": "Read the fixed errcodes.txt row and macro mapping.",
      "limits": "This is a view write invariant, not a table CHECK constraint code."
    },
    {
      "id": "view-path",
      "statement": "ExecWithCheckOptions emits new row violates check option for view \"%s\" with a dynamic failing-row DETAIL.",
      "sources": [
        "src.execMain.18.6",
        "src.calls.REL_18_6"
      ],
      "method": "Trace ERRCODE_WITH_CHECK_OPTION_VIOLATION in execMain.c.",
      "limits": "The row representation and view name are dynamic."
    },
    {
      "id": "three-valued-check",
      "statement": "ExecWithCheckOptions treats a view check qual that evaluates to NULL or FALSE as a violation because the new tuple would not be visible through the view.",
      "sources": [
        "src.execMain.18.6"
      ],
      "method": "Read the fixed ExecWithCheckOptions comment and branch before the ERRCODE_WITH_CHECK_OPTION_VIOLATION report.",
      "limits": "This describes the executor check; the selected case uses a directly updatable view."
    },
    {
      "id": "detail-permission",
      "statement": "The failing-row DETAIL for a view check option is conditional on permissions that allow the row description.",
      "sources": [
        "src.execMain.18.6"
      ],
      "method": "Trace the WCO_VIEW_CHECK permission guard before ExecBuildSlotValueDescription.",
      "limits": "DETAIL may be absent even when the check ran."
    },
    {
      "id": "scope-and-trigger-boundary",
      "statement": "LOCAL checks only conditions defined directly in the current view; ordinary underlying-view conditions are not checked unless those base views also specify CHECK OPTION. CASCADED checks the current view and all underlying base-view conditions. CHECK OPTION is supported only on automatically updatable views without an INSTEAD OF trigger or rule; a trigger-updatable base view stops a cascade, and an INSTEAD rule rewrite can cause all checks to be ignored.",
      "sources": [
        "doc.create-view.18.6"
      ],
      "method": "Read the fixed CREATE VIEW documentation and compare the selected case definition.",
      "limits": "The selected runtime case is a direct automatically updatable view; it does not exercise nested views, a trigger-updatable base, or an INSTEAD rewrite."
    },
    {
      "id": "repair",
      "statement": "A write through a view with WITH CHECK OPTION must satisfy the view predicate; correcting the row preserves the invariant.",
      "sources": [
        "doc.create-view.18.6"
      ],
      "method": "Use the shared visible=true/false view case.",
      "limits": "LOCAL/CASCADED view composition and UPDATE paths can add further predicates."
    },
    {
      "id": "runtime",
      "statement": "The selected 44000 case passed on PostgreSQL 18.6 and 10.21 with the structured SQLSTATE, transaction-state, and repair assertions recorded in the runtime entries.",
      "sources": [
        "runtime.44000-batch34-20260909.latest",
        "runtime.44000-batch34-20260909.pg10"
      ],
      "method": "Read the selected runner summaries and raw outputs tied to the shared snippet registry.",
      "limits": "This covers the selected directly updatable view path; it does not test nested LOCAL/CASCADED views or INSTEAD OF triggers."
    }
  ],
  "messages": [
    {
      "id": "message.view-check",
      "sqlstate": "44000",
      "primary_template": "new row violates check option for view \"%s\"",
      "detail_template": "Failing row contains %s.",
      "severity_source": "ERROR",
      "sources": [
        "src.execMain.18.6"
      ],
      "limits": "Both the view identifier and row rendering are dynamic."
    }
  ],
  "usage_evidence": [
    {
      "scope": "44000-runtime",
      "status": "observed_runtime",
      "evidence_ids": [
        "runtime",
        "runtime.44000-batch34-20260909.latest",
        "runtime.44000-batch34-20260909.pg10"
      ]
    },
    {
      "scope": "condition-and-source-paths",
      "status": "source_path_confirmed",
      "evidence_ids": [
        "identity",
        "view-path",
        "repair"
      ]
    }
  ],
  "runtime": [
    {
      "id": "runtime.44000-batch34-20260909.latest",
      "run_id": "44000-batch34-20260909",
      "target": "latest",
      "server_version": "18.6 (Homebrew)",
      "status": "passed",
      "cases": [
        "view_check_option_recovery"
      ],
      "summary_sha256": "3d674692d53f36522eb3c818be06c41fc9b4386bb7dd37e65f8410a88629162f",
      "raw_sha256": "5b79b8c867bb95b70d22cff85bc3893ea16034731fb8a207c19b2910276efaa0",
      "case_manifest": {
        "sha256": "5512b051ff6459a4e3e6b5c35dcd1f30b1fff6f96d2513634382573954224f5a"
      },
      "observed": {
        "sqlstate": "44000",
        "primary": "new row violates check option for view \"visible_items\"",
        "severity": "ERROR",
        "statuses": {
          "after_error": "IDLE",
          "after_valid": "IDLE"
        },
        "repair": {
          "rows": [
            [
              1,
              true,
              "visible"
            ]
          ]
        },
        "connection_autocommit": true
      },
      "snippet_registry": {
        "sha256": "7b227bca904c860388c6cf1f5b7f551412b4d67832fb91aaa682f4126072e41c"
      }
    },
    {
      "id": "runtime.44000-batch34-20260909.pg10",
      "run_id": "44000-batch34-20260909",
      "target": "pg10",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "status": "passed",
      "cases": [
        "view_check_option_recovery"
      ],
      "summary_sha256": "24148b05266cf9fe1cda71058dd89ac856f1c4020c886b3a5ab33a51186377e8",
      "raw_sha256": "baf0278700f3e0f15b3b12de0f97bdf31173c6e9470a12b198ee7e696568998a",
      "case_manifest": {
        "sha256": "5512b051ff6459a4e3e6b5c35dcd1f30b1fff6f96d2513634382573954224f5a"
      },
      "observed": {
        "sqlstate": "44000",
        "primary": "new row violates check option for view \"visible_items\"",
        "severity": "ERROR",
        "statuses": {
          "after_error": "IDLE",
          "after_valid": "IDLE"
        },
        "repair": {
          "rows": [
            [
              1,
              true,
              "visible"
            ]
          ]
        },
        "connection_autocommit": true
      },
      "snippet_registry": {
        "sha256": "7b227bca904c860388c6cf1f5b7f551412b4d67832fb91aaa682f4126072e41c"
      }
    }
  ]
}
