Re: pg_dump and DEFAULT column values

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Eric Ridge" <ebr(at)tcdi(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: pg_dump and DEFAULT column values
Date: 2001-11-06 21:36:19
Message-ID: 21436.1005082579@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Eric Ridge" <ebr(at)tcdi(dot)com> writes:
> I have a function and a table:
> create table foo (
> f1 integer default foo_func();
> );

> create function foo_func returns integer
> as 'select max(f1)+1 from foo'
> language 'sql';

> when I use pg_dump, and then psql (\i <dumpfile>) to dump/reload
> everything, table foo can't be created because it uses foo_func which
> can't be created because it uses a table (foo) which doesn't exist.

pg_dump has a hard time with circular dependencies :-(

Have you considered using a sequence, rather than generating new values
as shown above? The approach you are using is extremely fragile:
consider what happens if two backends try to insert at the same time.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John D. Rozeboom 2001-11-06 21:46:16 Re: self outer join
Previous Message Culley Harrelson 2001-11-06 21:18:18 Re: functions vs embedded SQL