Files
pad/docs
xarmian c31fb06c86 fix(store): the migrate-to-pg preflight refuses a stored value that is not valid UTF-8, and scan-nul / repair-nul report and repair it (BUG-3222) (#1559)
* fix(store): the migrate-to-pg preflight refuses a stored value that is not valid UTF-8, and scan-nul / repair-nul report and repair it (BUG-3222)

PostgreSQL refuses a text or jsonb value holding invalid UTF-8 (SQLSTATE
22021 under a UTF8 database); SQLite stores it silently. A legacy row of
that class failed `pad db migrate-to-pg` partway through the copy, leaving
the destination half-populated, and the NUL preflight never looked for it.
The destination cast on NUL suspects caught a sliver of the class by
coincidence (a value that also mentioned the escape), which BUG-3220 is
about to delete.

The NUL census now reads every protected column in full as a BLOB and
reports invalid UTF-8 as a violation kind (merged with a NUL finding on the
same row), so scan-nul lists it, repair-nul replaces each invalid sequence
with U+FFFD, and the preflight refuses on it through the path it already
had (migrated tables only; nothing written first). Measured on a copy of a
306 MB live database: scan-nul 0.51 s -> 1.52-1.62 s, peak RSS +10 MB.

* fix(store): a value with both defects on an incomplete-key row is counted once (merged by rowid), and the JSON and SQLSTATE wording is exact (BUG-3222 codex r1)

* test(store): no protected table may declare a column that shadows SQLite's rowid, which the NUL scan merges on (BUG-3222 codex r2)
2026-09-26 00:15:21 -04:00
..