Restoring dump of multiuser databases

From: David Garamond <lists(at)zara(dot)6(dot)isreserved(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Restoring dump of multiuser databases
Date: 2004-09-07 18:28:22
Message-ID: 413DFDC6.9090007@zara.6.isreserved.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

All of my non-superusers are restricted from creating databases.
Whenever I upgrade Postgres, I have to hand-edit my dump and change:

CREATE USER usr1 WITH SYSID 101 PASSWORD '...' NOCREATEDB NOCREATEUSER;

into:

CREATE USER usr1 WITH SYSID 101 PASSWORD '...' CREATEDB NOCREATEUSER;

and then after the restore, I do a:

UPDATE pg_shadow SET usecreatedb=false WHERE usesysid <> 1;

Is there an easier way? Or would it make more sense if pg_dumpall
generates this:

\connect template1 postgres
CREATE DATABASE db1 WITH TEMPLATE=template0 ENCODING = 'SQL_ASCII';
UPDATE pg_database SET datdba=101 WHERE datnam='db1';
\connect db1 usr1
...
CREATE TABLE ( ... );

instead of this:

\connect template1 usr1
CREATE DATABASE db1 WITH TEMPLATE=template0 ENCODING = 'SQL_ASCII';
\connect db1 usr1
...
CREATE TABLE ( ... );

That is, the superuser creates the database for the normal user, and
then set the owner to the normal user. This way, the normal user doesn't
have to create the database himself.

--
dave

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nick Hajek 2004-09-07 18:34:31 V8.0 beta 1 Void type
Previous Message David Garamond 2004-09-07 18:18:17 Re: Salt in encrypted password in pg_shadow