From: Reinier Haasjes <Reinier.Haasjes@adyen.com>
To: pgsql-bugs@postgresql.org
Subject: [pg_dump] not dumping some default privileges
Date: Mon, 23 Oct 2017 13:13:58 +0200
Message-ID: <39fd69e3-279e-357d-008b-f6508f4c48b8@adyen.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Hi,
I noticed that pg_dump since 9.6 is missing some default privileges in
the dump. I noticed it since 9.6.2 but it's still there in 9.6.5.
To reproduce:
1) run 'create_database.sql' to create a database with some default
privileges.
create_database.sql is a modified pg_dump to reproduce this problem.
2) Check default privileges, should be like this:
> bug=# \ddp
> Default access privileges
> Owner | Schema | Type | Access privileges
> ----------+--------+----------+----------------------
> bug | public | sequence | bug=rwU/bug
> bug | public | table | bug=arwdDxt/bug
> postgres | public | sequence | bug=rwU/postgres
> postgres | public | table | bug=arwdDxt/postgres
> (4 rows)
3) Dump & re-create database with this dump
$ pg_dump -cCs -d bug > bug_schema_dump.sql
$ psql -f bug_schema_dump.sql
4) re-check default privileges:
> bug=# \ddp
> Default access privileges
> Owner | Schema | Type | Access privileges
> ----------+--------+----------+----------------------
> postgres | public | sequence | bug=rwU/postgres
> postgres | public | table | bug=arwdDxt/postgres
> (2 rows)
As show with a grep it's clearly in the dump (and thus not in psql not
loading):
> $ grep "^ALTER DEFAULT" create_database.sql
> ALTER DEFAULT PRIVILEGES FOR ROLE bug IN SCHEMA public REVOKE ALL ON SEQUENCES FROM bug;
> ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON SEQUENCES FROM postgres;
> ALTER DEFAULT PRIVILEGES FOR ROLE bug IN SCHEMA public REVOKE ALL ON TABLES FROM bug;
> ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON TABLES FROM postgres;
> ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT USAGE,SELECT,UPDATE ON SEQUENCES TO bug;
> ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT SELECT,INSERT,UPDATE,DELETE,TRUNCATE,REFERENCES,TRIGGER ON TABLES TO bug;
> ALTER DEFAULT PRIVILEGES FOR ROLE bug IN SCHEMA public GRANT SELECT,INSERT,UPDATE,DELETE,TRUNCATE,REFERENCES,TRIGGER ON TABLES TO bug;
> ALTER DEFAULT PRIVILEGES FOR ROLE bug IN SCHEMA public GRANT USAGE,SELECT,UPDATE ON SEQUENCES TO bug;
>
> $ grep "^ALTER DEFAULT" bug_schema_dump.sql
> ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON SEQUENCES FROM postgres;
> ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO bug;
> ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON TABLES FROM postgres;
> ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO bug;
The new database is missing 2 privileges (states in
missing_privileges.sql), I obviously expected that all privileges were
dumped.
I added two txt files (pg_controldata.txt & pg_config.txt) to show my
environment, which is a Mac with PG9.6.5. I initially noticed this bug
on a CentOS6 system with PG9.6.2 and it was still there after upgrade to
PG9.6.5.
I hope to have added all needed information, if not please let me know
what extra information you need.
Gr Reinier
--
Reinier Haasjes
Senior System Administrator
office +31 20 240 16 31
Adyen Headquarters
Simon Carmiggeltstraat 6-50, 5th floor
1011 DJ Amsterdam, The Netherlands
www.adyen.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugsAttachments:pg_controldata.txt (text/plain, 2.2K) download
pg_control version number: 960
Catalog version number: 201608131
Database system identifier: 6468164270952473602
Database cluster state: in production
pg_control last modified: Mon Oct 23 12:01:38 2017
Latest checkpoint location: 0/57069638
Prior checkpoint location: 0/57069560
Latest checkpoint's REDO location: 0/57069600
Latest checkpoint's REDO WAL file: 000000010000000000000057
Latest checkpoint's TimeLineID: 1
Latest checkpoint's PrevTimeLineID: 1
Latest checkpoint's full_page_writes: on
Latest checkpoint's NextXID: 0:75917
Latest checkpoint's NextOID: 427811
Latest checkpoint's NextMultiXactId: 1
Latest checkpoint's NextMultiOffset: 0
Latest checkpoint's oldestXID: 858
Latest checkpoint's oldestXID's DB: 1
Latest checkpoint's oldestActiveXID: 75916
Latest checkpoint's oldestMultiXid: 1
Latest checkpoint's oldestMulti's DB: 1
Latest checkpoint's oldestCommitTsXid:858
Latest checkpoint's newestCommitTsXid:75915
Time of latest checkpoint: Mon Oct 23 12:01:38 2017
Fake LSN counter for unlogged rels: 0/1
Minimum recovery ending location: 0/0
Min recovery ending loc's timeline: 0
Backup start location: 0/0
Backup end location: 0/0
End-of-backup record required: no
wal_level setting: logical
wal_log_hints setting: off
max_connections setting: 400
max_worker_processes setting: 40
max_prepared_xacts setting: 0
max_locks_per_xact setting: 64
track_commit_timestamp setting: on
Maximum data alignment: 8
Database block size: 8192
Blocks per segment of large relation: 131072
WAL block size: 8192
Bytes per WAL segment: 16777216
Maximum length of identifiers: 64
Maximum columns in an index: 32
Maximum size of a TOAST chunk: 1996
Size of a large-object chunk: 2048
Date/time type storage: 64-bit integers
Float4 argument passing: by value
Float8 argument passing: by value
Data page checksum version: 0
pg_config.txt (text/plain, 1.9K) download
BINDIR = /usr/local/postgresql-9.6/bin
DOCDIR = /usr/local/postgresql-9.6/share/doc
HTMLDIR = /usr/local/postgresql-9.6/share/doc
INCLUDEDIR = /usr/local/postgresql-9.6/include
PKGINCLUDEDIR = /usr/local/postgresql-9.6/include
INCLUDEDIR-SERVER = /usr/local/postgresql-9.6/include/server
LIBDIR = /usr/local/postgresql-9.6/lib
PKGLIBDIR = /usr/local/postgresql-9.6/lib
LOCALEDIR = /usr/local/postgresql-9.6/share/locale
MANDIR = /usr/local/postgresql-9.6/man
SHAREDIR = /usr/local/postgresql-9.6/share
SYSCONFDIR = /usr/local/postgresql-9.6/etc
PGXS = /usr/local/postgresql-9.6/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--target=x86_64' '--prefix=/usr/local/postgresql-9.6' '--with-includes=/usr/local/adyen/include' '--with-libraries=/usr/local/adyen/lib' '--mandir=/usr/local/postgresql-9.6/man' '--enable-thread-safety' '--with-openssl' '--with-gssapi' '--with-libxml' '--with-libxslt' '--with-python' '--with-perl' '--with-readline' '--with-uuid=e2fs' 'target_alias=x86_64' 'CFLAGS=-I/usr/local/adyen/include -I/usr/local/adyen/extras/include' 'LDFLAGS=-L/usr/local/adyen/lib -L/usr/local/adyen/extras/lib'
CC = gcc
CPPFLAGS = -DFRONTEND -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2 -I/usr/local/adyen/include
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -I/usr/local/adyen/include -I/usr/local/adyen/extras/include
CFLAGS_SL =
LDFLAGS = -L../../src/common -L/usr/local/adyen/lib -L/usr/local/adyen/extras/lib -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/lib -L/usr/local/adyen/lib -Wl,-dead_strip_dylibs
LDFLAGS_EX =
LDFLAGS_SL =
LIBS = -lpgcommon -lpgport -lxslt -lxml2 -lssl -lcrypto -lgssapi_krb5 -lz -lreadline -lm
VERSION = PostgreSQL 9.6.5
missing_privileges.sql (text/plain, 237B) download
ALTER DEFAULT PRIVILEGES FOR ROLE bug IN SCHEMA public GRANT SELECT,INSERT,UPDATE,DELETE,TRUNCATE,REFERENCES,TRIGGER ON TABLES TO bug;
ALTER DEFAULT PRIVILEGES FOR ROLE bug IN SCHEMA public GRANT USAGE,SELECT,UPDATE ON SEQUENCES TO bug;
bug_schema_dump.sql (text/plain, 1.8K) download
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.6.5
-- Dumped by pg_dump version 9.6.5
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
DROP DATABASE bug;
--
-- Name: bug; Type: DATABASE; Schema: -; Owner: bug
--
CREATE DATABASE bug WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'C' LC_CTYPE = 'UTF-8';
ALTER DATABASE bug OWNER TO bug;
\connect bug
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
--
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--
GRANT ALL ON SCHEMA public TO PUBLIC;
SET search_path = public, pg_catalog;
--
-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: public; Owner: postgres
--
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON SEQUENCES FROM postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO bug;
--
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: public; Owner: postgres
--
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON TABLES FROM postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO bug;
--
-- PostgreSQL database dump complete
--
create_database.sql (text/plain, 2.1K) download
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.6.5
-- Dumped by pg_dump version 9.6.5
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
CREATE ROLE bug;
ALTER ROLE bug WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS;
DROP DATABASE bug;
--
-- Name: bug; Type: DATABASE; Schema: -; Owner: bug
--
CREATE DATABASE bug;
ALTER DATABASE bug OWNER TO bug;
\connect bug
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
--
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--
GRANT ALL ON SCHEMA public TO PUBLIC;
SET search_path = public, pg_catalog;
ALTER DEFAULT PRIVILEGES FOR ROLE bug IN SCHEMA public REVOKE ALL ON SEQUENCES FROM bug;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON SEQUENCES FROM postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE bug IN SCHEMA public REVOKE ALL ON TABLES FROM bug;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON TABLES FROM postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT USAGE,SELECT,UPDATE ON SEQUENCES TO bug;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT SELECT,INSERT,UPDATE,DELETE,TRUNCATE,REFERENCES,TRIGGER ON TABLES TO bug;
ALTER DEFAULT PRIVILEGES FOR ROLE bug IN SCHEMA public GRANT SELECT,INSERT,UPDATE,DELETE,TRUNCATE,REFERENCES,TRIGGER ON TABLES TO bug;
ALTER DEFAULT PRIVILEGES FOR ROLE bug IN SCHEMA public GRANT USAGE,SELECT,UPDATE ON SEQUENCES TO bug;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: Reinier.Haasjes@adyen.com
Subject: Re: [pg_dump] not dumping some default privileges
In-Reply-To: <39fd69e3-279e-357d-008b-f6508f4c48b8@adyen.com>
References: <39fd69e3-279e-357d-008b-f6508f4c48b8@adyen.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox