{
  "schema": 1,
  "sqlstate": "08003",
  "condition_name": "connection_does_not_exist",
  "runner": "scripts/verify_cases.py",
  "targets": {
    "latest": {
      "binary": "Homebrew PostgreSQL 18.6",
      "required": true
    },
    "pg10": {
      "image": "postgres:10",
      "required": true
    }
  },
  "cases": [
    {
      "id": "dblink_missing_connection",
      "versions": [
        "10",
        "18"
      ],
      "preconditions": [
        "A runner-owned disposable target is provisioned."
      ],
      "trigger": "Look up a dblink name that was never opened.",
      "assertions": [
        "The selected server diagnostic has the expected SQLSTATE",
        "The selected recovery/probe assertions pass",
        "Runner-owned resources are cleaned up"
      ],
      "repair": "Follow the case-specific repair statements and verify the resulting state.",
      "cleanup": "Drop the case schema with an owner connection."
    }
  ],
  "evidence_status": "authored",
  "snippets": [
    {
      "id": "dblink_missing_connection",
      "case_id": "dblink_missing_connection",
      "language": "sql",
      "statements": {
        "create_extension": "CREATE EXTENSION IF NOT EXISTS dblink",
        "missing": "SELECT dblink_disconnect('missing_remote')",
        "open": "SELECT dblink_connect('working_remote', 'host=runner_host port=runner_port dbname=runner_db user=runner_user connect_timeout=5')",
        "remote_probe": "SELECT * FROM dblink('working_remote', 'SELECT 1') AS result(value integer)",
        "disconnect": "SELECT dblink_disconnect('working_remote')",
        "probe": "SELECT 1"
      }
    }
  ],
  "runtime": [
    {
      "id": "runtime.08003-dblink-repair-latest.latest",
      "kind": "runtime_observation",
      "run_id": "08003-dblink-repair-latest",
      "target": "latest",
      "status": "passed",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "cases": [
        "dblink_missing_connection"
      ],
      "summary_sha256": "6700d31ff0162861b00242d054665fc0644487d1f78eb3b7c663c1e95b077046",
      "raw_sha256": "170d804e9fc4fe7b1ef2d7cf85ebb16c451144178d275b8bd8720934f7c584b5",
      "case_manifest_sha256": "8ea12e9b1ce6097559da1eb41f880d946356274d5147465ea33b96190104a8ae",
      "snippet_registry": {
        "sha256": "a5f2c89616e3b311eec9b54a7d2a5c454bfad02b53896f3596bf5f963354d4a0"
      },
      "environment": {
        "target_kind": "latest",
        "server_version": "18.6 (Homebrew)",
        "server_version_num": "180006",
        "machine": "arm64",
        "platform": "macOS-26.6.2-arm64-arm-64bit-Mach-O",
        "libpq_version": "18.6",
        "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)]",
        "locale": "en_US.UTF-8",
        "lc_messages": "C",
        "log_destination": "csvlog,jsonlog"
      },
      "observed": {
        "connection_autocommit": true,
        "connection_scope": "server-side dblink name lookup followed by a real runner-owned dblink handle",
        "dblink_repair": {
          "disconnected": "OK",
          "opened": "OK",
          "remote_probe": 1
        },
        "diagnostic": {
          "column_name": null,
          "constraint_name": null,
          "context": null,
          "datatype_name": null,
          "exception_type": "ConnectionDoesNotExist",
          "internal_position": null,
          "internal_query": null,
          "message_detail": null,
          "message_hint": null,
          "message_primary": "connection \"missing_remote\" not available",
          "schema_name": null,
          "severity": "ERROR",
          "severity_nonlocalized": "ERROR",
          "source_file": "dblink.c",
          "source_function": "dblink_conn_not_avail",
          "source_line": "195",
          "sqlstate": "08003",
          "statement_position": null,
          "table_name": null,
          "text": "connection \"missing_remote\" not available"
        },
        "probe": 1,
        "statuses": {
          "after_error": "IDLE",
          "final": "IDLE"
        }
      },
      "assertions": [
        {
          "expected": "08003",
          "name": "missing dblink connection SQLSTATE",
          "observed": "08003",
          "passed": true
        },
        {
          "expected": "connection not available",
          "name": "missing dblink connection diagnostic",
          "observed": "connection \"missing_remote\" not available",
          "passed": true
        },
        {
          "expected": "IDLE",
          "name": "lookup failure leaves session usable",
          "observed": "IDLE",
          "passed": true
        },
        {
          "expected": "OK and remote SELECT 1",
          "name": "missing handle path can open a real handle",
          "observed": {
            "open": "OK",
            "remote": 1
          },
          "passed": true
        },
        {
          "expected": "OK",
          "name": "real handle is disconnected",
          "observed": "OK",
          "passed": true
        },
        {
          "expected": "SELECT 1 and IDLE",
          "name": "owner session remains usable",
          "observed": {
            "probe": 1,
            "status": "IDLE"
          },
          "passed": true
        }
      ],
      "cleanup": {
        "case": {
          "errors": [],
          "passed": true
        }
      },
      "limits": "Disposable runner-owned target only; this is a bounded mechanism case, not a guarantee for every client or network path.",
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 88190,
          "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": "08003",
                "name": "missing dblink connection SQLSTATE",
                "observed": "08003",
                "passed": true
              },
              {
                "expected": "connection not available",
                "name": "missing dblink connection diagnostic",
                "observed": "connection \"missing_remote\" not available",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "lookup failure leaves session usable",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": "OK and remote SELECT 1",
                "name": "missing handle path can open a real handle",
                "observed": {
                  "open": "OK",
                  "remote": 1
                },
                "passed": true
              },
              {
                "expected": "OK",
                "name": "real handle is disconnected",
                "observed": "OK",
                "passed": true
              },
              {
                "expected": "SELECT 1 and IDLE",
                "name": "owner session remains usable",
                "observed": {
                  "probe": 1,
                  "status": "IDLE"
                },
                "passed": true
              }
            ],
            "case_id": "dblink_missing_connection",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.02,
            "observed": {
              "connection_autocommit": true,
              "connection_scope": "server-side dblink name lookup followed by a real runner-owned dblink handle",
              "dblink_repair": {
                "disconnected": "OK",
                "opened": "OK",
                "remote_probe": 1
              },
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "ConnectionDoesNotExist",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": "connection \"missing_remote\" not available",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "dblink.c",
                "source_function": "dblink_conn_not_avail",
                "source_line": "195",
                "sqlstate": "08003",
                "statement_position": null,
                "table_name": null,
                "text": "connection \"missing_remote\" not available"
              },
              "probe": 1,
              "statuses": {
                "after_error": "IDLE",
                "final": "IDLE"
              }
            },
            "schema": "c08003_dblink_missing_connection",
            "status": "passed"
          }
        ]
      }
    },
    {
      "id": "runtime.08003-dblink-repair-pg10c.pg10",
      "kind": "runtime_observation",
      "run_id": "08003-dblink-repair-pg10c",
      "target": "pg10",
      "status": "passed",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "cases": [
        "dblink_missing_connection"
      ],
      "summary_sha256": "e0145f317869154f9641cbd77e935ed8a985716fdcdf889d0a0f5566de022ce7",
      "raw_sha256": "8484128ab10388de521a0dfab08f2313ec0f53d6ec447583f5fd3b8cd3a51fcf",
      "case_manifest_sha256": "8ea12e9b1ce6097559da1eb41f880d946356274d5147465ea33b96190104a8ae",
      "snippet_registry": {
        "sha256": "a5f2c89616e3b311eec9b54a7d2a5c454bfad02b53896f3596bf5f963354d4a0"
      },
      "environment": {
        "target_kind": "pg10",
        "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
        "server_version_num": "100021",
        "machine": "arm64",
        "platform": "macOS-26.6.2-arm64-arm-64bit-Mach-O",
        "libpq_version": "18.6",
        "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)]",
        "locale": "en_US.UTF-8",
        "lc_messages": "en_US.utf8",
        "log_destination": "csvlog"
      },
      "observed": {
        "connection_autocommit": true,
        "connection_scope": "server-side dblink name lookup followed by a real runner-owned dblink handle",
        "dblink_repair": {
          "disconnected": "OK",
          "opened": "OK",
          "remote_probe": 1
        },
        "diagnostic": {
          "column_name": null,
          "constraint_name": null,
          "context": null,
          "datatype_name": null,
          "exception_type": "ConnectionDoesNotExist",
          "internal_position": null,
          "internal_query": null,
          "message_detail": null,
          "message_hint": null,
          "message_primary": "connection \"missing_remote\" not available",
          "schema_name": null,
          "severity": "ERROR",
          "severity_nonlocalized": "ERROR",
          "source_file": "dblink.c",
          "source_function": "dblink_conn_not_avail",
          "source_line": "173",
          "sqlstate": "08003",
          "statement_position": null,
          "table_name": null,
          "text": "connection \"missing_remote\" not available"
        },
        "probe": 1,
        "statuses": {
          "after_error": "IDLE",
          "final": "IDLE"
        }
      },
      "assertions": [
        {
          "expected": "08003",
          "name": "missing dblink connection SQLSTATE",
          "observed": "08003",
          "passed": true
        },
        {
          "expected": "connection not available",
          "name": "missing dblink connection diagnostic",
          "observed": "connection \"missing_remote\" not available",
          "passed": true
        },
        {
          "expected": "IDLE",
          "name": "lookup failure leaves session usable",
          "observed": "IDLE",
          "passed": true
        },
        {
          "expected": "OK and remote SELECT 1",
          "name": "missing handle path can open a real handle",
          "observed": {
            "open": "OK",
            "remote": 1
          },
          "passed": true
        },
        {
          "expected": "OK",
          "name": "real handle is disconnected",
          "observed": "OK",
          "passed": true
        },
        {
          "expected": "SELECT 1 and IDLE",
          "name": "owner session remains usable",
          "observed": {
            "probe": 1,
            "status": "IDLE"
          },
          "passed": true
        }
      ],
      "cleanup": {
        "case": {
          "errors": [],
          "passed": true
        }
      },
      "limits": "Disposable runner-owned target only; this is a bounded mechanism case, not a guarantee for every client or network path.",
      "image": "postgres:10",
      "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": "08003",
                "name": "missing dblink connection SQLSTATE",
                "observed": "08003",
                "passed": true
              },
              {
                "expected": "connection not available",
                "name": "missing dblink connection diagnostic",
                "observed": "connection \"missing_remote\" not available",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "lookup failure leaves session usable",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": "OK and remote SELECT 1",
                "name": "missing handle path can open a real handle",
                "observed": {
                  "open": "OK",
                  "remote": 1
                },
                "passed": true
              },
              {
                "expected": "OK",
                "name": "real handle is disconnected",
                "observed": "OK",
                "passed": true
              },
              {
                "expected": "SELECT 1 and IDLE",
                "name": "owner session remains usable",
                "observed": {
                  "probe": 1,
                  "status": "IDLE"
                },
                "passed": true
              }
            ],
            "case_id": "dblink_missing_connection",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.016,
            "observed": {
              "connection_autocommit": true,
              "connection_scope": "server-side dblink name lookup followed by a real runner-owned dblink handle",
              "dblink_repair": {
                "disconnected": "OK",
                "opened": "OK",
                "remote_probe": 1
              },
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "ConnectionDoesNotExist",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": "connection \"missing_remote\" not available",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "dblink.c",
                "source_function": "dblink_conn_not_avail",
                "source_line": "173",
                "sqlstate": "08003",
                "statement_position": null,
                "table_name": null,
                "text": "connection \"missing_remote\" not available"
              },
              "probe": 1,
              "statuses": {
                "after_error": "IDLE",
                "final": "IDLE"
              }
            },
            "schema": "c08003_dblink_missing_connection",
            "status": "passed"
          }
        ]
      }
    }
  ]
}
