{
  "slug": "sqlite-generated-column",
  "term": "SQLite generated column",
  "aliases": [
    "computed column",
    "STORED generated column",
    "VIRTUAL generated column"
  ],
  "definition": "A SQLite generated column derives its value from an expression over columns in the same row, with STORED values materialized on writes and VIRTUAL values evaluated on reads.",
  "note": "Generated expressions require deterministic scalar functions. Generated columns are absent from table_info but included in table_xinfo, whose hidden flag is 2 for virtual and 3 for stored. [generated] [table-xinfo]\n\nIn seven controlled SQLite 3.45.1 observations, changing score(x) from x to x+100 left old STORED values in reopened, reindexed and backup copies while VIRTUAL values changed; integrity_check returned ok throughout. Python SQL-dump replay under the new callback recomputed stored values. Preserve or deliberately migrate the function implementation as well as the database. [experiment]\n\nA further three-case UNIQUE replay experiment changed the callback so two inputs generated the same key. Replay stopped at the second INSERT but left the first in an active transaction; explicit rollback discarded the import, whereas deliberately committing preserved an incomplete one-row table that passed integrity_check. Treat replay success and application completeness as separate acceptance checks. [replay]\n\nA separate two-build experiment copied historical stale STORED values through completed backup, VACUUM INTO and compatible-schema INSERT SELECT star; integrity_check returned ok. Explicit ordinary-column projection recomputed the fixture. Indexed VIRTUAL inconsistencies survived the same raw-transfer paths but were detected by full checking. SQL syntax alone does not establish recomputation. [recovery-copy]\n\nOn recorded 3.45.1 and 3.54.1 readers, inherited stale STORED values passed full checks through read-only and read/write connections. Blocking new BLOB writes does not revalidate old files. Recomputing a value also does not restore its historical input. [legacy-checks]",
  "related": [
    "sqlite-expression-index",
    "sqlite-integrity-check",
    "backup-verification"
  ],
  "citations": [
    {
      "id": "generated",
      "title": "SQLite: Generated Columns",
      "url": "https://sqlite.org/gencol.html",
      "accessed": "2026-10-18"
    },
    {
      "id": "table-xinfo",
      "title": "SQLite PRAGMA table_xinfo: generated-column flags",
      "url": "https://sqlite.org/pragma.html#pragma_table_xinfo",
      "accessed": "2026-10-18"
    },
    {
      "id": "experiment",
      "title": "Hesela: SQLite stored generated-column controls",
      "url": "https://hesela.com/analyses/sqlite-index-runtime-dependencies/#stored-columns",
      "accessed": "2026-10-18"
    },
    {
      "id": "replay",
      "title": "Hesela: generated-column replay failures and transaction finalization",
      "url": "https://hesela.com/analyses/sqlite-index-runtime-dependencies/#replay-errors",
      "accessed": "2026-10-18"
    },
    {
      "id": "recovery-copy",
      "title": "Hesela: native recovery-copy controls, exact build scope and source synthesis",
      "url": "https://hesela.com/analyses/sqlite-index-runtime-dependencies/#recovery-copy",
      "accessed": "2026-10-23"
    },
    {
      "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"
    }
  ],
  "status": "shipping",
  "advantages": [],
  "limitations": [
    "Changing a function implementation can violate the schema's determinism assumption; the controls are not a newly discovered SQLite defect."
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-03",
  "provenance": [
    "Seven designed cases on SQLite 3.45.1 and Python 3.12.3; closed DELETE-journal fixtures, no failure-rate estimate. Full rows, scripts and runtime identity are linked from the analysis.",
    "Three additional UNIQUE-constrained SQL replay controls on the same runtime; explicit rollback and deliberately unsafe commit after an error. Not a crash test or general import-tool guarantee.",
    "160 synthetic recovery configurations on recorded SQLite 3.45.1 and 3.54.1 builds; old-build seeds, closed files, two source journal settings. Not an incidence estimate or new vulnerability. Exact captures and reproduction package linked from the analysis.",
    "Supplement: 24 outcomes from six actions, two reader builds and two closed journal configurations, with explicit RO/RW checks. Corroborates the earlier mechanism on the same host; no independent replication, incidence or crash test."
  ]
}
