{
  "slug": "sqlite-integrity-check",
  "term": "SQLite integrity_check",
  "aliases": [
    "PRAGMA integrity_check"
  ],
  "definition": "SQLite integrity_check examines database structure and selected constraints without checking foreign-key relationships.",
  "note": "A result of ok does not validate declared references or application meaning. Use a separate foreign_key_check for declared relationships. [pragma]\n\nTen completed backup fixtures preserved all source rows and returned ok; four retained orphan references and only two met the fixed owner requirement. These are deliberately constructed inputs, not naturally occurring backup failures. [experiment]\n\nIn supplemental two-build legacy-file controls, an internally consistent index on a stale STORED hex(payload) value passed full checks through both read-only and read/write connections. An explicit stored IS NOT hex(payload) predicate found the mismatch. This is not the indexed VIRTUAL case, where full checking detects a stale index, nor evidence that all constraints are unchecked. Upgrading a writer and accepting inherited application values are different tasks. [legacy-checks] [generated-recovery]\n\nTelemetry: a completed backup retained NULL for both bound NaN and absence, while reopened databases passed integrity_check. Four rows had two non-NULL values: AVG returned 20 ms for those two values. COUNT(x) cannot recover missingness reasons. A pre-binding status field retained them, without proving the classification correct. [telemetry-evidence]\n\nPartial sums: in a signed-infinity control, direct SUM returned NULL but explicitly summing group subtotals returned 10. The outer aggregate skipped the indeterminate subtotal. Preserve contributing counts and invalid/empty/valid state. [aggregate-null] [telemetry-evidence] [telemetry-replay]",
  "related": [
    "sqlite-foreign-key-check",
    "backup-verification",
    "sqlite-online-backup",
    "sqlite-quick-check",
    "sqlite-expression-index",
    "fts5-integrity-check",
    "sqlite-rtree",
    "sqlite-generated-column"
  ],
  "citations": [
    {
      "id": "pragma",
      "title": "SQLite PRAGMA integrity_check",
      "url": "https://www.sqlite.org/pragma.html#pragma_integrity_check",
      "accessed": "2026-10-17"
    },
    {
      "id": "experiment",
      "title": "Hesela: executed SQLite validation-boundary cases",
      "url": "https://hesela.com/analyses/backup-verification-is-not-a-restore-test/#sqlite-validation-boundaries",
      "accessed": "2026-10-17"
    },
    {
      "id": "legacy-checks",
      "title": "Hesela: supplemental legacy generated-value controls, exact builds and RO/RW checks",
      "url": "https://hesela.dev/research/sqlite-blob-generated-recovery/README.md",
      "accessed": "2026-11-03"
    },
    {
      "id": "generated-recovery",
      "title": "Hesela: recovery-copy distinctions for STORED values and VIRTUAL indexes",
      "url": "https://hesela.com/analyses/sqlite-index-runtime-dependencies/#recovery-copy",
      "accessed": "2026-11-03"
    },
    {
      "id": "aggregate-null",
      "title": "SQLite aggregate functions: non-NULL populations and indeterminate signed-infinity sums",
      "url": "https://www.sqlite.org/lang_aggfunc.html",
      "accessed": "2026-11-06"
    },
    {
      "id": "telemetry-evidence",
      "title": "Hesela: native telemetry observations, versions, evidence pointers and limits",
      "url": "https://hesela.dev/research/sqlite-telemetry-provenance/summary.json",
      "accessed": "2026-11-06"
    },
    {
      "id": "telemetry-replay",
      "title": "Hesela: offline SQLite telemetry replay package and source ledger",
      "url": "https://hesela.dev/research/sqlite-telemetry-provenance/package.zip",
      "accessed": "2026-11-06"
    }
  ],
  "status": "shipping",
  "advantages": [],
  "limitations": [],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-06",
  "provenance": [
    "Ten designed cases using SQLite 3.45.1 with DELETE/WAL sources and read-only reopened destinations; no crash, failure-rate or full-application recovery claim.",
    "Supplemental fixed two-row legacy files, six recovery actions, two recorded reader builds and two closed source journal configurations: 24 outcomes, explicit RO/RW checks. Same-host corroboration of earlier evidence, not independent replication, incidence or a crash test.",
    "Additional telemetry observations use Python SQLite 3.45.1 and 3.53.1 on selected inputs, not a random sample. No physical device, power-loss event or concurrent writer was tested; the Backblaze audit is unchanged. [telemetry-evidence]",
    "The signed-infinity control is not a valid latency workload, an optimizer-rewrite claim or a general summation guarantee. [telemetry-evidence]"
  ]
}
