On Tue, Jun 16, 2009 at 6:30 AM, Stephen Frost<sfrost@snowman.net> wrote:
> * Robert Haas (robertmhaas@gmail.com) wrote:
>> As I look at this, another problem is that it seems to me that you're
>> assuming that VARDATA_ANY() will return an aligned pointer, which
>> isn't necessarily the case (see src/include/postgres.h).
>
> I believe you need to look at it more carefully. I don't think it's
> making any such assumption. Specifically, it has three loops; an "until
> we're aligned" loop, then a "while we're aligned", and a "when we've
> done all the aligned we could do".
I see that... but I don't think the test in the first loop is correct.It's based on the value of i % 4, but I'm not
convincedthat you know
anything about the alignment at the point where i == 0.
I might be all wet here, I haven't looked at this area of the code in detail.
> On the flip side, I am curious as to if the arguments to a stored
> procedure are always aligned or not. Never had a case to care before,
> but if palloc() is always going to return an aligned chunk of memory
> (per MemSetAligned in c.h) it makes me wonder.
Well, if it's char(n) for n <~ 126, it's going to have a 1-byte
varlena header...
...Robert