pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedpg_shadow dump annoying problem
3+ messages / 2 participants
[nested] [flat]
* pg_shadow dump annoying problem
@ 2003-11-10 00:10 Gaetano Mendola <mendola@bigfoot.com>
2003-11-10 01:32 ` Re: pg_shadow dump annoying problem Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Gaetano Mendola @ 2003-11-10 00:10 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pg_shadow dump annoying problem
2003-11-10 00:10 pg_shadow dump annoying problem Gaetano Mendola <mendola@bigfoot.com>
@ 2003-11-10 01:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2003-11-10 19:05 ` Re: pg_shadow dump annoying problem Gaetano Mendola <mendola@bigfoot.com>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2003-11-10 01:32 UTC (permalink / raw)
To: Gaetano Mendola <mendola@bigfoot.com>; +Cc: pgsql-admin
Gaetano Mendola <mendola@bigfoot.com> writes:
> [ pg_dumpall emits this: ]
> 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.
How so? If that deletes all users then you have already removed the
user who owns template0, ie, the user who did initdb. That is a really
bad idea.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pg_shadow dump annoying problem
2003-11-10 00:10 pg_shadow dump annoying problem Gaetano Mendola <mendola@bigfoot.com>
2003-11-10 01:32 ` Re: pg_shadow dump annoying problem Tom Lane <tgl@sss.pgh.pa.us>
@ 2003-11-10 19:05 ` Gaetano Mendola <mendola@bigfoot.com>
0 siblings, 0 replies; 3+ messages in thread
From: Gaetano Mendola @ 2003-11-10 19:05 UTC (permalink / raw)
To: pgsql-admin; +Cc: Tom Lane <tgl@sss.pgh.pa.us>
Tom Lane wrote:
> Gaetano Mendola <mendola@bigfoot.com> writes:
>
>>[ pg_dumpall emits this: ]
>>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.
>
>
> How so? If that deletes all users then you have already removed the
> user who owns template0, ie, the user who did initdb. That is a really
> bad idea.
I didn't say this, I just wrote that if the file generated is used
by a user different the postgres will result in a disaster, and may be is
better not delete all the user except the user that own template0 but
not delete the user that own template0 and the current_user.
Regards
Gaetano Mendola
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2003-11-10 19:05 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-11-10 00:10 pg_shadow dump annoying problem Gaetano Mendola <mendola@bigfoot.com>
2003-11-10 01:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2003-11-10 19:05 ` Gaetano Mendola <mendola@bigfoot.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