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
|
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend