pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14817: pg_dumpall is not generating create database statements
3+ messages / 3 participants
[nested] [flat]

* BUG #14817: pg_dumpall is not generating create database statements
@ 2017-09-15 15:20 alex@yuscott.co.uk
  2017-09-15 16:08 ` Re: BUG #14817: pg_dumpall is not generating create database statements David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: alex@yuscott.co.uk @ 2017-09-15 15:20 UTC (permalink / raw)
  To: pgsql-bugs; +Cc: alex@yuscott.co.uk

The following bug has been logged on the website:

Bug reference:      14817
Logged by:          Alexander Scott
Email address:      alex@yuscott.co.uk
PostgreSQL version: 9.6.5
Operating system:   CentOS Linux release 7.3.1611 (Core)
Description:        

I have a fresh install of 9.6.5 with a default postgres database.

I have REVOKED ALL FROM public, created a couple of roles and 1 initial
user.

I wanted to take a dump of the entire cluster to store but the output file
lacks create statements for the databases.  It happily dumps the contents,
and even grant privileges to roles at DB level (CREATE and TEMP).

I literally call with no parameters.
Output is as follows

--
-- PostgreSQL database cluster dump
--

SET default_transaction_read_only = off;

SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;

--
-- Roles
--

CREATE ROLE basic_user;
ALTER ROLE basic_user WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB
NOLOGIN NOREPLICATION NOBYPASSRLS;
CREATE ROLE developer;
ALTER ROLE developer WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB
NOLOGIN NOREPLICATION NOBYPASSRLS;
CREATE ROLE manager;
ALTER ROLE manager WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB NOLOGIN
NOREPLICATION NOBYPASSRLS;
CREATE ROLE postgres;
ALTER ROLE postgres WITH SUPERUSER INHERIT CREATEROLE CREATEDB LOGIN
REPLICATION BYPASSRLS PASSWORD '<password>';
CREATE ROLE initial_user;
ALTER ROLE initial_userWITH NOSUPERUSER NOINHERIT NOCREATEROLE NOCREATEDB
LOGIN NOREPLICATION NOBYPASSRLS PASSWORD '<password>';


--
-- Role memberships
--

GRANT basic_user TO developer GRANTED BY postgres;
GRANT developer TO manager GRANTED BY postgres;
GRANT manager TO tony_phillips GRANTED BY postgres;




--
-- Database creation
--

REVOKE CONNECT,TEMPORARY ON DATABASE postgres FROM PUBLIC;
GRANT CREATE ON DATABASE postgres TO manager;
GRANT TEMPORARY ON DATABASE postgres TO developer;
REVOKE CONNECT,TEMPORARY ON DATABASE template1 FROM PUBLIC;
GRANT CONNECT ON DATABASE template1 TO PUBLIC;


\connect postgres

SET default_transaction_read_only = off;

--
-- 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;

--
-- Name: postgres; Type: COMMENT; Schema: -; Owner: postgres
--

COMMENT ON DATABASE postgres IS 'default administrative connection
database';


--
-- 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
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
GRANT USAGE ON SCHEMA public TO PUBLIC;


--
-- PostgreSQL database dump complete
--

\connect template1

SET default_transaction_read_only = off;

--
-- 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;

--
-- Name: template1; Type: COMMENT; Schema: -; Owner: postgres
--

COMMENT ON DATABASE template1 IS 'default template for new databases';


--
-- 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';


--
-- PostgreSQL database dump complete
--

--
-- PostgreSQL database cluster dump complete
--

Thanks

Alex


-- 
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] 3+ messages in thread

* Re: BUG #14817: pg_dumpall is not generating create database statements
  2017-09-15 15:20 BUG #14817: pg_dumpall is not generating create database statements alex@yuscott.co.uk
@ 2017-09-15 16:08 ` David G. Johnston <david.g.johnston@gmail.com>
  2017-09-16 20:42   ` Re: BUG #14817: pg_dumpall is not generating create database statements Alexander Scott <alex@yuscott.co.uk>
  0 siblings, 1 reply; 3+ messages in thread

From: David G. Johnston @ 2017-09-15 16:08 UTC (permalink / raw)
  To: alex@yuscott.co.uk; +Cc: pgsql-bugs

On Fri, Sep 15, 2017 at 8:20 AM, <alex@yuscott.co.uk> wrote:

> The following bug has been logged on the website:
>
> Bug reference:      14817
> Logged by:          Alexander Scott
> Email address:      alex@yuscott.co.uk
> PostgreSQL version: 9.6.5
> Operating system:   CentOS Linux release 7.3.1611 (Core)
> Description:
>
> I have a fresh install of 9.6.5 with a default postgres database.
>
> I have REVOKED ALL FROM public, created a couple of roles and 1 initial
> user.
>
> I wanted to take a dump of the entire cluster to store but the output file
> lacks create statements for the databases.


Working as intended (at least per code comments in pg_dumpall.c @1464) -
the only databases that exist (postgres, template0, template1) in your
installation are the default databases.  pg_dumpall is assuming that the
target cluster that you will be restoring into will already contain them
(and a freshly created cluster should) and so decides it does not need to
create them itself.

You will probably need to describe a more complete use case, with an actual
failure, in order to convince someone to change this.

David J.

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #14817: pg_dumpall is not generating create database statements
  2017-09-15 15:20 BUG #14817: pg_dumpall is not generating create database statements alex@yuscott.co.uk
  2017-09-15 16:08 ` Re: BUG #14817: pg_dumpall is not generating create database statements David G. Johnston <david.g.johnston@gmail.com>
@ 2017-09-16 20:42   ` Alexander Scott <alex@yuscott.co.uk>
  0 siblings, 0 replies; 3+ messages in thread

From: Alexander Scott @ 2017-09-16 20:42 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-bugs

David,

Thanks for the answer.  That makes perfect sense and I feel slightly 
embarassed that that did not occur to me.

As far as I am concerned, there is a perfectly logic explanation for the 
behaviour so case closed!

Alex


On 15/09/2017 17:08, David G. Johnston wrote:
> On Fri, Sep 15, 2017 at 8:20 AM, <alex@yuscott.co.uk 
> <mailto:alex@yuscott.co.uk>>wrote:
>
>     The following bug has been logged on the website:
>
>     Bug reference:      14817
>     Logged by:          Alexander Scott
>     Email address: alex@yuscott.co.uk <mailto:alex@yuscott.co.uk>
>     PostgreSQL version: 9.6.5
>     Operating system:   CentOS Linux release 7.3.1611 (Core)
>     Description:
>
>     I have a fresh install of 9.6.5 with a default postgres database.
>
>     I have REVOKED ALL FROM public, created a couple of roles and 1
>     initial
>     user.
>
>     I wanted to take a dump of the entire cluster to store but the
>     output file
>     lacks create statements for the databases.
>
>
> Working as intended (at least per code comments in pg_dumpall.c @1464) 
> - the only databases that exist (postgres, template0, template1) in 
> your installation are the default databases.  pg_dumpall is assuming 
> that the target cluster that you will be restoring into will already 
> contain them (and a freshly created cluster should) and so decides it 
> does not need to create them itself.
>
> You will probably need to describe a more complete use case, with an 
> actual failure, in order to convince someone to change this.
>
> David J.
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2017-09-16 20:42 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-09-15 15:20 BUG #14817: pg_dumpall is not generating create database statements alex@yuscott.co.uk
2017-09-15 16:08 ` David G. Johnston <david.g.johnston@gmail.com>
2017-09-16 20:42   ` Alexander Scott <alex@yuscott.co.uk>

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