model-writtenrun 2626 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Laurenz Albe reported that deferred triggers could execute as the role active at commit rather than the role that caused the change, including when SECURITY DEFINER functions performed the original work #1.
- The initial discussion raised dropped-role handling, execution settings such as search_path, and Isaac Morland's alternative of executing triggers as their owners #2 #3 #4.
- Laurenz Albe proposed recording the triggering role in AfterTriggerSharedData and restoring it when firing the trigger, arguing that the change introduced no new privilege-escalation route through attacker-controlled tables #6.
- Joseph Koshakow questioned why roles should be preserved when other execution settings could change, requested documentation, and later supplied a rebase while identifying unnecessary role-name allocation in the existence check #7 #12.
- Laurenz Albe opposed adding special syntax for this corner case and considered owner-based execution too disruptive, while David G. Johnston eventually supported a narrow change for the next major release and Laurenz ruled out backpatching #11 #16 #17 #18.
- Bennie Swart supplied the motivating application example: writable views used SECURITY DEFINER functions to modify legacy tables, but deferred validation triggers subsequently lost the privileges needed to read those tables #19.
- Joseph Koshakow preferred retaining existing behavior and using SECURITY DEFINER validation functions; Laurenz considered rejection, and Pavel Stehule initially favored documentation alone, before another user report renewed the case for changing behavior #21 #22 #23 #24.
- Pavel Stehule's subsequent code review led Laurenz Albe to replace the role-name lookup with a syscache check, explain why queued events do not prevent role deletion, and document trigger execution identity; Pavel reported successful testing and marked the patch ready for a committer #25 #28 #29 #30 #31.
- Tom Lane identified regression-test role-name restrictions, and Laurenz Albe added the required regress_ prefixes #32 #33.
- Tom Lane's January review questioned the added shared-record storage and rejected the explicit role-existence check because it was racy and running as a dropped role did not threaten system integrity #34.
- Instrumentation reassured Tom Lane about shared-record counts but revealed inefficient oldest-first searching, leading to an independent newest-first optimization that landed unchanged as 7921927bbb from #35.
- Laurenz Albe rebased the main patch and removed the role-existence check in #36; Tom Lane committed it as 01463e1ccc with cosmetic and test adjustments, including removal of the dropped-role test #37.
- The main commit retained execution as the triggering role rather than the trigger owner to preserve CURRENT_USER-based auditing, and treated the semantic change as too large for backpatching 01463e1ccc.
- Noah Misch subsequently flagged avoidable trademark concerns in the test names and inaccurate documentation for roles changing within a statement; Nico Williams separately mentioned an always-deferred constraint proposal, which this thread did not implement #39 #40.
- After Michael Paquier endorsed renaming the test roles, Tom Lane replaced them with descriptive caller and function-owner names in 4b05ebf095 #41 #42.
- Noah Misch supplied an inline documentation patch describing the role that queued the event, and Tom Lane accepted it with a wording adjustment in the thread's final message; it subsequently landed as c37be39a74, completing the main fix and its follow-ups #43 #44.