Re: Something's been bugging me

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: "PostgreSQL-development Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Something's been bugging me
Date: 2007-09-30 20:05:17
Message-ID: 27632.1191182717@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gregory Stark <stark(at)enterprisedb(dot)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 like
memcpy((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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gregory Stark 2007-09-30 22:23:42 Re: Something's been bugging me
Previous Message Stefan Kaltenbrunner 2007-09-30 18:26:46 Re: First steps with 8.3 and autovacuum launcher