]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix pg_dumpall to cope with dangling OIDs in pg_auth_members.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 Feb 2025 18:37:12 +0000 (13:37 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 Feb 2025 18:37:16 +0000 (13:37 -0500)
commit6df3be415cdb7c6ae350eadbae2f8ea7a0fcf4be
treeab6732581b1c7976086c2bc1d56ebe4a02803ebf
parenta5618e40217d836e7e0e8dcb07764aeff2f73aad
Fix pg_dumpall to cope with dangling OIDs in pg_auth_members.

There is a race condition between "GRANT role" and "DROP ROLE",
which allows GRANT to install pg_auth_members entries that refer to
dropped roles.  (Commit 6566133c5 prevented that for the grantor
field, but not for the granted or grantee roles.)  We'll soon fix
that, at least in HEAD, but pg_dumpall needs to cope with the
situation in case of pre-existing inconsistency.  As pg_dumpall
stands, it will emit invalid commands like 'GRANT foo TO ""',
which causes pg_upgrade to fail.  Fix it to emit warnings and skip
those GRANTs, instead.

There was some discussion of removing the problem by changing
dumpRoleMembership's query to use JOIN not LEFT JOIN, but that
would result in silently ignoring such entries.  It seems better
to produce a warning.

Pre-v16 branches already coped with dangling grantor OIDs by simply
omitting the GRANTED BY clause.  I left that behavior as-is, although
it's somewhat inconsistent with the behavior of later branches.

Reported-by: Virender Singla <virender.cse@gmail.com>
Discussion: https://postgr.es/m/CAM6Zo8woa62ZFHtMKox6a4jb8qQ=w87R2L0K8347iE-juQL2EA@mail.gmail.com
Backpatch-through: 13
src/bin/pg_dump/pg_dumpall.c