model-writtenrun 4214 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Joseph Koshakow proposed checking the authenticated role's current superuser status on SET SESSION AUTHORIZATION because the cached connection-time status allowed demoted users to regain privileges; his initial patch performed a catalog lookup inside SetSessionAuthorization() #1.
- Nathan Bossart found that the initial lookup could make RESET SESSION AUTHORIZATION fail fatally after the authenticated role was dropped and suggested superuser_arg(); Joseph adopted it, later confirming that the existing same-role exemption avoided the problematic lookup #2 #3 #4 #8.
- Michał Kłeczek separately proposed secret-protected session-authorization changes for sandboxing scripts, but that idea received no implementation or further discussion in this thread #5.
- Joseph reproduced a server panic when superuser revocation caused privilege checking to fail repeatedly during transaction abort, and Nathan explained the recursive error handling; Joseph then moved validation into check_session_authorization() #9 #10 #11.
- Nathan explained that GUC assign hooks must avoid failures and catalog lookups during rollback, and supplied a separate preparatory patch that relocated validation while preserving existing privilege semantics through a temporary accessor #12.
- Joseph accepted the split and posted both patches, while identifying misleading is_superuser comments and the session_auth_is_superuser variable name; he also requested that the comment about setting the GUC remain beside SetSessionAuthorization() #13 #14.
- Nathan incorporated the feedback into three patches covering the variable rename, check relocation, and current-privilege validation; he removed the temporary accessor in the final component and deferred broader is_superuser GUC changes to another thread, after which Joseph endorsed the series #15 #16.
- Nathan first committed the variable-rename component of #15 with an unchanged diff as 0fef877538, announcing that the other two patches would follow #18.
- Nathan then committed the check-relocation component of #15 with comment and diagnostic refinements as 9987a7bf34, followed by its current-superuser validation component with unchanged substantive code as a0363ab7aa.
- The thread ended with all three patches committed, while Nathan acknowledged that a session already switched to another privileged role could retain those privileges after demotion; he accepted that limitation because the change still improved behavior and consistency with SET ROLE #19.