Re: Bug in triggers - Mailing list pgsql-bugs

From Chris Travers
Subject Re: Bug in triggers
Date
Msg-id 5ed37b141003090746s2d46abe5o1a952d3f9311e240@mail.gmail.com
Whole thread Raw
In response to Re: Bug in triggers  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: Bug in triggers  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On Tue, Mar 9, 2010 at 7:31 AM, Pavel Stehule <pavel.stehule@gmail.com> wro=
te:
> 2010/3/9 Tom Lane <tgl@sss.pgh.pa.us>:
>> Robert Haas <robertmhaas@gmail.com> writes:
>>> What seems odd to me is that NEW is apparently some other kind of
>>> thing that is not the same kind of thing as the row variable.
>>
>> NEW is a record variable, not a row variable. =A0In this context that's
>> sensible because its actual rowtype is unspecified by the function text.
>> The implications for row-null handling aren't obvious though :-(
>>
>
> is it necessary definition there? This is defined well from context.
>
I am assuming that Tom's previous objections may have to do with
C-language triggers as well but I couldn't tell from reading the docs.
 This may because I am no C-guru.

I think this behavior is unexpected, but not a bug.  The best fix is
documenting the datatype better.  Something like adding a paragraph to
chapter 38.9 just above the examples (going off the 8.4 docs):

Please note, NEW and OLD records are not guaranteed to follow the full
internal representation of the tuple in question.  In some cases (such
as casting to text) this can create subtle differences which make
comparisons problematic.  In some cases you may need to properly cast
NEW and OLD prior to making comparisons.

Best Wishes,
Chris Travers

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: duplicate key violates unique contraint on pg_type_typname_nsp_index
Next
From: Tom Lane
Date:
Subject: Re: Bug in triggers