{
  "schema": 1,
  "sqlstate": "55006",
  "condition_name": "object_in_use",
  "runner": "scripts/verify_cases.py",
  "targets": {
    "latest": {
      "binary": "Homebrew PostgreSQL 18.6",
      "required": true
    },
    "pg10": {
      "image": "postgres:10",
      "required": true
    }
  },
  "cases": [
    {
      "id": "active_cursor_drop",
      "versions": [
        "10",
        "18"
      ],
      "preconditions": [
        "A runner-owned empty table exists; a cursor can still hold the relation in active use.",
        "The table cursor and DROP run on one backend session."
      ],
      "trigger": "Declare and use a cursor on a table in an explicit transaction, then attempt to DROP that table from the same session.",
      "assertions": [
        "SQLSTATE is 55006 with ERROR severity",
        "The diagnostic says the table is used by active queries in this session",
        "The failed DROP leaves the explicit transaction INERROR",
        "ROLLBACK releases the transaction-owned cursor and the same session can DROP the table"
      ],
      "repair": "Rollback the failed transaction to release its cursor and then repeat the DDL; do not hide an active-session dependency with CASCADE.",
      "cleanup": "Close all runner connections and drop the case schema with an owner connection."
    }
  ],
  "evidence_status": "authored",
  "snippets": [
    {
      "id": "active_cursor_drop",
      "case_id": "active_cursor_drop",
      "language": "sql",
      "statements": {
        "create": "CREATE TABLE cursor_drop_table(id integer PRIMARY KEY)",
        "begin": "BEGIN",
        "declare": "DECLARE active_cursor CURSOR FOR SELECT id FROM cursor_drop_table",
        "fetch": "FETCH active_cursor",
        "drop": "DROP TABLE cursor_drop_table",
        "rollback": "ROLLBACK",
        "drop_repair": "DROP TABLE cursor_drop_table",
        "verify": "SELECT to_regclass('cursor_drop_table_regclass')"
      }
    }
  ],
  "runtime": [
    {
      "id": "runtime.ops-55006-latest-2.latest",
      "run_id": "ops-55006-latest-2",
      "target": "latest",
      "status": "passed",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "summary_sha256": "877c2f2da43a65ff859b4ee888da5a19d357c8ee0341216c0359c65b1997cb74",
      "raw_sha256": "1338c25d5b5349269a08a72f37669e6dce5801bbd4864c135586a10c0c836a0b",
      "case_manifest": {
        "id": "manifest.55006",
        "kind": "local_artifact",
        "source_role": "case_manifest",
        "sha256": "ba1f597f1250488a70187cce54fb5ee3b5271cc59c8bf14ccb89fc2580155577"
      },
      "snippet_registry": {
        "id": "snippet-registry.55006",
        "kind": "local_artifact",
        "source_role": "snippet_registry",
        "sha256": "7df91ab045a8fe307bc2f025c17f53d6e107fa392afe2b45dbb457c42fbcd74e"
      },
      "environment": {
        "TimeZone": "Asia/Shanghai",
        "backend_pid": 43851,
        "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": "C.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": [
        "active_cursor_drop"
      ],
      "observed": {
        "connection_autocommit": true,
        "cursor": "active_cursor_9a6f4bbd",
        "diagnostic": {
          "column_name": null,
          "constraint_name": null,
          "context": null,
          "datatype_name": null,
          "exception_type": "ObjectInUse",
          "internal_position": null,
          "internal_query": null,
          "message_detail": null,
          "message_hint": null,
          "message_primary": "cannot DROP TABLE \"cursor_drop_table\" because it is being used by active queries in this session",
          "schema_name": null,
          "severity": "ERROR",
          "severity_nonlocalized": "ERROR",
          "source_file": "tablecmds.c",
          "source_function": "CheckTableNotInUse",
          "source_line": "4435",
          "sqlstate": "55006",
          "statement_position": null,
          "table_name": null,
          "text": "cannot DROP TABLE \"cursor_drop_table\" because it is being used by active queries in this session"
        },
        "repair": "ROLLBACK releases the transaction-owned cursor, then DROP TABLE succeeds on the same connection.",
        "statuses": {
          "after_error": "INERROR",
          "after_repair": "IDLE",
          "after_rollback": "IDLE",
          "before_drop": "INTRANS"
        },
        "table": "\"c55006_active_cursor_drop\".\"cursor_drop_table\""
      },
      "assertions": [
        {
          "expected": "55006",
          "name": "55006 SQLSTATE",
          "observed": "55006",
          "passed": true
        },
        {
          "expected": "ERROR",
          "name": "55006 ERROR severity",
          "observed": "ERROR",
          "passed": true
        },
        {
          "expected": "cannot drop ... because it is being used by active queries in this session",
          "name": "active cursor blocks table drop",
          "observed": "cannot DROP TABLE \"cursor_drop_table\" because it is being used by active queries in this session",
          "passed": true
        },
        {
          "expected": "INTRANS",
          "name": "cursor transaction is active before DDL",
          "observed": "INTRANS",
          "passed": true
        },
        {
          "expected": "INERROR",
          "name": "failed DROP aborts transaction",
          "observed": "INERROR",
          "passed": true
        },
        {
          "expected": "IDLE",
          "name": "rollback releases cursor and transaction",
          "observed": "IDLE",
          "passed": true
        },
        {
          "expected": {
            "remaining": null,
            "status": "IDLE"
          },
          "name": "released cursor permits same-session DROP",
          "observed": {
            "remaining": null,
            "status": "IDLE"
          },
          "passed": true
        }
      ],
      "cleanup": {
        "errors": [],
        "passed": true
      },
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 43851,
          "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": "C.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": "55006",
                "name": "55006 SQLSTATE",
                "observed": "55006",
                "passed": true
              },
              {
                "expected": "ERROR",
                "name": "55006 ERROR severity",
                "observed": "ERROR",
                "passed": true
              },
              {
                "expected": "cannot drop ... because it is being used by active queries in this session",
                "name": "active cursor blocks table drop",
                "observed": "cannot DROP TABLE \"cursor_drop_table\" because it is being used by active queries in this session",
                "passed": true
              },
              {
                "expected": "INTRANS",
                "name": "cursor transaction is active before DDL",
                "observed": "INTRANS",
                "passed": true
              },
              {
                "expected": "INERROR",
                "name": "failed DROP aborts transaction",
                "observed": "INERROR",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "rollback releases cursor and transaction",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": {
                  "remaining": null,
                  "status": "IDLE"
                },
                "name": "released cursor permits same-session DROP",
                "observed": {
                  "remaining": null,
                  "status": "IDLE"
                },
                "passed": true
              }
            ],
            "case_id": "active_cursor_drop",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.011,
            "observed": {
              "connection_autocommit": true,
              "cursor": "active_cursor_9a6f4bbd",
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "ObjectInUse",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": "cannot DROP TABLE \"cursor_drop_table\" because it is being used by active queries in this session",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "tablecmds.c",
                "source_function": "CheckTableNotInUse",
                "source_line": "4435",
                "sqlstate": "55006",
                "statement_position": null,
                "table_name": null,
                "text": "cannot DROP TABLE \"cursor_drop_table\" because it is being used by active queries in this session"
              },
              "repair": "ROLLBACK releases the transaction-owned cursor, then DROP TABLE succeeds on the same connection.",
              "statuses": {
                "after_error": "INERROR",
                "after_repair": "IDLE",
                "after_rollback": "IDLE",
                "before_drop": "INTRANS"
              },
              "table": "\"c55006_active_cursor_drop\".\"cursor_drop_table\""
            },
            "schema": "c55006_active_cursor_drop",
            "status": "passed"
          }
        ]
      }
    },
    {
      "id": "runtime.ops-55006-pg10-1.pg10",
      "run_id": "ops-55006-pg10-1",
      "target": "pg10",
      "status": "passed",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "summary_sha256": "c92d34e3a4796ec4d721660566424ebcffd0dd19ab4381e22eef089267142a38",
      "raw_sha256": "e35d02729b81bf70d7f20c812d12e6049c5613254cf291dacee97f0b13c50dc5",
      "case_manifest": {
        "id": "manifest.55006",
        "kind": "local_artifact",
        "source_role": "case_manifest",
        "sha256": "ba1f597f1250488a70187cce54fb5ee3b5271cc59c8bf14ccb89fc2580155577"
      },
      "snippet_registry": {
        "id": "snippet-registry.55006",
        "kind": "local_artifact",
        "source_role": "snippet_registry",
        "sha256": "7df91ab045a8fe307bc2f025c17f53d6e107fa392afe2b45dbb457c42fbcd74e"
      },
      "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": "C.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": [
        "active_cursor_drop"
      ],
      "observed": {
        "connection_autocommit": true,
        "cursor": "active_cursor_cfa19ef4",
        "diagnostic": {
          "column_name": null,
          "constraint_name": null,
          "context": null,
          "datatype_name": null,
          "exception_type": "ObjectInUse",
          "internal_position": null,
          "internal_query": null,
          "message_detail": null,
          "message_hint": null,
          "message_primary": "cannot DROP TABLE \"cursor_drop_table\" because it is being used by active queries in this session",
          "schema_name": null,
          "severity": "ERROR",
          "severity_nonlocalized": "ERROR",
          "source_file": "tablecmds.c",
          "source_function": "CheckTableNotInUse",
          "source_line": "3077",
          "sqlstate": "55006",
          "statement_position": null,
          "table_name": null,
          "text": "cannot DROP TABLE \"cursor_drop_table\" because it is being used by active queries in this session"
        },
        "repair": "ROLLBACK releases the transaction-owned cursor, then DROP TABLE succeeds on the same connection.",
        "statuses": {
          "after_error": "INERROR",
          "after_repair": "IDLE",
          "after_rollback": "IDLE",
          "before_drop": "INTRANS"
        },
        "table": "\"c55006_active_cursor_drop\".\"cursor_drop_table\""
      },
      "assertions": [
        {
          "expected": "55006",
          "name": "55006 SQLSTATE",
          "observed": "55006",
          "passed": true
        },
        {
          "expected": "ERROR",
          "name": "55006 ERROR severity",
          "observed": "ERROR",
          "passed": true
        },
        {
          "expected": "cannot drop ... because it is being used by active queries in this session",
          "name": "active cursor blocks table drop",
          "observed": "cannot DROP TABLE \"cursor_drop_table\" because it is being used by active queries in this session",
          "passed": true
        },
        {
          "expected": "INTRANS",
          "name": "cursor transaction is active before DDL",
          "observed": "INTRANS",
          "passed": true
        },
        {
          "expected": "INERROR",
          "name": "failed DROP aborts transaction",
          "observed": "INERROR",
          "passed": true
        },
        {
          "expected": "IDLE",
          "name": "rollback releases cursor and transaction",
          "observed": "IDLE",
          "passed": true
        },
        {
          "expected": {
            "remaining": null,
            "status": "IDLE"
          },
          "name": "released cursor permits same-session DROP",
          "observed": {
            "remaining": null,
            "status": "IDLE"
          },
          "passed": true
        }
      ],
      "cleanup": {
        "errors": [],
        "passed": true
      },
      "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": "C.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": "55006",
                "name": "55006 SQLSTATE",
                "observed": "55006",
                "passed": true
              },
              {
                "expected": "ERROR",
                "name": "55006 ERROR severity",
                "observed": "ERROR",
                "passed": true
              },
              {
                "expected": "cannot drop ... because it is being used by active queries in this session",
                "name": "active cursor blocks table drop",
                "observed": "cannot DROP TABLE \"cursor_drop_table\" because it is being used by active queries in this session",
                "passed": true
              },
              {
                "expected": "INTRANS",
                "name": "cursor transaction is active before DDL",
                "observed": "INTRANS",
                "passed": true
              },
              {
                "expected": "INERROR",
                "name": "failed DROP aborts transaction",
                "observed": "INERROR",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "rollback releases cursor and transaction",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": {
                  "remaining": null,
                  "status": "IDLE"
                },
                "name": "released cursor permits same-session DROP",
                "observed": {
                  "remaining": null,
                  "status": "IDLE"
                },
                "passed": true
              }
            ],
            "case_id": "active_cursor_drop",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.017,
            "observed": {
              "connection_autocommit": true,
              "cursor": "active_cursor_cfa19ef4",
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "ObjectInUse",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": "cannot DROP TABLE \"cursor_drop_table\" because it is being used by active queries in this session",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "tablecmds.c",
                "source_function": "CheckTableNotInUse",
                "source_line": "3077",
                "sqlstate": "55006",
                "statement_position": null,
                "table_name": null,
                "text": "cannot DROP TABLE \"cursor_drop_table\" because it is being used by active queries in this session"
              },
              "repair": "ROLLBACK releases the transaction-owned cursor, then DROP TABLE succeeds on the same connection.",
              "statuses": {
                "after_error": "INERROR",
                "after_repair": "IDLE",
                "after_rollback": "IDLE",
                "before_drop": "INTRANS"
              },
              "table": "\"c55006_active_cursor_drop\".\"cursor_drop_table\""
            },
            "schema": "c55006_active_cursor_drop",
            "status": "passed"
          }
        ]
      }
    }
  ]
}
