{
  "schemaVersion": 1,
  "slug": "postgresql-toast-read-coverage",
  "title": "PostgreSQL TOAST: which checks reach the value?",
  "summary": "A controlled one-bit change survives row counts, length and prefix reads; page checksums and trusted payload comparisons reveal different coverage boundaries.",
  "published": "2026-10-21",
  "updated": "2026-10-21",
  "method": "Three executions of the same PostgreSQL 16.15 harness on synthetic uncompressed bytea values; separate checksum-on/off clusters, clean controls and a one-bit offline mutation.",
  "limits": [
    "One payload and selected bit on one Linux host, not a corruption-frequency estimate or exhaustive campaign.",
    "No compressed values, concurrency, restore operation, power loss or hardware failure was tested.",
    "The third execution repeats the same harness; it is not independent peer review."
  ],
  "citations": [
    {
      "id": "toast",
      "title": "PostgreSQL 16: TOAST, on-disk storage and EXTERNAL strategy",
      "url": "https://www.postgresql.org/docs/16/storage-toast.html",
      "accessed": "2026-10-21"
    },
    {
      "id": "amcheck",
      "title": "PostgreSQL 16: amcheck, verify_heapam and verification limits",
      "url": "https://www.postgresql.org/docs/16/amcheck.html",
      "accessed": "2026-10-21"
    },
    {
      "id": "pgamcheck",
      "title": "PostgreSQL 16: pg_amcheck, relation selection and TOAST-pointer exclusions",
      "url": "https://www.postgresql.org/docs/16/app-pgamcheck.html",
      "accessed": "2026-10-21"
    },
    {
      "id": "pgchecksums",
      "title": "PostgreSQL 16: pg_checksums, clean-shutdown requirement",
      "url": "https://www.postgresql.org/docs/16/app-pgchecksums.html",
      "accessed": "2026-10-21"
    },
    {
      "id": "length",
      "title": "PostgreSQL REL_16_15: varlena.c, byteaoctetlen and bytea_substring",
      "url": "https://github.com/postgres/postgres/blob/7d3e000c5961a544302072058a1184e9a588837b/src/backend/utils/adt/varlena.c",
      "accessed": "2026-10-21"
    },
    {
      "id": "size",
      "title": "PostgreSQL REL_16_15: detoast.c, toast_raw_datum_size",
      "url": "https://github.com/postgres/postgres/blob/7d3e000c5961a544302072058a1184e9a588837b/src/backend/access/common/detoast.c",
      "accessed": "2026-10-21"
    },
    {
      "id": "fast08",
      "title": "Bairavasundaram et al. An Analysis of Data Corruption in the Storage Stack. FAST 2008, sections 2.2, 3.2 and 4.5",
      "url": "https://static.usenix.org/events/fast08/tech/full_papers/bairavasundaram/bairavasundaram_html/index.html",
      "accessed": "2026-10-21"
    }
  ],
  "evidenceType": "measured-api-behavior",
  "generatedAt": "2026-10-20T23:05:21.666875+00:00",
  "executions": 3,
  "freshClusters": 6,
  "rowCount": 132,
  "onlineProbes": 120,
  "offlineInvocations": 12,
  "matrix": [
    {
      "probe": "row_count",
      "label": "Row count",
      "on": "1 row",
      "off": "1 row"
    },
    {
      "probe": "byte_length",
      "label": "Byte length",
      "on": "24,045 bytes",
      "off": "24,045 bytes"
    },
    {
      "probe": "prefix",
      "label": "First 32 bytes",
      "on": "Unchanged prefix",
      "off": "Unchanged prefix"
    },
    {
      "probe": "whole_sha256",
      "label": "Full-value SHA-256",
      "on": "Read/check error",
      "off": "Different digest"
    },
    {
      "probe": "heap_without_toast",
      "label": "Heap check without TOAST",
      "on": "No report rows",
      "off": "No report rows"
    },
    {
      "probe": "heap_with_toast",
      "label": "Heap check with TOAST",
      "on": "Read/check error",
      "off": "No report rows"
    },
    {
      "probe": "amcheck_default",
      "label": "pg_amcheck: both routes",
      "on": "Read/check error",
      "off": "Exit 0"
    },
    {
      "probe": "amcheck_no_pointers",
      "label": "pg_amcheck: dependent relation only",
      "on": "Read/check error",
      "off": "Exit 0"
    },
    {
      "probe": "amcheck_no_dependent_toast",
      "label": "pg_amcheck: pointers only",
      "on": "Read/check error",
      "off": "Exit 0"
    },
    {
      "probe": "amcheck_neither",
      "label": "pg_amcheck: neither route",
      "on": "Exit 0",
      "off": "Exit 0"
    },
    {
      "probe": "pg_checksums",
      "label": "Offline page checksums",
      "on": "One bad checksum",
      "off": "Refuses: not enabled"
    }
  ],
  "environment": {
    "python": "3.12.3",
    "system": "Linux",
    "kernel": "6.8.0-146-generic",
    "architecture": "x86_64",
    "postgres": "postgres (PostgreSQL) 16.15 (Ubuntu 16.15-0ubuntu0.24.04.1)",
    "psql": "psql (PostgreSQL) 16.15 (Ubuntu 16.15-0ubuntu0.24.04.1)",
    "pg_amcheck": "pg_amcheck (PostgreSQL) 16.15 (Ubuntu 16.15-0ubuntu0.24.04.1)",
    "postgres_sha256": "201d8daff9a5bd9df70b820471b965c39f5a776d677f395232c477d051270722"
  },
  "license": "CC0-1.0 for original Hesela code and synthetic observations; upstream sources retain their licenses.",
  "licenseUrl": "https://creativecommons.org/publicdomain/zero/1.0/",
  "humanPage": "https://hesela.com/analyses/postgresql-toast-read-coverage/",
  "sourceUrl": "https://hesela.com/analyses/postgresql-toast-read-coverage/",
  "downloadPath": "/data/datasets/postgresql-toast-read-coverage.csv",
  "rawPath": "/research/postgresql-toast-coverage/results-1.json",
  "codePath": "/research/postgresql-toast-coverage/experiment.py",
  "generatorPath": "/research/postgresql-toast-coverage/build-publication.py",
  "columns": [
    {
      "name": "repetition",
      "type": "integer",
      "description": "Execution 1 or 2; 3 is the review rerun using the same harness."
    },
    {
      "name": "checksums",
      "type": "boolean",
      "description": "Checksum setting in a separately initialized cluster."
    },
    {
      "name": "state",
      "type": "string",
      "description": "Clean fixture or the subsequent one-bit damaged fixture."
    },
    {
      "name": "phase",
      "type": "string",
      "description": "Online probe or offline checksum utility."
    },
    {
      "name": "probe",
      "type": "string",
      "description": "Stable probe identifier; raw JSON contains SQL/options."
    },
    {
      "name": "returncode",
      "type": "integer",
      "description": "Process exit code, not an application-content verdict."
    },
    {
      "name": "matches_expected",
      "type": "boolean-or-null",
      "description": "Only successful full-value hashes: true/false comparison with the trusted input; blank otherwise."
    }
  ],
  "sha256": {
    "experiment.py": "d4aa5f39f8b4a995e170557eb5555a1175c75409fe8d36c17497a96db4e26b98",
    "test_experiment.py": "6bc0debef6cc6eb3ed88872c970e69dcfba21b7c55800e2593a450488fb5f914",
    "verify.py": "fea7d15a9046d4a7d2bddea8e6a1ac3086ae3b7c90c14904d2221eabeab7a573",
    "summary.json": "d51fb6616f542171d4924f5a1891bdfafcd6d1c1049129bb960a4038b7ae3a62",
    "source-review.md": "1bdbef88d753e98d54ede02755a4eaef1467ad9018dd51f575129660852a95a8",
    "README.md": "e00cd52894a120be557ec8c326a2f87eaad306a4c31aefb748bbf1159e7541f3",
    "publication-README.md": "38940be7ab366c28cbf4f7ce7d37b8250acb7270baa8b996daf9229c97fc18c1",
    "publication.json": "dd9eea8ad1494a986364e8e9a90a3218612d041c60a9794177656547eded9bc0",
    "build-publication.py": "3b75df9cf9e9870a9d89ae637bda47da992e424de32ab034b0f6b1abd20a1d49",
    "test_publication.py": "b733d5ca4cd997ea7f7b1179e7da4c5cc885166732b27676a96e5c151e435ff9",
    "results-1.json": "c711a18ca0307276e745938087b0afd3ad0ad42525f1c5a5b74f448699bab64c",
    "results-2.json": "f397a28dc21eff167fdc6395017f81806f84fb6dd0ec153d5e820cddaa898910",
    "review-run.json": "a335fb0311b122841b717d446aee250034eeefe928fbf725703c2eb25a10514d"
  }
}
