Re: plpgsql/rule question

Поиск
Список
Период
Сортировка
От Ed L.
Тема Re: plpgsql/rule question
Дата
Msg-id 200501112053.54728.pgsql@bluepolka.net
обсуждение исходный текст
Ответ на Re: plpgsql/rule question  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: plpgsql/rule question  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Tuesday January 11 2005 8:40, Tom Lane wrote:
> >
> > Is it possible to distinguish within plpgsql between these two queries?
> >
> >     insert into foo (msg) values ('Hello')
> >     insert into foo (id, msg) values (NULL, 'Hello')
>
> Well, yes, because the default value in the former case will not be
> NULL.  But in general a trigger function cannot tell whether a field
> value that happens to equal the default was explicitly specified or
> defaulted.  All it can see is the proposed field value; not how that
> value was arrived at.

Bad example, but you saw what I was after.  Is that also true for NULL
values for NEW.id in foo_insert() in the following example?

    create view foo_view as select * from foo_table;
    create table foo_table (id serial, msg varchar);
    create function foo_insert that inserts NEW.* into foo_table
    create rule that calls foo_insert(NEW) on insert to foo_view

The reason I ask is because I'd like to allow any explicitly specified
values for the view insert, including NULL, to be passed through to the
table insert and override the column defaults.

Ed


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Bug in pg_dump in 7.4.6?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: plpgsql/rule question