model-writtenrun 7448 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Andreas Wicht reported that a procedure committing inside a cursor loop failed when selecting PostGIS geometries; Andres Freund reproduced the failure using ordinary toasted text and traced it to missing snapshots during detoasting #1 #2.
- After another report revived the issue in May 2021, Tom Lane investigated where to recreate snapshots after procedure COMMIT/ROLLBACK and posted a small fallback in init_toast_snapshot(), while warning that a new snapshot could not protect TOAST data already exposed to reclamation #3 #4.
- Following Konstantin Knizhnik's earlier investigation, Tom replaced that approach with disabling cursor prefetch in all non-atomic contexts; his new multirow isolation test exposed missing TOAST chunks after concurrent VACUUM, explaining why the existing single-row tests missed the bug #4 #5.
- Tom then demonstrated a separate failure: after an internal commit, SPI could return a toasted value after releasing its statement snapshot, leaving PL/pgSQL unable to detoast it safely #6.
- Andres explained that FirstSnapshotSet alone does not preserve a usable snapshot or xmin horizon, and Tom concluded that an enclosing snapshot must protect values returned by SPI; Andres also suggested associating xmin horizons with toasted datums as a possible future diagnostic #7 #8 #9.
- Tom's final attachment tracked portal-owned snapshots explicitly and restored them through SPI only when a statement required one, allowing SET and LOCK to run first; it also extended snapshot protection around logical-replication executor use #10.
- At the last message, both fixes were still proposed: Tom explicitly retained the separate prefetch patch, left SET/RESET infrastructure removal for development-only follow-up, and identified unresolved enforcement of safe procedure output values and snapshot management for PLs bypassing SPI #10.
- The cursor-prefetch fix landed on May 20 as f21fadafaf from #5, adding a clearer TOAST error and explanatory comments while preserving the implementation and test.
- The portal-snapshot fix landed on May 21 as 84f5c2908d from #10, with the allow_nonatomic naming propagated through the public SPI options and documentation; both bug fixes were backpatched through PostgreSQL 11.
- The development-only cleanup proposed in #10 landed on May 22 as 30168be8f7, removing PL/pgSQL's special SET/RESET paths because SPI now handled their snapshot requirements.