{
  "schema": 1,
  "sqlstate": "42846",
  "condition_name": "cannot_coerce",
  "runner": "scripts/verify_cases.py",
  "targets": {
    "latest": {
      "binary": "Homebrew PostgreSQL 18.6",
      "required": true
    },
    "pg10": {
      "image": "postgres:10",
      "required": true
    }
  },
  "cases": [
    {
      "id": "impossible_cast",
      "versions": [
        "10",
        "18"
      ],
      "preconditions": [
        "A runner-owned disposable target is provisioned."
      ],
      "trigger": "Explicitly cast an integer expression to date.",
      "assertions": [
        "SQLSTATE is 42846 with cannot cast type integer to date",
        "The failed autocommit session remains IDLE",
        "A date-typed literal returns the intended date"
      ],
      "repair": "Use a source type with a documented cast or construct a value in the target type; changing an input string is not the same as making an impossible type cast valid.",
      "cleanup": "Close the runner connection; no persistent objects are created."
    }
  ],
  "evidence_status": "authored",
  "snippets": [
    {
      "id": "impossible_cast",
      "case_id": "impossible_cast",
      "language": "sql",
      "statements": {
        "trigger": "SELECT 1::integer::date",
        "repair": "SELECT DATE '2026-01-01'"
      }
    }
  ],
  "runtime": [
    {
      "id": "runtime.syntax2-42846-latest.latest",
      "run_id": "syntax2-42846-latest",
      "target": "latest",
      "status": "passed",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "summary_sha256": "8cf837715d9427be31279c7369844643aa7a0c7fb9a06d1cda21dc864910ad9c",
      "raw_sha256": "af5badedd6f7288418b8d1458b0f50c1fbf8c8a4e1ebe0320df63427071dcff2",
      "case_manifest": {
        "id": "manifest.42846",
        "kind": "local_artifact",
        "source_role": "case_manifest",
        "sha256": "a73e8b18ce3528c5b74b6770883b20751d98545f358e3fcd64094017f704834d"
      },
      "snippet_registry": {
        "id": "snippet-registry.42846",
        "kind": "local_artifact",
        "source_role": "snippet_registry",
        "sha256": "8c6c979d843ec594c5a9f0a4cc6660713b468a48814f71bd5a4eb8c539aa4c11"
      },
      "environment": {
        "TimeZone": "Asia/Shanghai",
        "backend_pid": 30179,
        "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": [
        "impossible_cast"
      ],
      "observed": {
        "connection_autocommit": true,
        "diagnostic": {
          "column_name": null,
          "constraint_name": null,
          "context": null,
          "datatype_name": null,
          "exception_type": "CannotCoerce",
          "internal_position": null,
          "internal_query": null,
          "message_detail": null,
          "message_hint": null,
          "message_primary": "cannot cast type integer to date",
          "schema_name": null,
          "severity": "ERROR",
          "severity_nonlocalized": "ERROR",
          "source_file": "parse_expr.c",
          "source_function": "transformTypeCast",
          "source_line": "2787",
          "sqlstate": "42846",
          "statement_position": "18",
          "table_name": null,
          "text": "cannot cast type integer to date\nLINE 1: SELECT 1::integer::date\n                         ^"
        },
        "failed_status": "IDLE",
        "repair_status": "IDLE",
        "repair_value": "2026-01-01"
      },
      "assertions": [
        {
          "expected": "42846",
          "name": "42846 SQLSTATE",
          "observed": "42846",
          "passed": true
        },
        {
          "expected": "ERROR",
          "name": "42846 ERROR severity",
          "observed": "ERROR",
          "passed": true
        },
        {
          "expected": "cannot cast type integer to date",
          "name": "42846 primary diagnostic",
          "observed": "cannot cast type integer to date",
          "passed": true
        },
        {
          "expected": "IDLE",
          "name": "cannot-coerce error leaves autocommit session usable",
          "observed": "IDLE",
          "passed": true
        },
        {
          "expected": {
            "status": "IDLE",
            "value": "2026-01-01"
          },
          "name": "a date-typed literal repairs the expression",
          "observed": {
            "error": true,
            "status": "IDLE",
            "value": "2026-01-01"
          },
          "passed": true
        }
      ],
      "cleanup": {
        "errors": [],
        "passed": true
      },
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 30179,
          "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": "42846",
                "name": "42846 SQLSTATE",
                "observed": "42846",
                "passed": true
              },
              {
                "expected": "ERROR",
                "name": "42846 ERROR severity",
                "observed": "ERROR",
                "passed": true
              },
              {
                "expected": "cannot cast type integer to date",
                "name": "42846 primary diagnostic",
                "observed": "cannot cast type integer to date",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "cannot-coerce error leaves autocommit session usable",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": {
                  "status": "IDLE",
                  "value": "2026-01-01"
                },
                "name": "a date-typed literal repairs the expression",
                "observed": {
                  "error": true,
                  "status": "IDLE",
                  "value": "2026-01-01"
                },
                "passed": true
              }
            ],
            "case_id": "impossible_cast",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.007,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "CannotCoerce",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": "cannot cast type integer to date",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "parse_expr.c",
                "source_function": "transformTypeCast",
                "source_line": "2787",
                "sqlstate": "42846",
                "statement_position": "18",
                "table_name": null,
                "text": "cannot cast type integer to date\nLINE 1: SELECT 1::integer::date\n                         ^"
              },
              "failed_status": "IDLE",
              "repair_status": "IDLE",
              "repair_value": "2026-01-01"
            },
            "schema": "c42846_impossible_cast",
            "status": "passed"
          }
        ]
      }
    },
    {
      "id": "runtime.syntax2-42846-pg10.pg10",
      "run_id": "syntax2-42846-pg10",
      "target": "pg10",
      "status": "passed",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "summary_sha256": "008de923b32d0df980d398c51d793a1d422be893b830f3728af333a5889bad9b",
      "raw_sha256": "d13f9e7e174d96b9c470b3520adcbe008e9b6a4b3abf755700e80c3f6d32705f",
      "case_manifest": {
        "id": "manifest.42846",
        "kind": "local_artifact",
        "source_role": "case_manifest",
        "sha256": "a73e8b18ce3528c5b74b6770883b20751d98545f358e3fcd64094017f704834d"
      },
      "snippet_registry": {
        "id": "snippet-registry.42846",
        "kind": "local_artifact",
        "source_role": "snippet_registry",
        "sha256": "8c6c979d843ec594c5a9f0a4cc6660713b468a48814f71bd5a4eb8c539aa4c11"
      },
      "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",
          "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": [
        "impossible_cast"
      ],
      "observed": {
        "connection_autocommit": true,
        "diagnostic": {
          "column_name": null,
          "constraint_name": null,
          "context": null,
          "datatype_name": null,
          "exception_type": "CannotCoerce",
          "internal_position": null,
          "internal_query": null,
          "message_detail": null,
          "message_hint": null,
          "message_primary": "cannot cast type integer to date",
          "schema_name": null,
          "severity": "ERROR",
          "severity_nonlocalized": "ERROR",
          "source_file": "parse_expr.c",
          "source_function": "transformTypeCast",
          "source_line": "2735",
          "sqlstate": "42846",
          "statement_position": "18",
          "table_name": null,
          "text": "cannot cast type integer to date\nLINE 1: SELECT 1::integer::date\n                         ^"
        },
        "failed_status": "IDLE",
        "repair_status": "IDLE",
        "repair_value": "2026-01-01"
      },
      "assertions": [
        {
          "expected": "42846",
          "name": "42846 SQLSTATE",
          "observed": "42846",
          "passed": true
        },
        {
          "expected": "ERROR",
          "name": "42846 ERROR severity",
          "observed": "ERROR",
          "passed": true
        },
        {
          "expected": "cannot cast type integer to date",
          "name": "42846 primary diagnostic",
          "observed": "cannot cast type integer to date",
          "passed": true
        },
        {
          "expected": "IDLE",
          "name": "cannot-coerce error leaves autocommit session usable",
          "observed": "IDLE",
          "passed": true
        },
        {
          "expected": {
            "status": "IDLE",
            "value": "2026-01-01"
          },
          "name": "a date-typed literal repairs the expression",
          "observed": {
            "error": true,
            "status": "IDLE",
            "value": "2026-01-01"
          },
          "passed": true
        }
      ],
      "cleanup": {
        "errors": [],
        "passed": true
      },
      "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",
            "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": "42846",
                "name": "42846 SQLSTATE",
                "observed": "42846",
                "passed": true
              },
              {
                "expected": "ERROR",
                "name": "42846 ERROR severity",
                "observed": "ERROR",
                "passed": true
              },
              {
                "expected": "cannot cast type integer to date",
                "name": "42846 primary diagnostic",
                "observed": "cannot cast type integer to date",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "cannot-coerce error leaves autocommit session usable",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": {
                  "status": "IDLE",
                  "value": "2026-01-01"
                },
                "name": "a date-typed literal repairs the expression",
                "observed": {
                  "error": true,
                  "status": "IDLE",
                  "value": "2026-01-01"
                },
                "passed": true
              }
            ],
            "case_id": "impossible_cast",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.016,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "CannotCoerce",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": "cannot cast type integer to date",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "parse_expr.c",
                "source_function": "transformTypeCast",
                "source_line": "2735",
                "sqlstate": "42846",
                "statement_position": "18",
                "table_name": null,
                "text": "cannot cast type integer to date\nLINE 1: SELECT 1::integer::date\n                         ^"
              },
              "failed_status": "IDLE",
              "repair_status": "IDLE",
              "repair_value": "2026-01-01"
            },
            "schema": "c42846_impossible_cast",
            "status": "passed"
          }
        ]
      }
    }
  ]
}
