{
  "schema": 1,
  "sqlstate": "42804",
  "condition_name": "datatype_mismatch",
  "runner": "scripts/verify_cases.py",
  "targets": {
    "latest": {
      "binary": "Homebrew PostgreSQL 18.6",
      "required": true
    },
    "pg10": {
      "image": "postgres:10",
      "required": true
    }
  },
  "cases": [
    {
      "id": "default_type_mismatch",
      "versions": [
        "10",
        "18"
      ],
      "preconditions": [
        "A runner-owned disposable target is provisioned."
      ],
      "trigger": "Define an integer column whose default expression is explicitly text.",
      "assertions": [
        "SQLSTATE is 42804 with the type mismatch and rewrite/cast hint",
        "The failed autocommit session remains IDLE",
        "A matching integer default can be inserted and read back"
      ],
      "repair": "Make the expression type match the column or add a deliberate, valid cast; input-value errors such as 22P02 are a different path.",
      "cleanup": "Drop the runner schema and its table."
    }
  ],
  "evidence_status": "authored",
  "snippets": [
    {
      "id": "default_type_mismatch",
      "case_id": "default_type_mismatch",
      "language": "sql",
      "statements": {
        "trigger": "CREATE TABLE syntax_schema.mismatch_table (value integer DEFAULT 'x'::text)",
        "repair_create": "CREATE TABLE syntax_schema.mismatch_table (value integer DEFAULT 1)",
        "repair_insert": "INSERT INTO syntax_schema.mismatch_table DEFAULT VALUES",
        "verify": "SELECT value FROM syntax_schema.mismatch_table"
      }
    }
  ],
  "runtime": [
    {
      "id": "runtime.syntax2-42804-latest.latest",
      "run_id": "syntax2-42804-latest",
      "target": "latest",
      "status": "passed",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "summary_sha256": "fcb8c1ffc71d0018c42bdc6cae3aa4cfcbf7b0783a058c899ff5c7e1d3f7ca6a",
      "raw_sha256": "80e9dbafb1a45c96b8a6e104b704a9536fef7c7e93e208b7e47663df03846c12",
      "case_manifest": {
        "id": "manifest.42804",
        "kind": "local_artifact",
        "source_role": "case_manifest",
        "sha256": "05413a4b7a2096ddd8755efc43e853413838383fc32d89f73c769917ebada6f9"
      },
      "snippet_registry": {
        "id": "snippet-registry.42804",
        "kind": "local_artifact",
        "source_role": "snippet_registry",
        "sha256": "614d9ba401e016a67127a3daf08dd1b70139fa54ef26037c32ad668a5c40873b"
      },
      "environment": {
        "TimeZone": "Asia/Shanghai",
        "backend_pid": 29825,
        "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": [
        "default_type_mismatch"
      ],
      "observed": {
        "connection_autocommit": true,
        "diagnostic": {
          "column_name": null,
          "constraint_name": null,
          "context": null,
          "datatype_name": null,
          "exception_type": "DatatypeMismatch",
          "internal_position": null,
          "internal_query": null,
          "message_detail": null,
          "message_hint": "You will need to rewrite or cast the expression.",
          "message_primary": "column \"value\" is of type integer but default expression is of type text",
          "schema_name": null,
          "severity": "ERROR",
          "severity_nonlocalized": "ERROR",
          "source_file": "heap.c",
          "source_function": "cookDefault",
          "source_line": "3420",
          "sqlstate": "42804",
          "statement_position": null,
          "table_name": null,
          "text": "column \"value\" is of type integer but default expression is of type text\nHINT:  You will need to rewrite or cast the expression."
        },
        "failed_status": "IDLE",
        "repair_status": "IDLE",
        "repair_value": 1
      },
      "assertions": [
        {
          "expected": "42804",
          "name": "42804 SQLSTATE",
          "observed": "42804",
          "passed": true
        },
        {
          "expected": "ERROR",
          "name": "42804 ERROR severity",
          "observed": "ERROR",
          "passed": true
        },
        {
          "expected": "column \"value\" is of type integer but default expression is of type text",
          "name": "42804 primary diagnostic",
          "observed": "column \"value\" is of type integer but default expression is of type text",
          "passed": true
        },
        {
          "expected": "You will need to rewrite or cast the expression.",
          "name": "datatype mismatch preserves the cast/rewrite hint",
          "observed": "You will need to rewrite or cast the expression.",
          "passed": true
        },
        {
          "expected": "IDLE",
          "name": "datatype mismatch leaves autocommit session usable",
          "observed": "IDLE",
          "passed": true
        },
        {
          "expected": {
            "status": "IDLE",
            "value": 1
          },
          "name": "matching default expression repairs table definition",
          "observed": {
            "error": true,
            "status": "IDLE",
            "value": 1
          },
          "passed": true
        }
      ],
      "cleanup": {
        "errors": [],
        "passed": true
      },
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 29825,
          "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": "42804",
                "name": "42804 SQLSTATE",
                "observed": "42804",
                "passed": true
              },
              {
                "expected": "ERROR",
                "name": "42804 ERROR severity",
                "observed": "ERROR",
                "passed": true
              },
              {
                "expected": "column \"value\" is of type integer but default expression is of type text",
                "name": "42804 primary diagnostic",
                "observed": "column \"value\" is of type integer but default expression is of type text",
                "passed": true
              },
              {
                "expected": "You will need to rewrite or cast the expression.",
                "name": "datatype mismatch preserves the cast/rewrite hint",
                "observed": "You will need to rewrite or cast the expression.",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "datatype mismatch leaves autocommit session usable",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": {
                  "status": "IDLE",
                  "value": 1
                },
                "name": "matching default expression repairs table definition",
                "observed": {
                  "error": true,
                  "status": "IDLE",
                  "value": 1
                },
                "passed": true
              }
            ],
            "case_id": "default_type_mismatch",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.009,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "DatatypeMismatch",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": "You will need to rewrite or cast the expression.",
                "message_primary": "column \"value\" is of type integer but default expression is of type text",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "heap.c",
                "source_function": "cookDefault",
                "source_line": "3420",
                "sqlstate": "42804",
                "statement_position": null,
                "table_name": null,
                "text": "column \"value\" is of type integer but default expression is of type text\nHINT:  You will need to rewrite or cast the expression."
              },
              "failed_status": "IDLE",
              "repair_status": "IDLE",
              "repair_value": 1
            },
            "schema": "c42804_default_type_mismatch",
            "status": "passed"
          }
        ]
      }
    },
    {
      "id": "runtime.syntax2-42804-pg10.pg10",
      "run_id": "syntax2-42804-pg10",
      "target": "pg10",
      "status": "passed",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "summary_sha256": "43c38fc6ac8845bc5b72d1897be9d20f82528f70a495a25debdab32152c90783",
      "raw_sha256": "a04f19ae59de9d4656844f1fbebe08820ab41fb6a6f0ed512f6ea3a712410d47",
      "case_manifest": {
        "id": "manifest.42804",
        "kind": "local_artifact",
        "source_role": "case_manifest",
        "sha256": "05413a4b7a2096ddd8755efc43e853413838383fc32d89f73c769917ebada6f9"
      },
      "snippet_registry": {
        "id": "snippet-registry.42804",
        "kind": "local_artifact",
        "source_role": "snippet_registry",
        "sha256": "614d9ba401e016a67127a3daf08dd1b70139fa54ef26037c32ad668a5c40873b"
      },
      "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": [
        "default_type_mismatch"
      ],
      "observed": {
        "connection_autocommit": true,
        "diagnostic": {
          "column_name": null,
          "constraint_name": null,
          "context": null,
          "datatype_name": null,
          "exception_type": "DatatypeMismatch",
          "internal_position": null,
          "internal_query": null,
          "message_detail": null,
          "message_hint": "You will need to rewrite or cast the expression.",
          "message_primary": "column \"value\" is of type integer but default expression is of type text",
          "schema_name": null,
          "severity": "ERROR",
          "severity_nonlocalized": "ERROR",
          "source_file": "heap.c",
          "source_function": "cookDefault",
          "source_line": "2686",
          "sqlstate": "42804",
          "statement_position": null,
          "table_name": null,
          "text": "column \"value\" is of type integer but default expression is of type text\nHINT:  You will need to rewrite or cast the expression."
        },
        "failed_status": "IDLE",
        "repair_status": "IDLE",
        "repair_value": 1
      },
      "assertions": [
        {
          "expected": "42804",
          "name": "42804 SQLSTATE",
          "observed": "42804",
          "passed": true
        },
        {
          "expected": "ERROR",
          "name": "42804 ERROR severity",
          "observed": "ERROR",
          "passed": true
        },
        {
          "expected": "column \"value\" is of type integer but default expression is of type text",
          "name": "42804 primary diagnostic",
          "observed": "column \"value\" is of type integer but default expression is of type text",
          "passed": true
        },
        {
          "expected": "You will need to rewrite or cast the expression.",
          "name": "datatype mismatch preserves the cast/rewrite hint",
          "observed": "You will need to rewrite or cast the expression.",
          "passed": true
        },
        {
          "expected": "IDLE",
          "name": "datatype mismatch leaves autocommit session usable",
          "observed": "IDLE",
          "passed": true
        },
        {
          "expected": {
            "status": "IDLE",
            "value": 1
          },
          "name": "matching default expression repairs table definition",
          "observed": {
            "error": true,
            "status": "IDLE",
            "value": 1
          },
          "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": "42804",
                "name": "42804 SQLSTATE",
                "observed": "42804",
                "passed": true
              },
              {
                "expected": "ERROR",
                "name": "42804 ERROR severity",
                "observed": "ERROR",
                "passed": true
              },
              {
                "expected": "column \"value\" is of type integer but default expression is of type text",
                "name": "42804 primary diagnostic",
                "observed": "column \"value\" is of type integer but default expression is of type text",
                "passed": true
              },
              {
                "expected": "You will need to rewrite or cast the expression.",
                "name": "datatype mismatch preserves the cast/rewrite hint",
                "observed": "You will need to rewrite or cast the expression.",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "datatype mismatch leaves autocommit session usable",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": {
                  "status": "IDLE",
                  "value": 1
                },
                "name": "matching default expression repairs table definition",
                "observed": {
                  "error": true,
                  "status": "IDLE",
                  "value": 1
                },
                "passed": true
              }
            ],
            "case_id": "default_type_mismatch",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.015,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "DatatypeMismatch",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": "You will need to rewrite or cast the expression.",
                "message_primary": "column \"value\" is of type integer but default expression is of type text",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "heap.c",
                "source_function": "cookDefault",
                "source_line": "2686",
                "sqlstate": "42804",
                "statement_position": null,
                "table_name": null,
                "text": "column \"value\" is of type integer but default expression is of type text\nHINT:  You will need to rewrite or cast the expression."
              },
              "failed_status": "IDLE",
              "repair_status": "IDLE",
              "repair_value": 1
            },
            "schema": "c42804_default_type_mismatch",
            "status": "passed"
          }
        ]
      }
    }
  ]
}
