{
  "schema": 1,
  "sqlstate": "25001",
  "condition_name": "active_sql_transaction",
  "runner": "scripts/verify_cases.py",
  "targets": {
    "latest": {
      "binary": "Homebrew PostgreSQL 18.6",
      "required": true
    },
    "pg10": {
      "image": "postgres:10",
      "required": true
    }
  },
  "cases": [
    {
      "id": "vacuum_inside_transaction",
      "versions": [
        "10",
        "18"
      ],
      "preconditions": [
        "A disposable table exists",
        "VACUUM is issued after an explicit BEGIN"
      ],
      "trigger": "Run VACUUM inside an explicit transaction block.",
      "assertions": [
        "SQLSTATE is 25001",
        "The transaction enters INERROR and rollback restores IDLE",
        "The same connection can execute a follow-up query",
        "VACUUM succeeds after rollback outside the transaction block"
      ],
      "repair": "Run transaction-control-restricted utility commands outside the transaction block; rollback the failed transaction before reuse.",
      "cleanup": "Drop the case schema with an owner connection."
    }
  ],
  "evidence_status": "authored",
  "snippets": [
    {
      "id": "vacuum_inside_transaction",
      "case_id": "vacuum_inside_transaction",
      "language": "sql",
      "statements": {
        "create": "CREATE TABLE items(id integer PRIMARY KEY, note text NOT NULL)",
        "seed": "INSERT INTO items VALUES (1, 'seed')",
        "begin": "BEGIN",
        "trigger": "VACUUM items",
        "rollback": "ROLLBACK",
        "followup": "SELECT 1 AS usable",
        "repair": "VACUUM items"
      }
    }
  ],
  "runtime": [
    {
      "id": "runtime.25001-batch1-latest2-20260909.latest",
      "run_id": "25001-batch1-latest2-20260909",
      "target": "latest",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "status": "passed",
      "cases": [
        "vacuum_inside_transaction"
      ],
      "summary_sha256": "544bd0ec303a15036fe848468ed90f2674d5c2212e520bf6be2413bfdc91f200",
      "raw_sha256": "0b164ca0eab22ccc7ad5d18ed6201072049d2b7ba49e8cc99ba65aae172e1ec0",
      "snippet_registry": {
        "sha256": "0fc4277a4e2f59e78e54a1fed1ec0efef6bd0d3bd97180e03df596677e847f03"
      },
      "case_manifest": {
        "sha256": "2a5fad757733e23fd68df23270c4b0dfe108ff9ba0e1ab33c4a69e85c46c7ce1"
      },
      "observed": {
        "sqlstate": "25001",
        "primary": "VACUUM cannot run inside a transaction block",
        "after_error": "INERROR",
        "after_rollback": "IDLE",
        "usable": 1,
        "vacuum_outside_transaction": true,
        "status_after_vacuum": "IDLE"
      },
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 48728,
          "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": "25001",
                "name": "active-transaction sqlstate",
                "observed": "25001",
                "passed": true
              },
              {
                "expected": "VACUUM cannot run inside a transaction block",
                "name": "utility restriction diagnostic",
                "observed": "VACUUM cannot run inside a transaction block",
                "passed": true
              },
              {
                "expected": "INERROR then IDLE",
                "name": "rollback restores idle",
                "observed": {
                  "after_error": "INERROR",
                  "after_rollback": "IDLE"
                },
                "passed": true
              },
              {
                "expected": "error, 1, IDLE",
                "name": "follow-up query succeeds",
                "observed": {
                  "error": true,
                  "status": "IDLE",
                  "usable": 1
                },
                "passed": true
              },
              {
                "expected": "VACUUM outside transaction and IDLE",
                "name": "utility succeeds outside transaction",
                "observed": {
                  "error": null,
                  "status": "IDLE"
                },
                "passed": true
              }
            ],
            "case_id": "vacuum_inside_transaction",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.011,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "ActiveSqlTransaction",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": "VACUUM cannot run inside a transaction block",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "xact.c",
                "source_function": "PreventInTransactionBlock",
                "source_line": "3658",
                "sqlstate": "25001",
                "statement_position": null,
                "table_name": null,
                "text": "VACUUM cannot run inside a transaction block"
              },
              "followup": 1,
              "statuses": {
                "after_error": "INERROR",
                "after_followup": "IDLE",
                "after_rollback": "IDLE",
                "after_vacuum": "IDLE"
              },
              "transaction_control": [
                "BEGIN",
                "ROLLBACK"
              ],
              "vacuum_outside_transaction": true
            },
            "schema": "c25001_vacuum_inside_transaction",
            "status": "passed"
          }
        ]
      }
    },
    {
      "id": "runtime.25001-batch1-pg10b-20260909.pg10",
      "run_id": "25001-batch1-pg10b-20260909",
      "target": "pg10",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "status": "passed",
      "cases": [
        "vacuum_inside_transaction"
      ],
      "summary_sha256": "498a7229697ff6f46b6bbb135c3f79215cbb5442e9ce2400f651bb5efb91b151",
      "raw_sha256": "1efa43a93beca206fe048de038e4538694746fece446eb129a81fb8e36aa2740",
      "snippet_registry": {
        "sha256": "0fc4277a4e2f59e78e54a1fed1ec0efef6bd0d3bd97180e03df596677e847f03"
      },
      "case_manifest": {
        "sha256": "2a5fad757733e23fd68df23270c4b0dfe108ff9ba0e1ab33c4a69e85c46c7ce1"
      },
      "observed": {
        "sqlstate": "25001",
        "primary": "VACUUM cannot run inside a transaction block",
        "after_error": "INERROR",
        "after_rollback": "IDLE",
        "usable": 1,
        "vacuum_outside_transaction": true,
        "status_after_vacuum": "IDLE"
      },
      "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": "25001",
                "name": "active-transaction sqlstate",
                "observed": "25001",
                "passed": true
              },
              {
                "expected": "VACUUM cannot run inside a transaction block",
                "name": "utility restriction diagnostic",
                "observed": "VACUUM cannot run inside a transaction block",
                "passed": true
              },
              {
                "expected": "INERROR then IDLE",
                "name": "rollback restores idle",
                "observed": {
                  "after_error": "INERROR",
                  "after_rollback": "IDLE"
                },
                "passed": true
              },
              {
                "expected": "error, 1, IDLE",
                "name": "follow-up query succeeds",
                "observed": {
                  "error": true,
                  "status": "IDLE",
                  "usable": 1
                },
                "passed": true
              },
              {
                "expected": "VACUUM outside transaction and IDLE",
                "name": "utility succeeds outside transaction",
                "observed": {
                  "error": null,
                  "status": "IDLE"
                },
                "passed": true
              }
            ],
            "case_id": "vacuum_inside_transaction",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.03,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "ActiveSqlTransaction",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": "VACUUM cannot run inside a transaction block",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "xact.c",
                "source_function": "PreventTransactionChain",
                "source_line": "3228",
                "sqlstate": "25001",
                "statement_position": null,
                "table_name": null,
                "text": "VACUUM cannot run inside a transaction block"
              },
              "followup": 1,
              "statuses": {
                "after_error": "INERROR",
                "after_followup": "IDLE",
                "after_rollback": "IDLE",
                "after_vacuum": "IDLE"
              },
              "transaction_control": [
                "BEGIN",
                "ROLLBACK"
              ],
              "vacuum_outside_transaction": true
            },
            "schema": "c25001_vacuum_inside_transaction",
            "status": "passed"
          }
        ]
      }
    }
  ]
}
