Re: error creating/setting sequence, pg_dump / pg_restore 8.1.5 - Mailing list pgsql-general

From Tom Lane
Subject Re: error creating/setting sequence, pg_dump / pg_restore 8.1.5
Date
Msg-id 4776.1176567575@sss.pgh.pa.us
Whole thread Raw
In response to error creating/setting sequence, pg_dump / pg_restore 8.1.5  ("Mason Hale" <masonhale@gmail.com>)
Responses Re: error creating/setting sequence, pg_dump / pg_restore 8.1.5  ("Mason Hale" <masonhale@gmail.com>)
List pgsql-general
"Mason Hale" <masonhale@gmail.com> writes:
> After running pg_dump to backup my database, and then running pg_restore to
> load the db (on a different server),
> I run into a problem with creating a sequence.

Hmm ... which sequence is entry.id actually referring to on the source
database?  I suspect that it is linked to some differently-named
sequence like "entry_id_seq1" and the source's "entry_id_seq" is not
in truth doing anything (and, in particular, hasn't ever been advanced,
so when the restore script sets its value to 1 it's clobbering the other
sequence).

The methodology that pre-8.2 pg_dump uses for serial columns is
vulnerable to quite a number of problems if serial sequences don't have
the expected names, and this seems to be another one.  8.2 would be able
to handle the case, but in 8.1 the best advice is to drop the unused
sequence to avoid the name collision when SERIAL picks plain "entry_id_seq"
as the serial sequence's name upon reload.

            regards, tom lane

pgsql-general by date:

Previous
From: "Alain Roger"
Date:
Subject: postgresql 8.1.4 to 8.2.3
Next
From: Martijn van Oosterhout
Date:
Subject: Re: indexing array columns