Re: pg_dump and DEFAULT column values

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: pg_dump and DEFAULT column values
Дата
Msg-id 21436.1005082579@sss.pgh.pa.us
обсуждение исходный текст
Ответ на pg_dump and DEFAULT column values  ("Eric Ridge" <ebr@tcdi.com>)
Список pgsql-general
"Eric Ridge" <ebr@tcdi.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

В списке pgsql-general по дате отправления:

Предыдущее
От: Keary Suska
Дата:
Сообщение: Re: Use of Serial Datatype and Sequence Issue
Следующее
От: jd@commandprompt.com (Joshua Drake)
Дата:
Сообщение: Re: Sourceforge moving from PostgreSQL to Oracle