{
  "schema": 1,
  "sqlstate": "23514",
  "condition_name": "check_violation",
  "runner": "scripts/verify_cases.py",
  "targets": {
    "latest": {
      "binary": "Homebrew PostgreSQL 18.6",
      "required": true
    },
    "pg10": {
      "image": "postgres:10",
      "required": true
    }
  },
  "cases": [
    {
      "id": "check_constraint_insert",
      "versions": [
        "10",
        "18"
      ],
      "preconditions": [
        "The target table has a named CHECK constraint",
        "The inserted value fails that predicate"
      ],
      "trigger": "Insert a row whose value violates the CHECK expression.",
      "assertions": [
        "SQLSTATE is 23514",
        "The named relation and constraint are identified",
        "A valid row can be inserted after the error"
      ],
      "repair": "Correct the value or deliberately revise the constraint after reviewing existing data; do not disable validation to hide a contract violation.",
      "cleanup": "Drop the case schema with an owner connection."
    }
  ],
  "evidence_status": "authored",
  "snippets": [
    {
      "id": "check_constraint_insert",
      "case_id": "check_constraint_insert",
      "language": "sql",
      "statements": {
        "create": "CREATE TABLE items(id integer PRIMARY KEY, amount integer CONSTRAINT amount_positive CHECK (amount > 0))",
        "seed": "INSERT INTO items VALUES (1, 10)",
        "trigger": "INSERT INTO items VALUES (2, -1)",
        "repair": "INSERT INTO items VALUES (2, 1)",
        "verify": "SELECT id, amount FROM items ORDER BY id"
      }
    }
  ],
  "runtime": [
    {
      "id": "runtime.23514-batch1-latest-20260909.latest",
      "run_id": "23514-batch1-latest-20260909",
      "target": "latest",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "status": "passed",
      "cases": [
        "check_constraint_insert"
      ],
      "summary_sha256": "ea15d7fcfc868444fd08a27f5a428e75f5d129e53732fa0ac19449bcc0e589a4",
      "raw_sha256": "11302e6a32ae75c2f4938099bcbcfeeb774ad58e3f404574c56b0c81ea828012",
      "snippet_registry": {
        "sha256": "0dcd48b5f9b3c4264c7843f77edae204d2a37b55a2b41bb2570febfdf6391d83"
      },
      "case_manifest": {
        "sha256": "86b43f2a10da9ff67b7b53b05fe3d16121b922f713be9f02f7c8caf558f73012"
      },
      "observed": {
        "sqlstate": "23514",
        "primary": "new row for relation \"items\" violates check constraint \"amount_positive\"",
        "detail": "Failing row contains (2, -1).",
        "constraint": "amount_positive",
        "table": "items",
        "status_after_error": "IDLE",
        "rows": [
          [
            1,
            10
          ],
          [
            2,
            1
          ]
        ]
      },
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 33444,
          "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": "23514",
                "name": "check sqlstate",
                "observed": "23514",
                "passed": true
              },
              {
                "expected": "amount_positive/items",
                "name": "check constraint is identified",
                "observed": {
                  "constraint": "amount_positive",
                  "table": "items"
                },
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "autocommit remains idle",
                "observed": {
                  "after_error": "IDLE",
                  "after_valid": "IDLE"
                },
                "passed": true
              },
              {
                "expected": "two rows",
                "name": "valid row committed",
                "observed": [
                  [
                    1,
                    10
                  ],
                  [
                    2,
                    1
                  ]
                ],
                "passed": true
              }
            ],
            "case_id": "check_constraint_insert",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.014,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": "amount_positive",
                "context": null,
                "datatype_name": null,
                "exception_type": "CheckViolation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": "Failing row contains (2, -1).",
                "message_hint": null,
                "message_primary": "new row for relation \"items\" violates check constraint \"amount_positive\"",
                "schema_name": "c23514_check_constraint_insert",
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "execMain.c",
                "source_function": "ExecConstraints",
                "source_line": "2081",
                "sqlstate": "23514",
                "statement_position": null,
                "table_name": "items",
                "text": "new row for relation \"items\" violates check constraint \"amount_positive\"\nDETAIL:  Failing row contains (2, -1)."
              },
              "rows": [
                [
                  1,
                  10
                ],
                [
                  2,
                  1
                ]
              ],
              "statuses": {
                "after_error": "IDLE",
                "after_valid": "IDLE"
              }
            },
            "schema": "c23514_check_constraint_insert",
            "status": "passed"
          }
        ]
      }
    },
    {
      "id": "runtime.23514-batch1-pg10-20260909.pg10",
      "run_id": "23514-batch1-pg10-20260909",
      "target": "pg10",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "status": "passed",
      "cases": [
        "check_constraint_insert"
      ],
      "summary_sha256": "599d10014ead75a34e9a0f59a7485ba0cdbfc350fa01456201c8bda00b29aa10",
      "raw_sha256": "e0a09ba6b64cc6ba16b2038fb8fee8541d55b047369068ccca8b2406c5700699",
      "snippet_registry": {
        "sha256": "0dcd48b5f9b3c4264c7843f77edae204d2a37b55a2b41bb2570febfdf6391d83"
      },
      "case_manifest": {
        "sha256": "86b43f2a10da9ff67b7b53b05fe3d16121b922f713be9f02f7c8caf558f73012"
      },
      "observed": {
        "sqlstate": "23514",
        "primary": "new row for relation \"items\" violates check constraint \"amount_positive\"",
        "detail": "Failing row contains (2, -1).",
        "constraint": "amount_positive",
        "table": "items",
        "status_after_error": "IDLE",
        "rows": [
          [
            1,
            10
          ],
          [
            2,
            1
          ]
        ]
      },
      "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",
            "id": "sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
            "image": "postgres:10",
            "image_created": "2022-06-23T09:11:18.374607054Z",
            "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": "23514",
                "name": "check sqlstate",
                "observed": "23514",
                "passed": true
              },
              {
                "expected": "amount_positive/items",
                "name": "check constraint is identified",
                "observed": {
                  "constraint": "amount_positive",
                  "table": "items"
                },
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "autocommit remains idle",
                "observed": {
                  "after_error": "IDLE",
                  "after_valid": "IDLE"
                },
                "passed": true
              },
              {
                "expected": "two rows",
                "name": "valid row committed",
                "observed": [
                  [
                    1,
                    10
                  ],
                  [
                    2,
                    1
                  ]
                ],
                "passed": true
              }
            ],
            "case_id": "check_constraint_insert",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.014,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": "amount_positive",
                "context": null,
                "datatype_name": null,
                "exception_type": "CheckViolation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": "Failing row contains (2, -1).",
                "message_hint": null,
                "message_primary": "new row for relation \"items\" violates check constraint \"amount_positive\"",
                "schema_name": "c23514_check_constraint_insert",
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "execMain.c",
                "source_function": "ExecConstraints",
                "source_line": "2070",
                "sqlstate": "23514",
                "statement_position": null,
                "table_name": "items",
                "text": "new row for relation \"items\" violates check constraint \"amount_positive\"\nDETAIL:  Failing row contains (2, -1)."
              },
              "rows": [
                [
                  1,
                  10
                ],
                [
                  2,
                  1
                ]
              ],
              "statuses": {
                "after_error": "IDLE",
                "after_valid": "IDLE"
              }
            },
            "schema": "c23514_check_constraint_insert",
            "status": "passed"
          }
        ]
      }
    }
  ]
}
