[COMMITTERS] pgsql: pg_dump: Properly handle public schema ACLs with --clean

Поиск
Список
Период
Сортировка
От Stephen Frost
Тема [COMMITTERS] pgsql: pg_dump: Properly handle public schema ACLs with --clean
Дата
Msg-id E1cl6kp-0001zc-A2@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
pg_dump: Properly handle public schema ACLs with --clean

pg_dump has always handled the public schema in a special way when it
comes to the "--clean" option.  To wit, we do not drop or recreate the
public schema in "normal" mode, but when we are run in "--clean" mode
then we do drop and recreate the public schema.

When running in "--clean" mode, the public schema is dropped and then
recreated and it is recreated with the normal schema-default privileges
of "nothing".  This is unlike how the public schema starts life, which
is to have CREATE and USAGE GRANT'd to the PUBLIC role, and that is what
is recorded in pg_init_privs.

Due to this, in "--clean" mode, pg_dump would mistakenly only dump out
the set of privileges required to go from the initdb-time privileges on
the public schema to whatever the current-state privileges are.  If the
privileges were not changed from initdb time, then no privileges would
be dumped out for the public schema, but with the schema being dropped
and recreated, the result was that the public schema would have no ACLs
on it instead of what it should have, which is the initdb-time
privileges.

Practically speaking, this meant that pg_dump with --clean mode dumping
a database where the ACLs on the public schema were not changed from the
default would, upon restore, result in a public schema with *no*
privileges GRANT'd, not matching the state of the existing database
(where the initdb-time privileges would have been CREATE and USAGE to
the PUBLIC role for the public schema).

To fix, adjust the query in getNamespaces() to ignore the pg_init_privs
entry for the public schema when running in "--clean" mode, meaning that
the privileges for the public schema would be dumped, correctly, as if
it was going from a newly-created schema to the current state (which is,
indeed, what will happen during the restore thanks to the DROP/CREATE).

Only the public schema is handled in this special way by pg_dump, no
other initdb-time objects are dropped/recreated in --clean mode.

Back-patch to 9.6 where the bug was introduced.

Discussion: https://postgr.es/m/3534542.o3cNaKiDID%40techfox

Branch
------
REL9_6_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/e961341cc1491ddf41e9408d9b1d3342df9ea2c2

Modified Files
--------------
src/bin/pg_dump/pg_dump.c        | 22 +++++++++++++++++++++-
src/bin/pg_dump/t/002_pg_dump.pl | 26 ++++++++++++++++++++++++--
2 files changed, 45 insertions(+), 3 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: [COMMITTERS] pgsql: Repair incorrect pg_dump labeling for some comments andsecurity
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: [COMMITTERS] pgsql: Refactor SHA2 functions and move them to src/common/.