Re: Inconsistent behavior of pg_dump/pg_restore on DEFAULT PRIVILEGES

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: "Bossart, Nathan" <bossartn@amazon.com>, Michael Paquier <michael@paquier.xyz>, Neil Chen <carpenter.nail.cz@gmail.com>, "Boris P. Korzun" <drtr0jan@yandex.ru>, "pgsql-bugs@lists.postgresql.org" <pgsql-bugs@lists.postgresql.org>
Date: 2021-10-19T03:19:12Z
Lists: pgsql-bugs, pgsql-hackers
Masahiko Sawada <sawada.mshk@gmail.com> writes:
> I've looked at the patch proposed you proposed. If we can depend on
> acldefault() being STRICT (which is legitimate to me), I think we
> don't need to build an expression depending on the caller (i.g.,
> is_default_acl). If acldefault() were to become not STRICT, we could
> detect it by regression tests. What do you think?

FWIW, I'm working on a refactoring of this logic that will bring the
acldefault() call into the getDefaultACLs code, which would mean that
we won't need that assumption anymore anyway.  The code as I have it
produces SQL like

     acldefault(CASE WHEN defaclobjtype = 'S'
                THEN 's'::"char" ELSE defaclobjtype END, defaclrole) AS acldefault

and we could wrap the test-for-zero around that:

     CASE WHEN defaclnamespace = 0 THEN
       acldefault(CASE WHEN defaclobjtype = 'S'
                  THEN 's'::"char" ELSE defaclobjtype END, defaclrole)
     ELSE NULL END AS acldefault

(although I think it might be better to write ELSE '{}' not ELSE NULL).

So I think we don't need to worry about whether acldefault() will stay
strict.  This patch will only need to work in the back branches.

			regards, tom lane



Commits

  1. pg_dump: fix mis-dumping of non-global default privileges.