# An upgraded SQLite reader does not revalidate stored computations

**Evidence type:** supplemental native software controls and source synthesis,
3 November 2026. Two builds on one host, not independent researcher replication.
This package documents observations, not the deployment status of the website.

## Finding

A newer engine can reject an operation that an older engine accepted, yet still
carry forward the inconsistent values left by that older operation.

In our SQLite 3.45.1 fixture, incremental BLOB I/O changed payload AA to BA.
The built-in expression hex(payload) did not change implementation, but its
STORED result remained 4141 while fresh evaluation and the VIRTUAL column
returned 4241. An ordinary index on the stored value remained internally
consistent with that stale value. Both quick_check and integrity_check passed.

The recorded 3.54.1 build refused to open a BLOB handle on the same newly created
generated-column schema. Nevertheless, it opened the closed legacy file,
returned the stale stored result, and reported successful integrity checks.
Completed backup and VACUUM INTO copies retained that result too.

This is a recovery-validation gap demonstrated by designed controls, **not a
claim of a newly discovered SQLite defect or a current write vulnerability**.
SQLite's maintainer publicly announced generated-table BLOB-handle rejection
in August 2024, in response to a different column-position problem.
[Maintainer reply (4)](https://sqlite.org/forum/forumpost/cc82420f4cac4142)

## Relationship to already published evidence

The [existing recovery-copy section](https://hesela.com/analyses/sqlite-index-runtime-dependencies/#recovery-copy)
already establishes unchanged built-in hex, historical BLOB mutation, newer
writer rejection, and preservation through backup/VACUUM/record transfers.
This packet corroborates that result; it is not its first demonstration.
The original research draft overstated the gap by comparing only against the
earlier callback-drift section. The publication review corrected that scope.

The bounded supplement retains two exact closed seed images and executes full
checks through both read-only and read/write connections. Its STORED-only and
read-only BLOB-handle controls further delimit the tested guard. It uses a
smaller two-byte fixture, so do not merge its row values with the earlier
four-byte example or count repeated captures as independent observations.

Three acceptance questions remain separate: can the writer repeat the old
operation, do inherited stored values match their expressions, and are the
current input bytes the historical inputs the owner intends to recover?
Recomputation answers only the second question in this fixture.

## Native fixture and method

Each database contains two rows, id 1 with AA and id 2 with CC. The schema is:

~~~sql
CREATE TABLE item(
  id INTEGER PRIMARY KEY,
  payload BLOB NOT NULL,
  stored TEXT GENERATED ALWAYS AS(hex(payload)) STORED,
  virtual TEXT GENERATED ALWAYS AS(hex(payload)) VIRTUAL
);
CREATE INDEX item_index ON item(stored);
~~~

The payload precedes the virtual column. The historical wrong-column layout
from the forum is deliberately not reproduced. A STORED-only control confirms
that our stale-value result does not require a virtual column.

The 3.45.1 writer opens an explicit transaction, writes one byte B at offset 0,
closes the BLOB handle, and commits. Separate DELETE and WAL fixtures are closed
before recovery begins; the WAL writer is fully checkpointed by final close.
Two exact 12,288-byte main files and their hashes are retained. Every recovery
path starts from a fresh byte copy of one of those files.

A ctypes wrapper calls declared SQLite C APIs. Native identities, compile
options and loaded-library hashes are in the JSON captures. Neither wrapper
code nor a hand-written model computes the stored values. No package or library
was downloaded to execute the probes; the available builds were reused.

## Results

The two reader builds produce the following result for both legacy source
journal settings. Row 2 remains CC / 4343 throughout.

| Recovery action | Row 1 payload hex | STORED | VIRTUAL | Explicit mismatch | Full check RO / RW |
| --- | --- | --- | --- | --- | --- |
| Reopen | 4241 | 4141 | 4241 | id 1 | ok / ok |
| REINDEX | 4241 | 4141 | 4241 | id 1 | ok / ok |
| Completed Backup API | 4241 | 4141 | 4241 | id 1 | ok / ok |
| VACUUM INTO | 4241 | 4141 | 4241 | id 1 | ok / ok |
| Explicit input-column projection | 4241 | 4241 | 4241 | none | ok / ok |
| UPDATE payload=payload | 4241 | 4241 | 4241 | none | ok / ok |

The generated [24-row table](results.md) retains build and source identities.
[summary.json](summary.json) is machine-readable and derived from the validated
native captures, not manually transcribed.

For each of four backups, step returned SQLITE_DONE (101), remaining pages
were zero, page count was three and finish returned SQLITE_OK (0). All copies
were closed and reopened. This establishes completion in the fixture, not an
assumption from a zero error alone.
[Backup API contract](https://sqlite.org/c3ref/backup_finish.html)

A query for stored='4241' returned no row before recomputation, while evaluating
hex(payload)='4241' returned id 1. That is not an accusation that the index
misrepresents the stored column: it correctly indexes the value actually
stored. The application assumption stored=hex(payload) is what fails.

Both RO and RW diagnostics were executed on disposable copies. Main-file
hashes remained unchanged during inspection, and the original seed files are
not opened during replay. Thus the result does not depend on the separate
read-only CHECK-constraint omission discussed in the earlier BLOB work.

## Controls and version boundary

Seven creation controls run on each build:

- SQL UPDATE produces consistent 4241 values on both.
- Committed BLOB writes produce the stale value only on the tested old build.
- Explicit rollback restores the old build's original bytes and computed value.
- Read-only BLOB handles succeed on the old build but are also rejected on 3.54.1.
- Indexing payload directly rejects its writable handle on the old build.
- A STORED-only schema shows the same old-write/new-rejection distinction.
- A plain table permits the BLOB write on both builds.

The upstream generated-table guard is absent from the pinned 3.45.1 source and
present in the inspected 3.47.0 and 3.54.1 sources. It runs before the write-flag
index checks, explaining rejection of read-only handles as well. Only 3.45.1
and 3.54.1 were executed. This packet does not establish the exact first release,
every vendor backport, or behavior of every intervening version.
[Old implementation](https://github.com/sqlite/sqlite/blob/189e44dfecdc7868bb860dfb5d98eab371318c37/src/vdbeblob.c)
[3.47.0 guard](https://github.com/sqlite/sqlite/blob/f5fb820c0f4781337faf02ed871be68d13a83d94/src/vdbeblob.c#L170)
[3.54.1 guard](https://github.com/sqlite/sqlite/blob/57520227c95396ce39ba6ecaac8d475b78dd3964/src/vdbeblob.c#L171)

The current BLOB-open API page's listed restrictions did not state this
generated-table rejection when accessed. An API summary and a tested
implementation's admissible operations are not interchangeable.
[API reference](https://sqlite.org/c3ref/blob_open.html)

## Why reconstruction differs from copying

The generated-column contract distinguishes persisted results from values
computed on read. REINDEX rebuilds indexes, not the table expression history.
That makes the copied stale result and its internally correct index compatible
with the observed diagnostics.
[Generated columns](https://sqlite.org/gencol.html)
[REINDEX](https://sqlite.org/lang_reindex.html)

The explicit projection copies only id and payload into a new table:
INSERT INTO target.item(id,payload) SELECT id,payload FROM main.item.
The no-op input update instead rewrites the existing rows. Both recompute this
built-in expression, but both retain BA. Neither restores historical AA.

These are diagnostic controls, not general repair prescriptions. Recomputing
real data can change unique keys, trigger actions, or invalidate an application's
historical-value requirements. Preserve the received file, decide which inputs
are authoritative, and validate the complete intended result before migration.
A fresh hash of an already inconsistent image cannot decide that policy.

## Reproduction

Python 3.12, an available SQLite shared library and the optional sqlite3 CLI are
sufficient. No network is required after checkout. Use unused output filenames.

~~~sh
python3 -B observe.py observe --output replay-system.json
SQLITE_LIBRARY=/absolute/path/libsqlite3.so.0 python3 -B -m unittest -v test_observe
SQLITE_LIBRARY=/absolute/path/libsqlite3.so.0 python3 -B -O -m unittest -v test_observe
python3 -B cli_replay.py --output replay-cli.json
python3 -B summarize.py
~~~

Omit SQLITE_LIBRARY for the system library. The test oracle requires the retained source ID, binary SHA-256 and compile
options as well as the version; a new build requires review, not relabeling.
To recreate seeds on the recorded old build, use
python3 -B observe.py seed --seeds fresh-seeds. Existing outputs are never
overwritten by capture commands.

The standard distribution sqlite3 shell independently repeated four RO/RW
queries over disposable copies of the two seed files, agreeing with the C-API
rows and diagnostics. This is a separate entry point, not an independent engine.
The system shell could not load the separately built 3.54.1 library because that
library lacks the shell\'s required session extension symbol; no newer-shell
result is claimed. The native 3.54.1 controls above do not require that extension.

The final v2 captures add RW diagnostics and normalize temporary directory names
in operation SQL. Preliminary captures are retained as provenance, not added
as extra independent observations. The original eighteen unittest methods passed on each of two builds in normal
and optimized Python mode (72 executions). Publication review adds three
identity-rejection controls and executes the displayed acceptance query; its
fresh run has 22 methods per build/mode. Purposeful
evidence mutations check that missing cases, wrong values, wrong lineage and
incomplete backup cannot silently pass.

## Limits and editorial acceptance

Two native library builds on one Linux host; two rows per fixture; seven direct
controls per build plus 24 recovery observations. Designed cases are not sampled
incidents, so no rate or confidence interval is estimated. No power loss,
concurrent writer, custom function, attacker, production data, storage-device
benchmark or exhaustive generated-expression coverage was tested.

The system source ID ends in alt1; inspected upstream code is explanatory, not
asserted to be byte-identical distribution source. An upgraded writer's guard
does not diagnose how every legacy inconsistency arose. It only separates the
tested new operation from the tested historical bytes.

One harness test initially detected empty WAL/SHM files created by a read-only
seed inspection. That inspection now operates on a disposable copy. The original
main-file hashes were verified unchanged; the empty sidecars were finalized
through SQLite, not treated as missing committed data.

Ten primary-source receipts and three pinned public-domain source files are
retained in [sources.json](sources.json). No third-party paper or full API
documentation is redistributed. Normal publication gates and independent review remain distinct from this
same-host replay. No new defect, discovery priority or deployment is implied.
