model-writtenrun 6390 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Jim Nasby reported that evaluating an immutable SQL function immediately after COMMIT in a stored procedure crashed HEAD and PostgreSQL 13 because no active snapshot existed #1; Michael Paquier bisected the regression to snapshot avoidance for immutable simple expressions and questioned snapshot handling in a new transaction #2.
- Ranier Vilela proposed changing the snapshot condition from && to || and reported that this fixed the original reproducer #3.
- Tom Lane identified a deeper omission: simple expressions needed to restore the portal-level snapshot after COMMIT or ROLLBACK, including protection for toasted results after expression evaluation #4; his replacement patch added EnsurePortalSnapshotExists() before replanning #5.
- Tom added a regression test using a deliberately immutable-marked SQL function returning toasted table data, demonstrating that PostgreSQL 11 and 12 also failed when the result was detoasted #6.
- Tom committed the complete tested patch from #6 unchanged apart from branch context as d102aafb62, with backports through PostgreSQL 11.
- After the commit, Justin Pryzby reported a FETCH crash #7; Tom could not reproduce it #8, and Justin withdrew the report after identifying an old pg_stat_statements module #9.
- Greg Nancarrow subsequently tested and supported Ranier's original condition change #10, and Ranier reiterated its rationale #11; Tom explained that the existing && condition was correct and that changing it would take unnecessary snapshots while only partially masking the underlying bug #12.
- Greg accepted the existing logic and suggested expressing the condition as skip_snapshot to align with the comment #13, which Tom considered #14; Ranier preferred retaining the simpler code and requested clearer comments #15 #16, leaving the functional fix landed and the wording discussion unresolved.