minimal update trigger

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: minimal update trigger
Date: 2008-02-20 02:32:30
Message-ID: 47BB913E.3080401@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


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.

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
|

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Luke Lonergan 2008-02-20 02:54:38 Re: 8.3 / 8.2.6 restore comparison
Previous Message Marc G. Fournier 2008-02-20 01:52:56 gateway test II