{
  "schema": 1,
  "sqlstate": "23502",
  "condition_name": "not_null_violation",
  "runner": "scripts/verify_cases.py",
  "targets": {
    "latest": {
      "binary": "Homebrew PostgreSQL 18.6",
      "required": true
    },
    "pg10": {
      "image": "postgres:10",
      "required": true
    }
  },
  "cases": [
    {
      "id": "not_null_insert",
      "versions": [
        "10",
        "18"
      ],
      "preconditions": [
        "The target column is declared NOT NULL",
        "The insert supplies a NULL value"
      ],
      "trigger": "Insert a row with NULL in the NOT NULL column.",
      "assertions": [
        "SQLSTATE is 23502",
        "The column and relation are identified",
        "A valid row can be inserted after the error"
      ],
      "repair": "Provide a valid value or change the schema only after confirming the data contract; do not silently coerce a missing value without business meaning.",
      "cleanup": "Drop the case schema with an owner connection."
    }
  ],
  "evidence_status": "authored",
  "snippets": [
    {
      "id": "not_null_insert",
      "case_id": "not_null_insert",
      "language": "sql",
      "statements": {
        "create": "CREATE TABLE items(id integer PRIMARY KEY, label text NOT NULL)",
        "seed": "INSERT INTO items VALUES (1, 'seed')",
        "trigger": "INSERT INTO items VALUES (2, NULL)",
        "repair": "INSERT INTO items VALUES (2, 'valid')",
        "verify": "SELECT id, label FROM items ORDER BY id"
      }
    }
  ],
  "runtime": [
    {
      "id": "runtime.23502-batch1-latest-20260909.latest",
      "run_id": "23502-batch1-latest-20260909",
      "target": "latest",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "status": "passed",
      "cases": [
        "not_null_insert"
      ],
      "summary_sha256": "a224ad3252f2d40d8f1685a490fe4efe6cd8deb95515b5533c9002323387576a",
      "raw_sha256": "52cde4d2906d14030040c5034ac22d1331109e60ddc32bc7331ab11666986787",
      "snippet_registry": {
        "sha256": "f701e32a0e9214d6c88deabcda99981c288cae0f176d1dcaf383863c3942f8e0"
      },
      "case_manifest": {
        "sha256": "2a097af0bb10072da2300cf9a5626d13027ed5773bad917fd333b489f4b4f109"
      },
      "observed": {
        "sqlstate": "23502",
        "primary": "null value in column \"label\" of relation \"items\" violates not-null constraint",
        "detail": "Failing row contains (2, null).",
        "column": "label",
        "table": "items",
        "status_after_error": "IDLE",
        "rows": [
          [
            1,
            "seed"
          ],
          [
            2,
            "valid"
          ]
        ]
      },
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 33340,
          "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": "23502",
                "name": "not-null sqlstate",
                "observed": "23502",
                "passed": true
              },
              {
                "expected": "label/items",
                "name": "column and relation are identified",
                "observed": {
                  "column": "label",
                  "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,
                    "seed"
                  ],
                  [
                    2,
                    "valid"
                  ]
                ],
                "passed": true
              }
            ],
            "case_id": "not_null_insert",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.012,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": "label",
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "NotNullViolation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": "Failing row contains (2, null).",
                "message_hint": null,
                "message_primary": "null value in column \"label\" of relation \"items\" violates not-null constraint",
                "schema_name": "c23502_not_null_insert",
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "execMain.c",
                "source_function": "ReportNotNullViolationError",
                "source_line": "2219",
                "sqlstate": "23502",
                "statement_position": null,
                "table_name": "items",
                "text": "null value in column \"label\" of relation \"items\" violates not-null constraint\nDETAIL:  Failing row contains (2, null)."
              },
              "rows": [
                [
                  1,
                  "seed"
                ],
                [
                  2,
                  "valid"
                ]
              ],
              "statuses": {
                "after_error": "IDLE",
                "after_valid": "IDLE"
              }
            },
            "schema": "c23502_not_null_insert",
            "status": "passed"
          }
        ]
      }
    },
    {
      "id": "runtime.23502-batch1-pg10-20260909.pg10",
      "run_id": "23502-batch1-pg10-20260909",
      "target": "pg10",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "status": "passed",
      "cases": [
        "not_null_insert"
      ],
      "summary_sha256": "1449b9682de2708ea83657d8356bf28b716f5a6f27c52f26e12b2eb9e63a6bbc",
      "raw_sha256": "c1c8501748a78a9e9553ff3c7887b9f60c7a78973efefc6cc952374ec19f007c",
      "snippet_registry": {
        "sha256": "f701e32a0e9214d6c88deabcda99981c288cae0f176d1dcaf383863c3942f8e0"
      },
      "case_manifest": {
        "sha256": "2a097af0bb10072da2300cf9a5626d13027ed5773bad917fd333b489f4b4f109"
      },
      "observed": {
        "sqlstate": "23502",
        "primary": "null value in column \"label\" violates not-null constraint",
        "detail": "Failing row contains (2, null).",
        "column": "label",
        "table": "items",
        "status_after_error": "IDLE",
        "rows": [
          [
            1,
            "seed"
          ],
          [
            2,
            "valid"
          ]
        ]
      },
      "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": "23502",
                "name": "not-null sqlstate",
                "observed": "23502",
                "passed": true
              },
              {
                "expected": "label/items",
                "name": "column and relation are identified",
                "observed": {
                  "column": "label",
                  "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,
                    "seed"
                  ],
                  [
                    2,
                    "valid"
                  ]
                ],
                "passed": true
              }
            ],
            "case_id": "not_null_insert",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.021,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": "label",
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "NotNullViolation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": "Failing row contains (2, null).",
                "message_hint": null,
                "message_primary": "null value in column \"label\" violates not-null constraint",
                "schema_name": "c23502_not_null_insert",
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "execMain.c",
                "source_function": "ExecConstraints",
                "source_line": "2021",
                "sqlstate": "23502",
                "statement_position": null,
                "table_name": "items",
                "text": "null value in column \"label\" violates not-null constraint\nDETAIL:  Failing row contains (2, null)."
              },
              "rows": [
                [
                  1,
                  "seed"
                ],
                [
                  2,
                  "valid"
                ]
              ],
              "statuses": {
                "after_error": "IDLE",
                "after_valid": "IDLE"
              }
            },
            "schema": "c23502_not_null_insert",
            "status": "passed"
          }
        ]
      }
    }
  ]
}
