pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nicolas Kowalski <Nicolas.Kowalski@imag.fr>
To: pgsql-admin@postgresql.org
Subject: database ownership and dumps
Date: Thu, 25 Jul 2002 19:25:24 +0200
Message-ID: <vqo65z3oh2z.fsf@imag.fr> (raw)


Hello.

We use PostgreSQL 7.1.3 on Debian GNU/Linux.

I would like to 1) create a database owned by a particular user but
without giving him/her the right to create databases (some users make
mistakes, or bad things, whatever), and 2) keep consistent backups.

I managed to do 1) by creating a database as a superuser, then
changing the ownership directly into the pg_database table. The user
owning the database is now able to create his/her
tables/views/whatever, in this database only. Fine.

But for 2), I noticed an inconsistency in the backup file, see
below. The user that is the datdba has the same name ('sthomas') :

...
--
-- Database sthomas
--
\connect template1 sthomas
CREATE DATABASE "sthomas" WITH TEMPLATE = template0 ENCODING = 'SQL_ASCII';
\connect sthomas sthomas

...

This will fail in the case of a database reconstruction (after a crash
for example), because this user is not authorized to create databases,
right ?

I think these lines should look like :

\connect template1 postgres
CREATE DATABASE "sthomas" WITH TEMPLATE = template0 ENCODING = 'SQL_ASCII';
UPDATE pg_database SET datdba = <usesysid-for-sthomas> 
 WHERE datname = 'sthomas' ;
\connect sthomas sthomas


Am I wrong ? Couldn't this be the "standard" pg_dump(|all) behaviour ?

Nicolas.


PS : I can edit manually the dump files, so this isn't really
     important.




view thread (2+ messages)  latest in thread

Message-ID: <vqo65z3oh2z.fsf@imag.fr>
Permalink:  ../vqo65z3oh2z.fsf@imag.fr/
Also on:    postgresql.org/message-id/vqo65z3oh2z.fsf@imag.fr

 · 

reply

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-admin@postgresql.org
  Cc: Nicolas.Kowalski@imag.fr
  Subject: Re: database ownership and dumps
  In-Reply-To: <vqo65z3oh2z.fsf@imag.fr>
  References: <vqo65z3oh2z.fsf@imag.fr>

* 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