Thread: Inconsistent treatment of serials in pg_dump

Inconsistent treatment of serials in pg_dump

From
Josh Berkus
Date:
All,

Just encountered this:

create table josh ( id serial not null, desc text );

pg_dump -Fc -T josh -f no_josh_dump postgres

pg_dump -Fc -t josh -f josh_dump postgres

pg_restore -d new no_josh_dump
pg_restore -d new josh_dump

pg_restore: [archiver (db)] Error from TOC entry 2645; 1259 49910
SEQUENCE josh_id_seq postgres
pg_restore: [archiver (db)] could not execute query: ERROR:  relation
"josh_id_seq" already exists

It seems that if I exclude a table using -T, its dependant sequences do
not get excluded.  But if I include it using -t, its dependent sequences
*do* get included.

Is there a reason this is a good idea, or is it just an oversight?

-- 
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com


Re: Inconsistent treatment of serials in pg_dump

From
Tom Lane
Date:
Josh Berkus <josh@agliodbs.com> writes:
> It seems that if I exclude a table using -T, its dependant sequences do
> not get excluded.  But if I include it using -t, its dependent sequences
> *do* get included.

> Is there a reason this is a good idea, or is it just an oversight?

It's not immediately clear to me that those switches ought to be exact
inverses.

As a counterexample, consider the case where multiple tables share the
same sequence.  Suppressing one of the tables with -T ought not lead to
suppressing the sequence.
        regards, tom lane


Re: Inconsistent treatment of serials in pg_dump

From
Josh Berkus
Date:
> As a counterexample, consider the case where multiple tables share the
> same sequence.  Suppressing one of the tables with -T ought not lead to
> suppressing the sequence.

Now, that's a good point.  And I don't expect that pg_dump can
distinguish between a serial and an sequence with a dependency?

-- 
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com


Re: Inconsistent treatment of serials in pg_dump

From
Alvaro Herrera
Date:
Excerpts from Josh Berkus's message of lun may 09 16:43:10 -0400 2011:

> Now, that's a good point.  And I don't expect that pg_dump can
> distinguish between a serial and an sequence with a dependency?

They're the same thing, so no.

-- 
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support