{
  "schema": 1,
  "sqlstate": "22007",
  "condition_name": "invalid_datetime_format",
  "runner": "scripts/verify_cases.py",
  "targets": {
    "latest": {
      "binary": "Homebrew PostgreSQL 18.6",
      "required": true
    },
    "pg10": {
      "image": "postgres:10",
      "required": true
    }
  },
  "cases": [
    {
      "id": "invalid_interval_format",
      "versions": [
        "10",
        "18"
      ],
      "preconditions": [],
      "trigger": "Format an interval with the date-only field ID, which is not defined for intervals.",
      "assertions": [
        "SQLSTATE is 22007",
        "The diagnostic and HINT identify the interval format restriction",
        "The failed autocommit session remains IDLE",
        "A valid interval format returns the expected value afterward"
      ],
      "repair": "Use an interval-compatible format such as DD, or convert a value whose semantics really require a calendar date before formatting.",
      "cleanup": "Drop the case schema with an owner connection."
    }
  ],
  "evidence_status": "authored",
  "snippets": [
    {
      "id": "invalid_interval_format",
      "case_id": "invalid_interval_format",
      "language": "sql",
      "statements": {
        "trigger": "SELECT to_char(interval '1 day', 'ID')",
        "repair": "SELECT to_char(interval '1 day', 'DD')"
      }
    }
  ],
  "runtime": [
    {
      "id": "runtime.22007-data1-latest.latest",
      "run_id": "22007-data1-latest",
      "target": "latest",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "status": "passed",
      "cases": [
        "invalid_interval_format"
      ],
      "summary_sha256": "5429879e671be538f513654b5c0821f227aac67f67e0b1fbb2d6c7821c0af675",
      "raw_sha256": "e1ab1c24625152560f9dc7baf091dbec22324d34bba0deea9c8048565500906a",
      "snippet_registry": {
        "sha256": "cea6f9f6a07e3371f1ebc79d2842da2c66c06750f3b39f91b7fdd57fb2b7d0a9"
      },
      "observed": {
        "sqlstate": "22007",
        "status_after_repair": "IDLE"
      },
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 16461,
          "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": "22007",
                "name": "22007 SQLSTATE",
                "observed": "22007",
                "passed": true
              },
              {
                "expected": "ERROR",
                "name": "22007 ERROR severity",
                "observed": "ERROR",
                "passed": true
              },
              {
                "expected": "invalid format specification for an interval value",
                "name": "22007 primary diagnostic",
                "observed": "invalid format specification for an interval value",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "interval format error leaves session usable",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": "Intervals are not tied to specific calendar dates.",
                "name": "interval format diagnostic preserves hint",
                "observed": "Intervals are not tied to specific calendar dates.",
                "passed": true
              },
              {
                "expected": {
                  "status": "IDLE",
                  "value": "01"
                },
                "name": "valid interval format repairs call",
                "observed": {
                  "status": "IDLE",
                  "value": "01"
                },
                "passed": true
              }
            ],
            "case_id": "invalid_interval_format",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.008,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "InvalidDatetimeFormat",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": "Intervals are not tied to specific calendar dates.",
                "message_primary": "invalid format specification for an interval value",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "formatting.c",
                "source_function": "DCH_to_char",
                "source_line": "3076",
                "sqlstate": "22007",
                "statement_position": null,
                "table_name": null,
                "text": "invalid format specification for an interval value\nHINT:  Intervals are not tied to specific calendar dates."
              },
              "failed_status": "IDLE",
              "repair_status": "IDLE",
              "repair_value": "01"
            },
            "schema": "c22007_invalid_interval_format",
            "status": "passed"
          }
        ]
      }
    },
    {
      "id": "runtime.22007-data1-pg10.pg10",
      "run_id": "22007-data1-pg10",
      "target": "pg10",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "status": "passed",
      "cases": [
        "invalid_interval_format"
      ],
      "summary_sha256": "dbc6026274c92764eb19acdc4668d1aa3bb2529a01a7ca3dbcb879cb46646f9c",
      "raw_sha256": "e9f8cef16bd8674c68fb7c518fa325adbf726e8797dc8b43da20508a0ecc41dd",
      "snippet_registry": {
        "sha256": "cea6f9f6a07e3371f1ebc79d2842da2c66c06750f3b39f91b7fdd57fb2b7d0a9"
      },
      "observed": {
        "sqlstate": "22007",
        "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": "22007",
                "name": "22007 SQLSTATE",
                "observed": "22007",
                "passed": true
              },
              {
                "expected": "ERROR",
                "name": "22007 ERROR severity",
                "observed": "ERROR",
                "passed": true
              },
              {
                "expected": "invalid format specification for an interval value",
                "name": "22007 primary diagnostic",
                "observed": "invalid format specification for an interval value",
                "passed": true
              },
              {
                "expected": "IDLE",
                "name": "interval format error leaves session usable",
                "observed": "IDLE",
                "passed": true
              },
              {
                "expected": "Intervals are not tied to specific calendar dates.",
                "name": "interval format diagnostic preserves hint",
                "observed": "Intervals are not tied to specific calendar dates.",
                "passed": true
              },
              {
                "expected": {
                  "status": "IDLE",
                  "value": "01"
                },
                "name": "valid interval format repairs call",
                "observed": {
                  "status": "IDLE",
                  "value": "01"
                },
                "passed": true
              }
            ],
            "case_id": "invalid_interval_format",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.01,
            "observed": {
              "connection_autocommit": true,
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "InvalidDatetimeFormat",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": "Intervals are not tied to specific calendar dates.",
                "message_primary": "invalid format specification for an interval value",
                "schema_name": null,
                "severity": "ERROR",
                "severity_nonlocalized": "ERROR",
                "source_file": "formatting.c",
                "source_function": "DCH_to_char",
                "source_line": "2830",
                "sqlstate": "22007",
                "statement_position": null,
                "table_name": null,
                "text": "invalid format specification for an interval value\nHINT:  Intervals are not tied to specific calendar dates."
              },
              "failed_status": "IDLE",
              "repair_status": "IDLE",
              "repair_value": "01"
            },
            "schema": "c22007_invalid_interval_format",
            "status": "passed"
          }
        ]
      }
    }
  ]
}
