{
  "schema": 1,
  "sqlstate": "22001",
  "condition_name": "string_data_right_truncation",
  "runner": "scripts/verify_cases.py",
  "targets": {
    "latest": {
      "binary": "Homebrew PostgreSQL 18.6",
      "required": true
    },
    "pg10": {
      "image": "postgres:10",
      "required": true
    }
  },
  "cases": [
    {
      "id": "varchar_width_overflow",
      "versions": [
        "10",
        "18"
      ],
      "preconditions": [],
      "trigger": "Insert a value longer than the declared varchar(3) width.",
      "assertions": [
        "SQLSTATE is 22001",
        "The varchar width diagnostic names character varying(3)",
        "The failed autocommit session remains IDLE",
        "A representable value is stored after the error"
      ],
      "repair": "Use a value that satisfies the declared width or revise the data contract explicitly; do not rely on an explicit cast that silently truncates the input.",
      "cleanup": "Drop the case schema with an owner connection."
    }
  ],
  "evidence_status": "authored",
  "snippets": [
    {
      "id": "varchar_width_overflow",
      "case_id": "varchar_width_overflow",
      "language": "sql",
      "statements": {
        "create": "CREATE TABLE varchar_limits (value varchar(3))",
        "trigger": "INSERT INTO varchar_limits VALUES ('too-long')",
        "repair": "INSERT INTO varchar_limits VALUES ('ok')",
        "verify": "SELECT value FROM varchar_limits"
      }
    }
  ],
  "runtime": [
    {
      "id": "runtime.22001-data1-latest.latest",
      "run_id": "22001-data1-latest",
      "target": "latest",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "status": "passed",
      "cases": [
        "varchar_width_overflow"
      ],
      "summary_sha256": "d4700f6daef109b19ddfddc1f70948979400702a04024dc8ba4dfbcb13cd3def",
      "raw_sha256": "722254ec20e72752649e81427aec2e21f8072d75e22960c3183883a04625c48a",
      "snippet_registry": {
        "sha256": "ee3932e6fef2bd5b1c3ff35391019940f81eb61fd72854d9c79447efceeab634"
      },
      "observed": {
        "sqlstate": "22001",
        "status_after_repair": "IDLE"
      },
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 16343,
          "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": "22001",
                "name": "22001 SQLSTATE",
                "observed": "22001",
                "passed": true
              },
              {
                "expected": "ERROR",
                "name": "22001 ERROR severity",
                "observed": "ERROR",
                "passed": true
              },
              {
                "expected": "value too long for type character varying(3)",
                "name": "22001 primary diagnostic",
                "observed": "value too long for type character varying(3)",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "varchar width error leaves session usable",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": {
                  "status": "IDLE",
                  "value": "ok"
                },
                "name": "representable varchar value repairs insert",
                "observed": {
                  "status": "IDLE",
                  "value": "ok"
                },
                "passed": true
              }
            ],
            "case_id": "varchar_width_overflow",
            "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": "StringDataRightTruncation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": "value too long for type character varying(3)",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "varchar.c",
                "source_function": "varchar",
                "source_line": "640",
                "sqlstate": "22001",
                "statement_position": null,
                "table_name": null,
                "text": "value too long for type character varying(3)"
              },
              "failed_status": "IDLE",
              "repair_status": "IDLE",
              "repair_value": "ok"
            },
            "schema": "c22001_varchar_width_overflow",
            "status": "passed"
          }
        ]
      }
    },
    {
      "id": "runtime.22001-data1-pg10.pg10",
      "run_id": "22001-data1-pg10",
      "target": "pg10",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "status": "passed",
      "cases": [
        "varchar_width_overflow"
      ],
      "summary_sha256": "0acd54978ccf0df63136d6d32d1259804d5ae52c1cf9b45a48b165bdc9f201e1",
      "raw_sha256": "da3eabf6714cfde3179b8d3456f74b7378ea4fc24b63905a8fef18acc93a8d31",
      "snippet_registry": {
        "sha256": "ee3932e6fef2bd5b1c3ff35391019940f81eb61fd72854d9c79447efceeab634"
      },
      "observed": {
        "sqlstate": "22001",
        "status_after_repair": "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",
            "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": "22001",
                "name": "22001 SQLSTATE",
                "observed": "22001",
                "passed": true
              },
              {
                "expected": "ERROR",
                "name": "22001 ERROR severity",
                "observed": "ERROR",
                "passed": true
              },
              {
                "expected": "value too long for type character varying(3)",
                "name": "22001 primary diagnostic",
                "observed": "value too long for type character varying(3)",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "varchar width error leaves session usable",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": {
                  "status": "IDLE",
                  "value": "ok"
                },
                "name": "representable varchar value repairs insert",
                "observed": {
                  "status": "IDLE",
                  "value": "ok"
                },
                "passed": true
              }
            ],
            "case_id": "varchar_width_overflow",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.014,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "StringDataRightTruncation",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": "value too long for type character varying(3)",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "varchar.c",
                "source_function": "varchar",
                "source_line": "624",
                "sqlstate": "22001",
                "statement_position": null,
                "table_name": null,
                "text": "value too long for type character varying(3)"
              },
              "failed_status": "IDLE",
              "repair_status": "IDLE",
              "repair_value": "ok"
            },
            "schema": "c22001_varchar_width_overflow",
            "status": "passed"
          }
        ]
      }
    }
  ]
}
