{
  "schema": 1,
  "sqlstate": "23503",
  "condition_name": "foreign_key_violation",
  "runner": "scripts/verify_cases.py",
  "targets": {
    "latest": {
      "binary": "Homebrew PostgreSQL 18.6",
      "required": true
    },
    "pg10": {
      "image": "postgres:10",
      "required": true
    }
  },
  "cases": [
    {
      "id": "fk_insert_missing_parent",
      "versions": [
        "10",
        "18"
      ],
      "preconditions": [
        "A parent table and a child table with a NOT DEFERRABLE foreign key",
        "The referenced key is absent"
      ],
      "trigger": "Insert a child row whose parent key does not exist.",
      "assertions": [
        "SQLSTATE is 23503",
        "The foreign-key constraint and child table are identified",
        "A valid parent and child row can be committed after rollback"
      ],
      "repair": "Create or select the intended parent before inserting the child; do not disable the constraint to hide the data error.",
      "cleanup": "Drop the case schema with an owner connection."
    }
  ],
  "evidence_status": "authored",
  "snippets": [
    {
      "id": "fk_insert_missing_parent",
      "case_id": "fk_insert_missing_parent",
      "language": "sql",
      "statements": {
        "create_parent": "CREATE TABLE parents(id integer PRIMARY KEY)",
        "create_child": "CREATE TABLE children(\n    id integer PRIMARY KEY,\n    parent_id integer NOT NULL,\n    CONSTRAINT children_parent_fk FOREIGN KEY (parent_id) REFERENCES parents(id)\n)",
        "begin": "BEGIN",
        "trigger": "INSERT INTO children VALUES (1, 99)",
        "rollback": "ROLLBACK",
        "repair_begin": "BEGIN",
        "repair_parent": "INSERT INTO parents VALUES (99)",
        "repair_child": "INSERT INTO children VALUES (1, 99)",
        "commit": "COMMIT"
      }
    }
  ],
  "runtime": [
    {
      "cases": [
        "fk_insert_missing_parent"
      ],
      "id": "runtime.23503-final-20260909.latest",
      "run_id": "23503-final-20260909",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "status": "passed",
      "target": "latest",
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 98156,
          "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": "23503",
                "name": "foreign-key sqlstate",
                "observed": "23503",
                "passed": true
              },
              {
                "expected": "children",
                "name": "child table is identified",
                "observed": "children",
                "passed": true
              },
              {
                "expected": "children_parent_fk",
                "name": "constraint is identified",
                "observed": "children_parent_fk",
                "passed": true
              },
              {
                "expected": "INERROR",
                "name": "failed transaction is inerror",
                "observed": "INERROR",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "rollback restores idle",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": "one child row and IDLE",
                "name": "repair commits a valid row",
                "observed": {
                  "rows": [
                    [
                      1,
                      99
                    ]
                  ],
                  "status": "IDLE"
                },
                "passed": true
              },
              {
                "expected": "error",
                "name": "natural foreign-key error was raised",
                "observed": "error",
                "passed": true
              }
            ],
            "case_id": "fk_insert_missing_parent",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.085,
            "observed": {
              "diagnostic": {
                "column_name": null,
                "constraint_name": "children_parent_fk",
                "context": null,
                "datatype_name": null,
                "exception_type": "ForeignKeyViolation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": "Key (parent_id)=(99) is not present in table \"parents\".",
                "message_hint": null,
                "message_primary": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"",
                "schema_name": "c23503_fk_insert_missing_parent",
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "ri_triggers.c",
                "source_function": "ri_ReportViolation",
                "source_line": "2783",
                "sqlstate": "23503",
                "statement_position": null,
                "table_name": "children",
                "text": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"\nDETAIL:  Key (parent_id)=(99) is not present in table \"parents\"."
              },
              "rows": [
                [
                  1,
                  99
                ]
              ],
              "statuses": {
                "after_commit": "IDLE",
                "after_error": "INERROR",
                "after_rollback": "IDLE"
              }
            },
            "schema": "c23503_fk_insert_missing_parent",
            "status": "passed"
          }
        ]
      }
    },
    {
      "cases": [
        "fk_insert_missing_parent"
      ],
      "id": "runtime.23503-final-20260909.pg10",
      "image": "postgres@sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
      "run_id": "23503-final-20260909",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "status": "passed",
      "target": "pg10",
      "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": "23503",
                "name": "foreign-key sqlstate",
                "observed": "23503",
                "passed": true
              },
              {
                "expected": "children",
                "name": "child table is identified",
                "observed": "children",
                "passed": true
              },
              {
                "expected": "children_parent_fk",
                "name": "constraint is identified",
                "observed": "children_parent_fk",
                "passed": true
              },
              {
                "expected": "INERROR",
                "name": "failed transaction is inerror",
                "observed": "INERROR",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "rollback restores idle",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": "one child row and IDLE",
                "name": "repair commits a valid row",
                "observed": {
                  "rows": [
                    [
                      1,
                      99
                    ]
                  ],
                  "status": "IDLE"
                },
                "passed": true
              },
              {
                "expected": "error",
                "name": "natural foreign-key error was raised",
                "observed": "error",
                "passed": true
              }
            ],
            "case_id": "fk_insert_missing_parent",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.488,
            "observed": {
              "diagnostic": {
                "column_name": null,
                "constraint_name": "children_parent_fk",
                "context": null,
                "datatype_name": null,
                "exception_type": "ForeignKeyViolation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": "Key (parent_id)=(99) is not present in table \"parents\".",
                "message_hint": null,
                "message_primary": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"",
                "schema_name": "c23503_fk_insert_missing_parent",
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "ri_triggers.c",
                "source_function": "ri_ReportViolation",
                "source_line": "3266",
                "sqlstate": "23503",
                "statement_position": null,
                "table_name": "children",
                "text": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"\nDETAIL:  Key (parent_id)=(99) is not present in table \"parents\"."
              },
              "rows": [
                [
                  1,
                  99
                ]
              ],
              "statuses": {
                "after_commit": "IDLE",
                "after_error": "INERROR",
                "after_rollback": "IDLE"
              }
            },
            "schema": "c23503_fk_insert_missing_parent",
            "status": "passed"
          }
        ]
      }
    },
    {
      "cases": [
        "fk_insert_missing_parent"
      ],
      "id": "runtime.23503-explicit-begin-final-20260909.latest",
      "limits": "This rerun proves the page's explicit BEGIN around the post-rollback repair; it does not test deferred or cascading foreign keys.",
      "observed": {
        "repair_transaction": "BEGIN; INSERT parent; INSERT child; COMMIT",
        "rows": [
          [
            1,
            99
          ]
        ],
        "sqlstate": "23503",
        "status_after_error": "INERROR",
        "status_after_rollback": "IDLE"
      },
      "raw_sha256": "448d0fb4e045829071281cbf3b41be2be070932288191012cc3b766a038f0f2d",
      "run_id": "23503-explicit-begin-final-20260909",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "status": "passed",
      "summary_sha256": "dcbbb3ede7e424622275a30b8e4ddee2e8e0dc71ea46a78aba1f9c40403626a0",
      "target": "latest",
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 21205,
          "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": "23503",
                "name": "foreign-key sqlstate",
                "observed": "23503",
                "passed": true
              },
              {
                "expected": "children",
                "name": "child table is identified",
                "observed": "children",
                "passed": true
              },
              {
                "expected": "children_parent_fk",
                "name": "constraint is identified",
                "observed": "children_parent_fk",
                "passed": true
              },
              {
                "expected": "INERROR",
                "name": "failed transaction is inerror",
                "observed": "INERROR",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "rollback restores idle",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": "one child row and IDLE",
                "name": "repair commits a valid row",
                "observed": {
                  "rows": [
                    [
                      1,
                      99
                    ]
                  ],
                  "status": "IDLE"
                },
                "passed": true
              },
              {
                "expected": "error",
                "name": "natural foreign-key error was raised",
                "observed": "error",
                "passed": true
              }
            ],
            "case_id": "fk_insert_missing_parent",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.065,
            "observed": {
              "diagnostic": {
                "column_name": null,
                "constraint_name": "children_parent_fk",
                "context": null,
                "datatype_name": null,
                "exception_type": "ForeignKeyViolation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": "Key (parent_id)=(99) is not present in table \"parents\".",
                "message_hint": null,
                "message_primary": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"",
                "schema_name": "c23503_fk_insert_missing_parent",
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "ri_triggers.c",
                "source_function": "ri_ReportViolation",
                "source_line": "2783",
                "sqlstate": "23503",
                "statement_position": null,
                "table_name": "children",
                "text": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"\nDETAIL:  Key (parent_id)=(99) is not present in table \"parents\"."
              },
              "rows": [
                [
                  1,
                  99
                ]
              ],
              "statuses": {
                "after_commit": "IDLE",
                "after_error": "INERROR",
                "after_rollback": "IDLE"
              }
            },
            "schema": "c23503_fk_insert_missing_parent",
            "status": "passed"
          }
        ]
      }
    },
    {
      "cases": [
        "fk_insert_missing_parent"
      ],
      "id": "runtime.23503-explicit-begin-final-20260909.pg10",
      "image": "postgres@sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
      "limits": "This rerun proves the page's explicit BEGIN around the post-rollback repair; it does not test deferred or cascading foreign keys.",
      "observed": {
        "repair_transaction": "BEGIN; INSERT parent; INSERT child; COMMIT",
        "rows": [
          [
            1,
            99
          ]
        ],
        "sqlstate": "23503",
        "status_after_error": "INERROR",
        "status_after_rollback": "IDLE"
      },
      "raw_sha256": "0d3f8a56d5b50bb184ce791c5c88db1e1ddac4f43ba220829a773796c044f58e",
      "run_id": "23503-explicit-begin-final-20260909",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "status": "passed",
      "summary_sha256": "c92079153f22913d9a75ccf5dbbe19d4983c75f553572cdc10e755d3fc8b943e",
      "target": "pg10",
      "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": "23503",
                "name": "foreign-key sqlstate",
                "observed": "23503",
                "passed": true
              },
              {
                "expected": "children",
                "name": "child table is identified",
                "observed": "children",
                "passed": true
              },
              {
                "expected": "children_parent_fk",
                "name": "constraint is identified",
                "observed": "children_parent_fk",
                "passed": true
              },
              {
                "expected": "INERROR",
                "name": "failed transaction is inerror",
                "observed": "INERROR",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "rollback restores idle",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": "one child row and IDLE",
                "name": "repair commits a valid row",
                "observed": {
                  "rows": [
                    [
                      1,
                      99
                    ]
                  ],
                  "status": "IDLE"
                },
                "passed": true
              },
              {
                "expected": "error",
                "name": "natural foreign-key error was raised",
                "observed": "error",
                "passed": true
              }
            ],
            "case_id": "fk_insert_missing_parent",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.042,
            "observed": {
              "diagnostic": {
                "column_name": null,
                "constraint_name": "children_parent_fk",
                "context": null,
                "datatype_name": null,
                "exception_type": "ForeignKeyViolation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": "Key (parent_id)=(99) is not present in table \"parents\".",
                "message_hint": null,
                "message_primary": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"",
                "schema_name": "c23503_fk_insert_missing_parent",
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "ri_triggers.c",
                "source_function": "ri_ReportViolation",
                "source_line": "3266",
                "sqlstate": "23503",
                "statement_position": null,
                "table_name": "children",
                "text": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"\nDETAIL:  Key (parent_id)=(99) is not present in table \"parents\"."
              },
              "rows": [
                [
                  1,
                  99
                ]
              ],
              "statuses": {
                "after_commit": "IDLE",
                "after_error": "INERROR",
                "after_rollback": "IDLE"
              }
            },
            "schema": "c23503_fk_insert_missing_parent",
            "status": "passed"
          }
        ]
      }
    },
    {
      "cases": [
        "fk_insert_missing_parent"
      ],
      "id": "runtime.23503-registry-final-20260909.latest",
      "observed": {
        "message_detail": "Key (parent_id)=(99) is not present in table \"parents\".",
        "message_primary": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"",
        "rows": [
          [
            1,
            99
          ]
        ],
        "source": "ri_triggers.c / ri_ReportViolation / line 2783",
        "sqlstate": "23503",
        "statuses": {
          "after_commit": "IDLE",
          "after_error": "INERROR",
          "after_rollback": "IDLE"
        }
      },
      "raw_sha256": "977b16fea3508fc6efef5a9d353500ae0036dfa28bab4e857eba86167a5b52af",
      "run_id": "23503-registry-final-20260909",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "snippet_registry": {
        "sha256": "63d0f78a47023e343cf8b38f4168021e68ccdd875bb64f35b5e42e68394779e3"
      },
      "status": "passed",
      "summary_sha256": "301bd9183ceb223bd5898315316ab5c666a89dc10c5b48333e54bcdafcab873a",
      "target": "latest",
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 28787,
          "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": "23503",
                "name": "foreign-key sqlstate",
                "observed": "23503",
                "passed": true
              },
              {
                "expected": "children",
                "name": "child table is identified",
                "observed": "children",
                "passed": true
              },
              {
                "expected": "children_parent_fk",
                "name": "constraint is identified",
                "observed": "children_parent_fk",
                "passed": true
              },
              {
                "expected": "INERROR",
                "name": "failed transaction is inerror",
                "observed": "INERROR",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "rollback restores idle",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": "one child row and IDLE",
                "name": "repair commits a valid row",
                "observed": {
                  "rows": [
                    [
                      1,
                      99
                    ]
                  ],
                  "status": "IDLE"
                },
                "passed": true
              },
              {
                "expected": "error",
                "name": "natural foreign-key error was raised",
                "observed": "error",
                "passed": true
              }
            ],
            "case_id": "fk_insert_missing_parent",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.014,
            "observed": {
              "diagnostic": {
                "column_name": null,
                "constraint_name": "children_parent_fk",
                "context": null,
                "datatype_name": null,
                "exception_type": "ForeignKeyViolation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": "Key (parent_id)=(99) is not present in table \"parents\".",
                "message_hint": null,
                "message_primary": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"",
                "schema_name": "c23503_fk_insert_missing_parent",
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "ri_triggers.c",
                "source_function": "ri_ReportViolation",
                "source_line": "2783",
                "sqlstate": "23503",
                "statement_position": null,
                "table_name": "children",
                "text": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"\nDETAIL:  Key (parent_id)=(99) is not present in table \"parents\"."
              },
              "rows": [
                [
                  1,
                  99
                ]
              ],
              "statuses": {
                "after_commit": "IDLE",
                "after_error": "INERROR",
                "after_rollback": "IDLE"
              }
            },
            "schema": "c23503_fk_insert_missing_parent",
            "status": "passed"
          }
        ]
      }
    },
    {
      "cases": [
        "fk_insert_missing_parent"
      ],
      "id": "runtime.23503-registry-final-20260909.pg10",
      "image": "postgres@sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
      "observed": {
        "message_detail": "Key (parent_id)=(99) is not present in table \"parents\".",
        "message_primary": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"",
        "rows": [
          [
            1,
            99
          ]
        ],
        "source": "ri_triggers.c / ri_ReportViolation / line 3266",
        "sqlstate": "23503",
        "statuses": {
          "after_commit": "IDLE",
          "after_error": "INERROR",
          "after_rollback": "IDLE"
        }
      },
      "raw_sha256": "02bc2125919383ed4e9847d7cdf45e3ca235b325c5c36fa9d9e1984d27a45c5d",
      "run_id": "23503-registry-final-20260909",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "snippet_registry": {
        "sha256": "63d0f78a47023e343cf8b38f4168021e68ccdd875bb64f35b5e42e68394779e3"
      },
      "status": "passed",
      "summary_sha256": "0aba93166977cc979499f62acee75df0f0b86587e3b0309795da0de2476209de",
      "target": "pg10",
      "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": "23503",
                "name": "foreign-key sqlstate",
                "observed": "23503",
                "passed": true
              },
              {
                "expected": "children",
                "name": "child table is identified",
                "observed": "children",
                "passed": true
              },
              {
                "expected": "children_parent_fk",
                "name": "constraint is identified",
                "observed": "children_parent_fk",
                "passed": true
              },
              {
                "expected": "INERROR",
                "name": "failed transaction is inerror",
                "observed": "INERROR",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "rollback restores idle",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": "one child row and IDLE",
                "name": "repair commits a valid row",
                "observed": {
                  "rows": [
                    [
                      1,
                      99
                    ]
                  ],
                  "status": "IDLE"
                },
                "passed": true
              },
              {
                "expected": "error",
                "name": "natural foreign-key error was raised",
                "observed": "error",
                "passed": true
              }
            ],
            "case_id": "fk_insert_missing_parent",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.024,
            "observed": {
              "diagnostic": {
                "column_name": null,
                "constraint_name": "children_parent_fk",
                "context": null,
                "datatype_name": null,
                "exception_type": "ForeignKeyViolation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": "Key (parent_id)=(99) is not present in table \"parents\".",
                "message_hint": null,
                "message_primary": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"",
                "schema_name": "c23503_fk_insert_missing_parent",
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "ri_triggers.c",
                "source_function": "ri_ReportViolation",
                "source_line": "3266",
                "sqlstate": "23503",
                "statement_position": null,
                "table_name": "children",
                "text": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"\nDETAIL:  Key (parent_id)=(99) is not present in table \"parents\"."
              },
              "rows": [
                [
                  1,
                  99
                ]
              ],
              "statuses": {
                "after_commit": "IDLE",
                "after_error": "INERROR",
                "after_rollback": "IDLE"
              }
            },
            "schema": "c23503_fk_insert_missing_parent",
            "status": "passed"
          }
        ]
      }
    },
    {
      "cases": [
        "fk_insert_missing_parent"
      ],
      "id": "runtime.23503-fk-manual-final-20260909.latest",
      "limits": "This run proves that the registry BEGIN/ROLLBACK/BEGIN/COMMIT sequence executes with autocommit=True; it covers the single-parent foreign-key case.",
      "observed": {
        "connection_autocommit": true,
        "diagnostic": {
          "message_detail": "Key (parent_id)=(99) is not present in table \"parents\".",
          "message_primary": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"",
          "sqlstate": "23503"
        },
        "rows": [
          [
            1,
            99
          ]
        ],
        "statuses": {
          "after_commit": "IDLE",
          "after_error": "INERROR",
          "after_rollback": "IDLE"
        },
        "transaction_control": [
          "BEGIN",
          "ROLLBACK",
          "BEGIN",
          "COMMIT"
        ]
      },
      "raw_sha256": "442dbfa57497ce15440689645d531f493890d35e8841308ade267514244b68e5",
      "run_id": "23503-fk-manual-final-20260909",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "snippet_registry": {
        "sha256": "63d0f78a47023e343cf8b38f4168021e68ccdd875bb64f35b5e42e68394779e3"
      },
      "status": "passed",
      "summary_sha256": "e3029aab946d6e097e1c741d918937583f4ae6c8f0af24e118667b50396bcddb",
      "target": "latest",
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 8467,
          "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": "23503",
                "name": "foreign-key sqlstate",
                "observed": "23503",
                "passed": true
              },
              {
                "expected": "children",
                "name": "child table is identified",
                "observed": "children",
                "passed": true
              },
              {
                "expected": "children_parent_fk",
                "name": "constraint is identified",
                "observed": "children_parent_fk",
                "passed": true
              },
              {
                "expected": "INERROR",
                "name": "failed transaction is inerror",
                "observed": "INERROR",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "rollback restores idle",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": "one child row and IDLE",
                "name": "repair commits a valid row",
                "observed": {
                  "rows": [
                    [
                      1,
                      99
                    ]
                  ],
                  "status": "IDLE"
                },
                "passed": true
              },
              {
                "expected": "error",
                "name": "natural foreign-key error was raised",
                "observed": "error",
                "passed": true
              }
            ],
            "case_id": "fk_insert_missing_parent",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.015,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": "children_parent_fk",
                "context": null,
                "datatype_name": null,
                "exception_type": "ForeignKeyViolation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": "Key (parent_id)=(99) is not present in table \"parents\".",
                "message_hint": null,
                "message_primary": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"",
                "schema_name": "c23503_fk_insert_missing_parent",
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "ri_triggers.c",
                "source_function": "ri_ReportViolation",
                "source_line": "2783",
                "sqlstate": "23503",
                "statement_position": null,
                "table_name": "children",
                "text": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"\nDETAIL:  Key (parent_id)=(99) is not present in table \"parents\"."
              },
              "rows": [
                [
                  1,
                  99
                ]
              ],
              "statuses": {
                "after_commit": "IDLE",
                "after_error": "INERROR",
                "after_rollback": "IDLE"
              },
              "transaction_control": [
                "BEGIN",
                "ROLLBACK",
                "BEGIN",
                "COMMIT"
              ]
            },
            "schema": "c23503_fk_insert_missing_parent",
            "status": "passed"
          }
        ]
      }
    },
    {
      "cases": [
        "fk_insert_missing_parent"
      ],
      "id": "runtime.23503-fk-manual-final-20260909.pg10",
      "image": "postgres@sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
      "limits": "This run proves that the registry BEGIN/ROLLBACK/BEGIN/COMMIT sequence executes with autocommit=True; it covers the single-parent foreign-key case.",
      "observed": {
        "connection_autocommit": true,
        "diagnostic": {
          "message_detail": "Key (parent_id)=(99) is not present in table \"parents\".",
          "message_primary": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"",
          "sqlstate": "23503"
        },
        "rows": [
          [
            1,
            99
          ]
        ],
        "statuses": {
          "after_commit": "IDLE",
          "after_error": "INERROR",
          "after_rollback": "IDLE"
        },
        "transaction_control": [
          "BEGIN",
          "ROLLBACK",
          "BEGIN",
          "COMMIT"
        ]
      },
      "raw_sha256": "05887d0f8e900ab9230ac677b112119303e6de9d2bde0da7f743e1649bd213be",
      "run_id": "23503-fk-manual-final-20260909",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "snippet_registry": {
        "sha256": "63d0f78a47023e343cf8b38f4168021e68ccdd875bb64f35b5e42e68394779e3"
      },
      "status": "passed",
      "summary_sha256": "433729dd2e043777d52910ceb7ca71c437a06d0a746b42385f5a7c5411893e68",
      "target": "pg10",
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Etc/UTC",
          "backend_pid": 80,
          "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": "23503",
                "name": "foreign-key sqlstate",
                "observed": "23503",
                "passed": true
              },
              {
                "expected": "children",
                "name": "child table is identified",
                "observed": "children",
                "passed": true
              },
              {
                "expected": "children_parent_fk",
                "name": "constraint is identified",
                "observed": "children_parent_fk",
                "passed": true
              },
              {
                "expected": "INERROR",
                "name": "failed transaction is inerror",
                "observed": "INERROR",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "rollback restores idle",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": "one child row and IDLE",
                "name": "repair commits a valid row",
                "observed": {
                  "rows": [
                    [
                      1,
                      99
                    ]
                  ],
                  "status": "IDLE"
                },
                "passed": true
              },
              {
                "expected": "error",
                "name": "natural foreign-key error was raised",
                "observed": "error",
                "passed": true
              }
            ],
            "case_id": "fk_insert_missing_parent",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.02,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": "children_parent_fk",
                "context": null,
                "datatype_name": null,
                "exception_type": "ForeignKeyViolation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": "Key (parent_id)=(99) is not present in table \"parents\".",
                "message_hint": null,
                "message_primary": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"",
                "schema_name": "c23503_fk_insert_missing_parent",
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "ri_triggers.c",
                "source_function": "ri_ReportViolation",
                "source_line": "3266",
                "sqlstate": "23503",
                "statement_position": null,
                "table_name": "children",
                "text": "insert or update on table \"children\" violates foreign key constraint \"children_parent_fk\"\nDETAIL:  Key (parent_id)=(99) is not present in table \"parents\"."
              },
              "rows": [
                [
                  1,
                  99
                ]
              ],
              "statuses": {
                "after_commit": "IDLE",
                "after_error": "INERROR",
                "after_rollback": "IDLE"
              },
              "transaction_control": [
                "BEGIN",
                "ROLLBACK",
                "BEGIN",
                "COMMIT"
              ]
            },
            "schema": "c23503_fk_insert_missing_parent",
            "status": "passed"
          }
        ]
      }
    }
  ]
}
