Re: Column Default Clause and User Defined Functions

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Column Default Clause and User Defined Functions
Дата
Msg-id 20676.1183006919@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Column Default Clause and User Defined Functions  (Michael Glaesemann <grzm@seespotcode.net>)
Ответы Re: Column Default Clause and User Defined Functions  (Michael Glaesemann <grzm@seespotcode.net>)
Список pgsql-general
Michael Glaesemann <grzm@seespotcode.net> writes:
> On Jun 27, 2007, at 18:18 , Keary Suska wrote:
>> Is it possible to have a user-defined function (a plpqsql function)
>> as the
>> argument to a default clause that issues SELECTs on other tables?

> Not according to the documentation:
> http://www.postgresql.org/docs/8.2/interactive/sql-createtable.html

What those docs say is that you can't have a naked sub-SELECT in the
DEFAULT expression.  This is to some extent an implementation limitation
--- we don't do planning on DEFAULT expressions.  You can definitely get
around it by hiding the sub-SELECT in a function.

Whether that is a good idea is another question entirely ... it seems
a bit questionable, but on the other hand time-varying defaults like
"default now()" have time-honored usefulness, so I'm not quite sure
why I feel uncomfortable with it.

            regards, tom lane

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

Предыдущее
От: "Luki Rustianto"
Дата:
Сообщение: Pg7.4.x plpgsql trigger execution order bug
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Pg7.4.x plpgsql trigger execution order bug