triggers: how to check if a field changed?

From: <me(at)alternize(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: triggers: how to check if a field changed?
Date: 2005-08-30 00:46:58
Message-ID: 02c101c5acfc$540f44b0$6402a8c0@iwing
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

hi list

for our discussion board i've successfully set up a trigger to have tsearch2 index the record every time it is updated. this works fine, but also triggers the reindex of the record every time i update the "# of views" counter, which creates unnecessary load. in a trigger, is there a way to check the fields affected by the UPDATE query? i only want to have the tsearch2 index updated when the indexed field (p_msg_raw) changed...

this is the current trigger (straight following the tsearch2 guide):

CREATE TRIGGER "posts_ts_update" BEFORE INSERT OR UPDATE
ON "forum"."posts" FOR EACH ROW
EXECUTE PROCEDURE "public"."tsearch2"(idxfti, p_msg_raw);

thanks in advance,
thomas

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Prasad dev 2005-08-30 03:00:30 Disabling Trigger
Previous Message Andreas 2005-08-29 20:30:48 message dupes anyone ?