Re: Foreign key pg_dump issue and serial column type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Vsevolod (Simon) Ilyushchenko" <simonf(at)cshl(dot)edu>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Foreign key pg_dump issue and serial column type
Date: 2005-06-30 01:15:46
Message-ID: 1391.1120094146@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Vsevolod (Simon) Ilyushchenko" <simonf(at)cshl(dot)edu> writes:
> However, when I pg_dump the database and import it on another server,
> the tables are exported alphabetically, so when the 'people_roles' table
> is created with its foreign keys, the table 'roles' does not exist yet.
> Thus, the foreign key creation fails. Is there a way around it?

Are you sure you are using 8.0 pg_dump? That's a longstanding
deficiency in older versions, but 8.0 is not supposed to have a problem
with it. If you're sure it's an up-to-date pg_dump, could you provide a
complete test case (ie, a script to create a database that pg_dump has
trouble with)?

> 2. I've just discovered the 'serial' column type and tried to do this:
> alter table people_roles alter column people_roles_code type serial;
> To my surprise, it fails:
> ERROR: type "serial" does not exist

Serial isn't quite a true type, and so it doesn't work in every context
that you might think. It'd probably make sense for "alter column type"
to accept it, but for now what you gotta do is create a sequence
and set the column default manually.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2005-06-30 03:56:21 Re: Error saving image to PostgresSQL 8.x database
Previous Message Vsevolod (Simon) Ilyushchenko 2005-06-30 00:25:55 Foreign key pg_dump issue and serial column type