Re: minimal update trigger

From: David Fetter <david(at)fetter(dot)org>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: minimal update trigger
Date: 2008-02-20 15:02:36
Message-ID: 20080220150236.GA21436@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Feb 19, 2008 at 09:32:30PM -0500, Andrew Dunstan wrote:
>
> As discussed a little while back, I would like to add a generic
> trigger function which will force an update to skip if the new and
> old tuples are identical.

This one has lots of use cases. Did the earlier discussion settle on
whether there should be a GUC and/or CREATE DATABASE and/or initdb
option for this?

Cheers,
David.
>
> The guts of this is the following snippet of code:
>
> | rettuple = newtuple = trigdata->tg_newtuple;
> oldtuple = trigdata->tg_trigtuple;
>
> if (newtuple->t_len == oldtuple->t_len &&
> newtuple->t_data->t_hoff == oldtuple->t_data->t_hoff &&
> HeapTupleHeaderGetNatts(newtuple->t_data) == HeapTupleHeaderGetNatts(oldtuple->t_data) &&
> (newtuple->t_data->t_infomask & ~HEAP_XACT_MASK) ==
> (oldtuple->t_data->t_infomask & ~HEAP_XACT_MASK) &&
> memcmp(((char *)newtuple->t_data) + offsetof(HeapTupleHeaderData, t_bits),
> ((char *)oldtuple->t_data) + offsetof(HeapTupleHeaderData, t_bits),
> newtuple->t_len - offsetof(HeapTupleHeaderData, t_bits)) == 0)
> {
> rettuple = NULL;
> }
>
> return rettuple;
>
>
> I propose to call the function pg_minimal_update.
>
> Unless there is an objection I will put together a patch + docs for this shortly. Not quite sure what section of the docs to put it in - maybe a new subsection of the Functions chapter?
>
>
> cheers
>
> andrew
> |
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend

--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dimitri Fontaine 2008-02-20 15:06:53 Re: Permanent settings
Previous Message Andrew Dunstan 2008-02-20 14:42:02 Re: Permanent settings