Re: Detecting changes to certain fields in 'before update' trigger functions

From: Sebastian Tennant <sebyte(at)smolny(dot)plus(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Detecting changes to certain fields in 'before update' trigger functions
Date: 2008-12-01 17:48:35
Message-ID: wsejiy6k.fsf@vps203.linuxvps.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Quoth "Richard Broersma" <richard(dot)broersma(at)gmail(dot)com>:
> On Mon, Dec 1, 2008 at 8:35 AM, Sebastian Tennant
> <sebyte(at)smolny(dot)plus(dot)com> wrote:
>>>> IF (NEW.<column-name> != OLD.<column-name>) THEN ...
>>>
>>> IF( NEW.* IS DISTINCT FROM OLD.* ) THEN ...
>>>
>> I sometimes think this kind of gotcha is purposely buried, or not
>> addressed at all, in order to force users to read the manual.
>
> I wouldn't say it is intentionally buried. I would say that the
> PostgreSQL manual focuses primarily is on "What are the PG features".
> While the manual may at times document some of the good/best practices
> to use by combining various PG features, I wouldn't say that its
> intention isn't to be an authoritative source on "How to use PG
> features."
>
> On the other hand, there are many ANSI-SQL books that focus on good
> practices. For example, the need for the "IS DISTINCT FROM" when
> dealing with nulls would be discussed in an SQL book. Once you have
> the theory down, you can turn to the PostgreSQL manual to find out how
> PostgreSQL implements this functionality.

That's sound advice and I take your point about the manual focussing on
Postgre features rather than SQL per se. I have read one or two SQL
books but I'm very much a learn by doing person... and the fact is, I
haven't done much doing, until now.

May I wriggle out a little by saying that I didn't really mean what I
said, or rather, I failed to say what I really meant; that it sometimes
feels as if a gotcha has been buried in order to make you read the
manual.

Sebastian

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Malinka Rellikwodahs 2008-12-01 17:56:24 Re: db backup script in gentoo
Previous Message Owen Hartnett 2008-12-01 17:46:18 Re: pg_dump restore as transaction?