Proper object locking for GRANT/REVOKE

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-10-28T15:20:42Z
Lists: pgsql-hackers

Attachments

This patch started out as a refactoring, thinking that 
objectNamesToOids() in aclchk.c should really mostly be a loop around 
get_object_address().  This is mostly true, with a few special cases 
because the node representations are a bit different in some cases, and 
OBJECT_PARAMETER_ACL, which is obviously very different.  This saves a 
bunch of duplicative code, which is nice.

Additionally, get_object_address() handles locking, which 
objectNamesToOids() somewhat famously does not do, and there is a code 
comment about it.  With this refactoring, we get the locking pretty much 
for free.

Interestingly, this changes the output of the intra-grant-inplace 
isolation test, which is recent work.  It might be good to get some 
review from those who worked on that, to make sure that the new behavior 
is still correct and/or to check whether those test cases are still 
applicable.

Also, it would be worth thinking about what the correct lock mode should 
be here.

Commits

  1. Put back intra-grant-inplace.spec test coverage

  2. Improve objectNamesToOids() comment

  3. Proper object locking for GRANT/REVOKE

  4. Add an assertion in get_object_address()