pg_dump and DEFAULT column values
| От | Eric Ridge |
|---|---|
| Тема | pg_dump and DEFAULT column values |
| Дата | |
| Msg-id | D3ADE25911614840BC69C72E3171E4ED0FBDFF@tcdiexch.tcdi.com обсуждение исходный текст |
| Ответы |
Re: pg_dump and DEFAULT column values
|
| Список | pgsql-general |
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.
So I always have to hand-edit the dump file:
create table foo (
f1 integer;
);
create function foo_func returns integer
as 'select max(f1) from foo'
language 'sql';
alter table foo alter column f1 set default foo_func();
Is there a way for pg_dump to do this automagically? or should I define
the table and function differently? Should the default value be
replaced with an on insert trigger?
eric
В списке pgsql-general по дате отправления: