From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | David Fetter <david(at)fetter(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: minimal update |
Date: | 2007-11-05 15:03:03 |
Message-ID: | 472F30A7.6070505@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>
>> Tom Lane wrote:
>>
>>> A BEFORE UPDATE trigger would be better, and probably hardly more
>>> expensive than a wired-in facility (especially if you were willing to
>>> write it in C).
>>>
>
>
>> Yes. I also prefer the trigger idea to a rule because triggers are easy
>> to enable and disable. It's still a lot of work for what must be a
>> common want, though. Could it be done generically?
>>
>
> Well, you could write the trigger in C and it'd work for any table.
> I think it could be as simple as a memcmp of the tuples' data areas,
> since we now require padding bytes to be 0 ...
>
>
>
Something like this fragment?
newtuple = trigdata->tg_newtuple;
oldtuple = trigdata->tg_trigtuple;
rettuple = newtuple;
if (newtuple->t_len == oldtuple->t_len &&
newtuple->t_data->t_hoff == oldtuple->t_data->t_hoff &&
memcmp(GETSTRUCT(newtuple),GETSTRUCT(oldtuple),
newtuple->t_len - newtuple->t_data->t_hoff) == 0)
rettuple = NULL;
return PointerGetDatum(rettuple);
Also, when did we first require padding bytes to be 0?
cheers
andrew
From | Date | Subject | |
---|---|---|---|
Next Message | Gokulakannan Somasundaram | 2007-11-05 15:06:13 | Re: Fwd: Clarification about HOT |
Previous Message | Pavan Deolasee | 2007-11-05 14:46:26 | Re: Fwd: Clarification about HOT |