model-writtenrun 6399 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Alexander Lakhin reported that DROP OWNED BY on a policy listing the same role twice caused an assertion failure or a tuple-already-updated error #1, and Tom Lane confirmed the problem extended back to PostgreSQL 9.6 #2.
- Tom identified an invalid assumption about unique role OIDs, unsafe locking order, unnecessary expression-dependency rebuilding, and inappropriate ownership checks in RemoveRoleFromObjectPolicy() #3 #4.
- Michael Paquier suggested preventing duplicate catalog entries #5, but Tom chose to make removal tolerate all matching entries because existing installations and manually modified arrays still required protection #6.
- Tom proposed allowing policies with no applicable roles as a future feature #6; Stephen Frost and Alvaro Herrera discussed policy preservation and DROP OWNED semantics, with Stephen accepting deletion of a policy when its last role disappears #7 #8 #9 #10.
- Alvaro suggested preserving otherwise-empty policies by assigning the bootstrap superuser #11, while Tom posted the minimal assertion and command-counter fix for beta2 #12 and rejected the bootstrap-superuser workaround because it could confuse or break dump restoration #13.
- Tom committed the minimal fix with clearer equivalent control flow and duplicate-role regression tests as d21fca0843, derived from #12 and backpatched to all supported branches.
- Tom then posted a separate cleanup removing ownership and relation checks, table locking, and redundant expression-dependency rebuilding, while leaving empty-role policies outside the backpatchable scope #14.
- Michael reviewed the cleanup and questioned rebuilding all shared dependencies #15; Tom deferred that optimization and explained the possible value of retaining empty-role policies #16, while Michael favored retaining existing deletion behavior in the thread's final message #17.
- After the discussion ended, Tom committed the cleanup from #14 as 5a0f1c8c01, adding a validity guard around ReleaseSysCache and backpatching it; both submitted changes landed, while empty-role policy support and finer-grained shared-dependency updates remained unimplemented.