model-writtenrun 6075 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Bertrand Drouvot reported an assertion failure when a PL/pgSQL loop committed inside an exception handler and proposed clearing the portal snapshot pointer when subtransaction abort emptied the snapshot stack #1; Tom Lane found a related snapshot-accounting error with a simpler reproducer #2.
- Tom Lane traced the problem to a portal snapshot being recreated at a deeper subtransaction level than its owning portal and rejected pointer clearing as an inadequate fix; he preferred assigning the snapshot the portal's level over searching the snapshot stack for pointers about to become invalid #4.
- Bertrand Drouvot implemented explicit snapshot levels and a regression test #5; Ranier Vilela questioned duplicated code #6, while Bertrand cited extension compatibility #7 and Alvaro Herrera supported the approach, ordering assertions, and retaining the existing API #10 #11.
- Tom Lane proposed preserving the API through a wrapper and corrected the ordering assertion #12; Bertrand incorporated those changes but reported a regression-test failure #14, which Tom traced to confusing sequential subtransaction IDs with nesting depth #15.
- Bertrand added a portal nesting-depth field and maintained it across subtransaction commits #16; Tom then limited explicit levels to PortalRunUtility and EnsurePortalSnapshotExists, refined field handling and comments, and moved the test to PL/pgSQL with both COMMIT and ROLLBACK coverage #17.
- Bertrand accepted the narrowed scope #18, and Tom explained that stable branches needed the new portal field appended to preserve existing field offsets for extensions #19; the thread ended with Bertrand acknowledging that explanation #20.
- After the final thread message, Tom Lane committed the final attached patch #17 unchanged as 7b5d4c29ed, crediting Bertrand Drouvot and back-patching the fix through PostgreSQL 11.