{
  "schema": 1,
  "sqlstate": "44000",
  "condition_name": "with_check_option_violation",
  "runner": "scripts/verify_cases.py",
  "targets": {
    "latest": {
      "binary": "Homebrew PostgreSQL 18.6",
      "required": true
    },
    "pg10": {
      "image": "postgres:10",
      "required": true
    }
  },
  "cases": [
    {
      "id": "view_check_option_recovery",
      "versions": [
        "10",
        "18"
      ],
      "preconditions": [
        "A runner-owned disposable target is provisioned."
      ],
      "trigger": "Insert a row through a view with a visible-row predicate and WITH CHECK OPTION, then insert a row satisfying the predicate.",
      "assertions": [
        "SQLSTATE is 44000",
        "The diagnostic identifies the view",
        "The rejected row leaves autocommit usable",
        "A row satisfying the view predicate is accepted"
      ],
      "repair": "Fix the row or the view predicate deliberately; do not bypass the view invariant by treating this as a table constraint failure.",
      "cleanup": "Drop the case schema with an owner connection."
    }
  ],
  "evidence_status": "authored",
  "snippets": [
    {
      "id": "view_check_option_recovery",
      "case_id": "view_check_option_recovery",
      "language": "sql",
      "statements": {
        "create_table": "CREATE TABLE items(id integer PRIMARY KEY, visible boolean NOT NULL, note text NOT NULL)",
        "create_view": "CREATE VIEW visible_items AS SELECT id, visible, note FROM items WHERE visible WITH CHECK OPTION",
        "violating_insert": "INSERT INTO visible_items VALUES (1, false, 'hidden')",
        "valid_insert": "INSERT INTO visible_items VALUES (1, true, 'visible')",
        "verify": "SELECT id, visible, note FROM visible_items ORDER BY id"
      }
    }
  ],
  "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"
      },
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 81325,
          "binary": {
            "bindir": "/opt/homebrew/Cellar/postgresql@18/18.6/bin",
            "pg_config": "/opt/homebrew/bin/pg_config",
            "pg_config_version": "PostgreSQL 18.6 (Homebrew)",
            "postgres": "/opt/homebrew/Cellar/postgresql@18/18.6/bin/postgres"
          },
          "connection_scope": "runner-owned localhost port",
          "current_user": "runner",
          "docker": {},
          "lc_messages": "C",
          "libpq_version": "18.6",
          "locale": "en_US.UTF-8",
          "log_destination": "csvlog,jsonlog",
          "log_error_verbosity": "verbose",
          "log_min_error_statement": "error",
          "log_min_messages": "error",
          "logging_collector": "on",
          "machine": "arm64",
          "max_connections": "100",
          "platform": "macOS-26.6.2-arm64-arm-64bit-Mach-O",
          "psycopg_version": "3.3.5",
          "python_version": "3.14.6 (main, Jun 10 2026, 10:03:53) [Clang 21.0.0 (clang-2100.0.123.102)]",
          "server_encoding": "UTF8",
          "server_version": "18.6 (Homebrew)",
          "server_version_num": "180006",
          "target_kind": "latest",
          "wal_level": "logical"
        },
        "cases": [
          {
            "assertions": [
              {
                "expected": "44000",
                "name": "check-option sqlstate",
                "observed": "44000",
                "passed": true
              },
              {
                "expected": "new row violates check option for view \"visible_items\"",
                "name": "view name is identified",
                "observed": "new row violates check option for view \"visible_items\"",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "autocommit failure remains idle",
                "observed": {
                  "after_error": "IDLE",
                  "after_valid": "IDLE"
                },
                "passed": true
              },
              {
                "expected": "one valid view row",
                "name": "row satisfying view predicate is accepted",
                "observed": [
                  [
                    1,
                    true,
                    "visible"
                  ]
                ],
                "passed": true
              }
            ],
            "case_id": "view_check_option_recovery",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.011,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "WithCheckOptionViolation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": "Failing row contains (1, f, hidden).",
                "message_hint": null,
                "message_primary": "new row violates check option for view \"visible_items\"",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "execMain.c",
                "source_function": "ExecWithCheckOptions",
                "source_line": "2327",
                "sqlstate": "44000",
                "statement_position": null,
                "table_name": null,
                "text": "new row violates check option for view \"visible_items\"\nDETAIL:  Failing row contains (1, f, hidden)."
              },
              "repair": "Insert through the view with visible=true; do not bypass the view invariant.",
              "rows": [
                [
                  1,
                  true,
                  "visible"
                ]
              ],
              "statuses": {
                "after_error": "IDLE",
                "after_valid": "IDLE"
              }
            },
            "schema": "c44000_view_check_option_recovery",
            "status": "passed"
          }
        ]
      }
    },
    {
      "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"
      },
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Etc/UTC",
          "backend_pid": 79,
          "binary": {},
          "connection_scope": "runner-owned localhost port",
          "current_user": "postgres",
          "docker": {
            "architecture": "arm64",
            "command": "/usr/local/bin/docker",
            "digest": "sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
            "id": "sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
            "image": "postgres:10",
            "image_created": "2022-06-23T09:11:18.374607054Z",
            "image_ref": "postgres@sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
            "log_destination": "csvlog",
            "os": "linux",
            "repo_digests": [
              "postgres@sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc"
            ]
          },
          "lc_messages": "en_US.utf8",
          "libpq_version": "18.6",
          "locale": "en_US.UTF-8",
          "log_destination": "csvlog",
          "log_error_verbosity": "verbose",
          "log_min_error_statement": "error",
          "log_min_messages": "error",
          "logging_collector": "on",
          "machine": "arm64",
          "max_connections": "100",
          "platform": "macOS-26.6.2-arm64-arm-64bit-Mach-O",
          "psycopg_version": "3.3.5",
          "python_version": "3.14.6 (main, Jun 10 2026, 10:03:53) [Clang 21.0.0 (clang-2100.0.123.102)]",
          "server_encoding": "UTF8",
          "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
          "server_version_num": "100021",
          "target_kind": "pg10",
          "wal_level": "logical"
        },
        "cases": [
          {
            "assertions": [
              {
                "expected": "44000",
                "name": "check-option sqlstate",
                "observed": "44000",
                "passed": true
              },
              {
                "expected": "new row violates check option for view \"visible_items\"",
                "name": "view name is identified",
                "observed": "new row violates check option for view \"visible_items\"",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "autocommit failure remains idle",
                "observed": {
                  "after_error": "IDLE",
                  "after_valid": "IDLE"
                },
                "passed": true
              },
              {
                "expected": "one valid view row",
                "name": "row satisfying view predicate is accepted",
                "observed": [
                  [
                    1,
                    true,
                    "visible"
                  ]
                ],
                "passed": true
              }
            ],
            "case_id": "view_check_option_recovery",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.03,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "WithCheckOptionViolation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": "Failing row contains (1, f, hidden).",
                "message_hint": null,
                "message_primary": "new row violates check option for view \"visible_items\"",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "execMain.c",
                "source_function": "ExecWithCheckOptions",
                "source_line": "2183",
                "sqlstate": "44000",
                "statement_position": null,
                "table_name": null,
                "text": "new row violates check option for view \"visible_items\"\nDETAIL:  Failing row contains (1, f, hidden)."
              },
              "repair": "Insert through the view with visible=true; do not bypass the view invariant.",
              "rows": [
                [
                  1,
                  true,
                  "visible"
                ]
              ],
              "statuses": {
                "after_error": "IDLE",
                "after_valid": "IDLE"
              }
            },
            "schema": "c44000_view_check_option_recovery",
            "status": "passed"
          }
        ]
      }
    }
  ]
}
