Re: Something's been bugging me - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Something's been bugging me
Date
Msg-id 27632.1191182717@sss.pgh.pa.us
Whole thread Raw
In response to Re: Something's been bugging me  (Gregory Stark <stark@enterprisedb.com>)
Responses Re: Something's been bugging me
Re: Something's been bugging me
List pgsql-hackers
Gregory Stark <stark@enterprisedb.com> writes:
> Here's a patch that does all of the above. 

Applied with tweak to use the added byte as an actual length word.

I ran into an interesting failure here on HPPA: the code the compiler
generated for copying unaligned toast pointers into aligned local
variables failed, because it was assuming halfword (2-byte) alignment of
the data to be copied!  (Instead of a memcpy call it was generating an
inline loop of ldh/sth instructions.)  Apparently gcc's thought process
is "the pointer is declared as struct varlena *, therefore must be at
least 4-aligned, therefore the data at offset 2 is at least 2-aligned".
The intermediate cast to "varattrib_1b_e *" did not prevent this; I
had to assign the datum pointer into a separate local variable of that
type to suppress the "optimization".

I'm not sure if the gcc boys would consider this a bug or not; I kinda
suspect the behavior is intentional, because otherwise they'd not be
able to optimize constructs likememcpy((char *) &foo, ...)
which is a pretty darn widespread locution.

Anyway, it seems to work now, I just thought I'd put something in the
archives about what that VARATT_EXTERNAL_GET_POINTER macro is for.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Stefan Kaltenbrunner
Date:
Subject: Re: First steps with 8.3 and autovacuum launcher
Next
From: Gregory Stark
Date:
Subject: Re: Something's been bugging me