pg_shadow dump annoying problem

From: Gaetano Mendola <mendola(at)bigfoot(dot)com>
To: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: pg_shadow dump annoying problem
Date: 2003-11-10 00:10:58
Message-ID: 3FAED792.5010508@bigfoot.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi all,
doing a postgres dump I a couple of time in an
annoying problem:

# pg_dumpall -g > pg_user.sql
# head -n 12 pg_user.sql
--
-- PostgreSQL database cluster dump
--

\connect "template1"

--
-- Users
--

DELETE FROM pg_shadow WHERE usesysid <> (SELECT datdba FROM pg_database
WHERE datname = 'template0');

Now if the file pg_user.sql is used accidentally by a user that is not
postgres the result is that all users are deleted ( also the user that
is doing the restore ) and no other user is created.

May be the "DELETE" phase shall be:

DELETE FROM pg_shadow WHERE usesysid <> (SELECT datdba FROM pg_database
WHERE datname = 'template0') AND usename <> current_user;

am I miss something ?

Regards
Gaetano Mendola

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2003-11-10 01:32:53 Re: pg_shadow dump annoying problem
Previous Message Steven Tower 2003-11-09 21:53:23 Re: Database Error (Bogus atrribute number 24....)