From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Hannu Krosing <hannu(at)2ndquadrant(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Is there a way to test for UNASSIGNED in pl/pgsql |
Date: | 2012-10-29 17:05:16 |
Message-ID: | CAFj8pRDP-BntGXTrud=LJTY0QW_c-gJ0yDErRL7hxqmq7w5LCA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2012/10/29 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Hannu Krosing <hannu(at)2ndQuadrant(dot)com> writes:
>> Would just converting UNDEFINED to NULL be a very bad idea ?
>
> Yeah, it would, at least for the normal case where an undefined record
> variable has no well-defined type either. Saying that it's NULL doesn't
> provide an answer to what type it has.
>
> In the case of OLD/NEW we do know that they ought to have the rowtype of
> the underlying table, so it's conceivable that we could pretend they are
> nulls of that type. But then you get into the question of whether a
> NULL record is distinguishable from (NULL, NULL, ...) --- which would be
> a perfectly legal real value of these records. Note that the SQL
> standard is pretty firmly on the side that says they are not
> distinguishable. I don't agree with that personally, but I don't think
> it'd be a good idea to make a fundamental plpgsql feature depend on
> being able to distinguish these states.
>
> TBH, I think your request is ill-considered and should be rejected.
> There is nothing whatsoever wrong with testing TG_OP to see what sort of
> trigger you're in.
+1
we can define two vars TG_NEW_IS_VALID and TG_OLD_IS_VALID.
and then you can write test
IF TG_NEW_IS_VALID THEN
-- do some with NEW
ELSE
-- ...
END IF;
Regards
Pavel
>
> regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Cédric Villemain | 2012-10-29 19:17:05 | Re: [PATCH] Prefetch index pages for B-Tree index scans |
Previous Message | Pavel Stehule | 2012-10-29 17:00:57 | Re: Is there a way to test for UNASSIGNED in pl/pgsql |