Re: Is there a way to test for UNASSIGNED in pl/pgsql

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Is there a way to test for UNASSIGNED in pl/pgsql
Дата
Msg-id CAFj8pRAB5vQqdy=UjS7TD5+xK8XqNz=gmX0Ga8sch-_c_X7gHQ@mail.gmail.com
обсуждение исходный текст
Ответ на Is there a way to test for UNASSIGNED in pl/pgsql  (Hannu Krosing <hannu@2ndQuadrant.com>)
Ответы Re: Is there a way to test for UNASSIGNED in pl/pgsql
Список pgsql-hackers
Hello


2012/10/29 Hannu Krosing <hannu@2ndquadrant.com>:
> Hi
>
> Is there a way to test for a variable being unassigned in pl/pgsql ?
>
> I'm writing an audit trigger where I'd like to save full before and
> after images into audit log and I really do not like to do
>
> IF TG_OP IN ('INSERT', 'UPDATE') ...
>
> I'd like rather better if i could just write
>
> IF NEW IS ASSIGNED THEN ...
>
> or even use it straight
>
> null_if_unnasigned(NEW)
>
> overriding
>
> coalesce(NEW, NULL)
>
> for the same purpose would also be ok
>

I don't know about any way, how to do it. It is little bit hard,
because it means test of state plpgsql variable (and plpgsql property)
from SQL expression, and it is not possible from SQL.

we can design some new variant of IF statement, where parameter is
test of validity some variable instead SQL expression

some like

IF DEFINED NEW THEN ...

Regards

Pavel Stehule


> ---------------------
> Hannu
>



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

Предыдущее
От: Claudio Freire
Дата:
Сообщение: Re: [PATCH] Prefetch index pages for B-Tree index scans
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: Is there a way to test for UNASSIGNED in pl/pgsql