pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedpg_dump object dump-order
2+ messages / 2 participants
[nested] [flat]
* pg_dump object dump-order
@ 2007-08-28 16:08 KL <zappa_lot@gmx.net>
2007-08-28 20:32 ` Re: pg_dump object dump-order Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 2+ messages in thread
From: KL @ 2007-08-28 16:08 UTC (permalink / raw)
To: pgsql-admin
Greetings
I'm working with PostgreSQL for quite some time now
but only yesterday ran into a specific problem, as - so far -
I have always used customized backup/restore-scripts.
PROBLEM:
pg_dump seems to dump objects strictly alphabetically,
I presume. Hence a table "events" is always dumped
_before_ any sequence "events_id_seq" that is already
being referenced in the "create table"-statement for
table "events".
Example
CREATE TABLE event (
event_id integer DEFAULT nextval('event_id_seq'::text) NOT NULL,
.
.
.
);
ALTER TABLE public.event OWNER TO someuser;
--
-- Name: event_id_seq; Type: SEQUENCE; Schema: public; Owner: someuser
--
CREATE SEQUENCE event_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
This ordering results in an error upon importing the data
with "psql".
QUESTION:
Is there any solution/option/trick/secret/whatever
to make pg_dump export referenced objects _before_
they are being referenced?
Thanks in advance
PS:
The thing isn't really urgent, as I have my "custom"-scripts
anyway, but it could be convenient to just have pg_dump
and psql as reliable, "out-of-the-box"-fallback-options.
I searched the lists here and also googled the whole day,
but couldn't find anything appropriate. Should there be
a thread about this issue already, I'd like to apologize
in advance.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: pg_dump object dump-order
2007-08-28 16:08 pg_dump object dump-order KL <zappa_lot@gmx.net>
@ 2007-08-28 20:32 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2007-08-28 20:32 UTC (permalink / raw)
To: KL <zappa_lot@gmx.net>; +Cc: pgsql-admin
KL <zappa_lot@gmx.net> writes:
> pg_dump seems to dump objects strictly alphabetically,
No, it doesn't ... at least not if you are running 8.0 or later.
It looks at dependencies to see what has to be dumped first.
(It does prefer alpha order when there's no dependency constraint.)
There are various situations where there might not be a dependency
entry, but without knowing more about the history of the table and
exactly which version you're running, it's hard to speculate about
why or what's the best fix.
I will point out, however, that the given script does not in fact
fail to load in any Postgres version known to me. Maybe you should
post your real problem instead of an oversimplified example.
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2007-08-28 20:32 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-08-28 16:08 pg_dump object dump-order KL <zappa_lot@gmx.net>
2007-08-28 20:32 ` Tom Lane <tgl@sss.pgh.pa.us>
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