pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feed[pg_dump] not dumping some default privileges
5+ messages / 3 participants
[nested] [flat]
* [pg_dump] not dumping some default privileges
@ 2017-10-23 11:13 Reinier Haasjes <Reinier.Haasjes@adyen.com>
2017-10-23 12:54 ` Re: [pg_dump] not dumping some default privileges Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 5+ messages in thread
From: Reinier Haasjes @ 2017-10-23 11:13 UTC (permalink / raw)
To: pgsql-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-bugs
Attachments:
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;
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pg_dump] not dumping some default privileges
2017-10-23 11:13 [pg_dump] not dumping some default privileges Reinier Haasjes <Reinier.Haasjes@adyen.com>
@ 2017-10-23 12:54 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2017-10-23 13:16 ` Re: [pg_dump] not dumping some default privileges Feike Steenbergen <feikesteenbergen@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Alvaro Herrera @ 2017-10-23 12:54 UTC (permalink / raw)
To: Reinier Haasjes <Reinier.Haasjes@adyen.com>; +Cc: pgsql-bugs
Reinier Haasjes wrote:
> 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.
Hmm, I can confirm that 9.6 seems to have this problem while 9.5 does
not seem to have it. Must have been broken at some point during the
extensive pg_dump patches in 9.6 ... I'll give this a look.
Thanks for reporting!
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pg_dump] not dumping some default privileges
2017-10-23 11:13 [pg_dump] not dumping some default privileges Reinier Haasjes <Reinier.Haasjes@adyen.com>
2017-10-23 12:54 ` Re: [pg_dump] not dumping some default privileges Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2017-10-23 13:16 ` Feike Steenbergen <feikesteenbergen@gmail.com>
2017-10-23 14:03 ` Re: [pg_dump] not dumping some default privileges Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 5+ messages in thread
From: Feike Steenbergen @ 2017-10-23 13:16 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Reinier Haasjes <Reinier.Haasjes@adyen.com>; pgsql-bugs
On 23 October 2017 at 14:54, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:
>
> Reinier Haasjes wrote:
> > Hi,
> >
> > I noticed that pg_dump since 9.6 is missing some default privileges
> Hmm, I can confirm that 9.6 seems to have this problem while 9.5 does
> not seem to have it. Must have been broken at some point during the
> extensive pg_dump patches in 9.6 ... I'll give this a look.
in buildACLQueries there is a filter to exclude those acl's that match the
pg_init_privs or default pg_catalog.acldefault for that role.
If I run the create_database.sql with a slightly altered GRANT section,
pg_dump does return the actual DEFAULT PRIVILEGES for that role, these
don't match the defaults.
-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
SELECT,INSERT,UPDATE,DELETE,TRUNCATE,TRIGGER ON TABLES TO bug;
regards,
Feike
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pg_dump] not dumping some default privileges
2017-10-23 11:13 [pg_dump] not dumping some default privileges Reinier Haasjes <Reinier.Haasjes@adyen.com>
2017-10-23 12:54 ` Re: [pg_dump] not dumping some default privileges Alvaro Herrera <alvherre@2ndquadrant.com>
2017-10-23 13:16 ` Re: [pg_dump] not dumping some default privileges Feike Steenbergen <feikesteenbergen@gmail.com>
@ 2017-10-23 14:03 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2017-10-23 14:12 ` Re: [pg_dump] not dumping some default privileges Reinier Haasjes <Reinier.Haasjes@adyen.com>
0 siblings, 1 reply; 5+ messages in thread
From: Alvaro Herrera @ 2017-10-23 14:03 UTC (permalink / raw)
To: Feike Steenbergen <feikesteenbergen@gmail.com>; +Cc: Reinier Haasjes <Reinier.Haasjes@adyen.com>; pgsql-bugs
Feike Steenbergen wrote:
> On 23 October 2017 at 14:54, Alvaro Herrera <alvherre@2ndquadrant.com>
> wrote:
> >
> > Reinier Haasjes wrote:
> > > Hi,
> > >
> > > I noticed that pg_dump since 9.6 is missing some default privileges
> > Hmm, I can confirm that 9.6 seems to have this problem while 9.5 does
> > not seem to have it. Must have been broken at some point during the
> > extensive pg_dump patches in 9.6 ... I'll give this a look.
>
> in buildACLQueries there is a filter to exclude those acl's that match the
> pg_init_privs or default pg_catalog.acldefault for that role.
Ah, thanks, Feike.
So what is going on is that those commands don't actually have any
visible effect in pg_dump because they change the privileges from the
default state to a state that's identical to the default. I suppose
that makes sense.
However, I don't think Reinier would have gone to the trouble of
reporting the problem unless there was something actually being affected
by it. Am I mistaken?
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pg_dump] not dumping some default privileges
2017-10-23 11:13 [pg_dump] not dumping some default privileges Reinier Haasjes <Reinier.Haasjes@adyen.com>
2017-10-23 12:54 ` Re: [pg_dump] not dumping some default privileges Alvaro Herrera <alvherre@2ndquadrant.com>
2017-10-23 13:16 ` Re: [pg_dump] not dumping some default privileges Feike Steenbergen <feikesteenbergen@gmail.com>
2017-10-23 14:03 ` Re: [pg_dump] not dumping some default privileges Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2017-10-23 14:12 ` Reinier Haasjes <Reinier.Haasjes@adyen.com>
0 siblings, 0 replies; 5+ messages in thread
From: Reinier Haasjes @ 2017-10-23 14:12 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; Feike Steenbergen <feikesteenbergen@gmail.com>; +Cc: pgsql-bugs
Hi,
On 23/10/2017 16:03, Alvaro Herrera wrote:
> However, I don't think Reinier would have gone to the trouble of
> reporting the problem unless there was something actually being affected
> by it. Am I mistaken?
I reported this problem because my automated privileges script was
complaining after dump/restore.
I did some more checking and I can't find any other thing being affected
by it (beside my check script).
Apparently the bug is not in pg_dump but it's my script not fully 9.6
compliant. I will adapt the script to be fully 9.6 compatible.
Sorry for the trouble but thanks for the help. We can mark this one as
NOT_A_BUG ;)
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-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2017-10-23 14:12 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-10-23 11:13 [pg_dump] not dumping some default privileges Reinier Haasjes <Reinier.Haasjes@adyen.com>
2017-10-23 12:54 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2017-10-23 13:16 ` Feike Steenbergen <feikesteenbergen@gmail.com>
2017-10-23 14:03 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2017-10-23 14:12 ` Reinier Haasjes <Reinier.Haasjes@adyen.com>
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