Re: minimal update - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: minimal update
Date
Msg-id 4775DDBD.4050005@dunslane.net
Whole thread Raw
In response to Re: minimal update  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers

Andrew Dunstan wrote:
>
>
> Tom Lane wrote:
>> Andrew Dunstan <andrew@dunslane.net> writes:
>>  
>>> How does this look?
>>>     
>>
>>  
>>>     if (newtuple->t_len == oldtuple->t_len &&
>>>         newtuple->t_data->t_hoff == oldtuple->t_data->t_hoff &&
>>>         HeapTupleHeaderGetNatts(newtuple) == 
>>> HeapTupleHeaderGetNatts(oldtuple) &&
>>>         (newtuple->t_data->t_infomask & (HEAP_HASOID|HEAP_HASNULL)) 
>>> == (oldtuple->t_data->t_infomask & (HEAP_HASOID|HEAP_HASNULL)) &&
>>>         memcmp(newtuple->t_data + offsetof(HeapTupleHeaderData, 
>>> t_bits),
>>>                oldtuple->t_data + offsetof(HeapTupleHeaderData, t_bits)
>>>                newtuple->t_len - offsetof(HeapTupleHeaderData, 
>>> t_bits)) == 0)
>>>     
>>
>>  
>>>       rettuple = NULL;
>>>     
>>
>> Looks sane.  It might be even saner if you compare all of the
>> non-visibility-related infomask bits, viz
>>
>>     (newtuple->t_data->t_infomask & ~HEAP_XACT_MASK) ==
>>     (oldtuple->t_data->t_infomask & ~HEAP_XACT_MASK)
>>
>> rather than just HASOID and HASNULL.
>>
>>            
>>   
>
> Sadly, the memcmp is failing on my test ("update foo set bar = bar") 
> on 8.2. Looks like I'm in for weekend with my fave debugger :-(
>
>

Turns out we needed those pointers used in the arguments to memcmp cast 
to char * so the pointer arithmetic would work right.

I'll be suggesting we add a utility function like this for 8.4.

cheers

andrew


pgsql-hackers by date:

Previous
From: Mark Mielke
Date:
Subject: Re: Spoofing as the postmaster
Next
From: Magnus Hagander
Date:
Subject: Re: Spoofing as the postmaster