Inconsistent behavior of pg_dump/pg_restore on DEFAULT PRIVILEGES

From: Boris P(dot) Korzun <drtr0jan(at)yandex(dot)ru>
To: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Inconsistent behavior of pg_dump/pg_restore on DEFAULT PRIVILEGES
Date: 2021-03-24 20:38:50
Message-ID: 111621616618184@mail.yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


Hi,


 



PostgreSQL version: 13.2


Operating system:  FreeBSD 13-STABLE


 



I've founded that pg_dump (and pg_dumpall) incorrectlty exports subsequent default privileges.


Ex.:


> ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE ALL ON FUNCTIONS FROM PUBLIC;


> ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA bar GRANT EXECUTE ON FUNCTIONS TO PUBLIC;


> bug=# \ddp


>              Default access privileges


>   Owner   | Schema |   Type   |  Access privileges


> ----------+--------+----------+---------------------


>  postgres | bar    | function | =X/postgres


>  postgres |        | function | postgres=X/postgres


> -- I can execute newly created functions on scheme 'bar' after that.


 


will be exported as:


> ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA bar REVOKE ALL ON FUNCTIONS  FROM postgres;


> ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE ALL ON FUNCTIONS  FROM PUBLIC;


> bug=# \ddp


>              Default access privileges


>   Owner   | Schema |   Type   |  Access privileges  


> ----------+--------+----------+---------------------


>  postgres |        | function | postgres=X/postgres


> -- I can NOT execute newly created functions on scheme 'bar' after that.


 


After restoring the dump I cannot execute newly created functions on scheme 'bar'.


I've attached the shell-script that create the environment.


 


I create a function after dump or restore procedures (ex. backup purposes):



> CREATE FUNCTION bar.new() RETURNS bool


>     IMMUTABLE


>     LANGUAGE sql


> AS 'SELECT TRUE;';


The function bar.new() cannot be executed by 'bug' user if created after the restore procedure.


I've got an error: ERROR:  permission denied for function new.


 



WBR,


Boris

Attachment Content-Type Size
unknown_filename text/html 2.2 KB
sql-def_priv_bug.sh text/x-shellscript 1023 bytes

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2021-03-24 22:27:21 BUG #16942: Misleading error message on denied permission for column in table
Previous Message Alvaro Herrera 2021-03-24 16:39:31 Re: BUG #16931: source code problem about commit_ts