Re: pg_dump and DEFAULT column values

Поиск
Список
Период
Сортировка
От Eric Ridge
Тема Re: pg_dump and DEFAULT column values
Дата
Msg-id D3ADE25911614840BC69C72E3171E4ED028131@tcdiexch.tcdi.com
обсуждение исходный текст
Ответ на pg_dump and DEFAULT column values  ("Eric Ridge" <ebr@tcdi.com>)
Ответы Re: pg_dump and DEFAULT column values
Список pgsql-general
> Hmm.  I think you should think hard about why you believe that the
> default has to work that way and you can't just use a sequence.
> You're paying a high price to conform to what seems a very
> questionable set of assumptions.

I use the field for sorting, and since the client application has the
ability to change the value of this field, it is possible they could set
it to a number larger than the next value of the sequence.  then an
insert of a new record would appear before the changed record, instead
of after it.

> The circular reference problem arises because SQL-language functions
> are parsed and checked at CREATE FUNCTION time.  A cheezy way to get
> around it is to define the function before the table, but write it in
> a PL language --- presently, at least, PL function definitions are not
> checked until first use.  So you could do

I ended up creating a "before on insert" trigger in plpgsql.  pg_dump
seems to like this, and it gives me the ability to easily change how I
find the default value for this field.


And thanks for your time.  It is very much appreciated.

eric

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: pg_dump and DEFAULT column values
Следующее
От: Francisco Reyes
Дата:
Сообщение: Re: My new job with SRA