Re: datum passed to macro which expects a pointer - Mailing list pgsql-patches

From Gavin Sherry
Subject Re: datum passed to macro which expects a pointer
Date
Msg-id 20080412225755.GG26250@europa.idg.com.au
Whole thread Raw
In response to Re: datum passed to macro which expects a pointer  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: datum passed to macro which expects a pointer  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: datum passed to macro which expects a pointer  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
On Sat, Apr 12, 2008 at 06:02:39PM -0400, Tom Lane wrote:
> Gavin Sherry <swm@alcove.com.au> writes:
> > This may seem a little pedantic but I noticed a few places where we pass
> > a datum to a macro which treats the datum as a pointer. This works now
> > but might not in the future (if, say, Datum were to be 8 bytes).
>
> Yeah, definitely something to fix.  I think though that the cases
> like this:
>
> > !     PG_RETURN_TEXT_P(DatumGetPointer(result));
>
> might as well just use PG_RETURN_DATUM instead of casting twice.

Oh of course. Updated patch attached.

>
> Was this just eyeball inspection or did you find a compiler that would
> complain about this?

I wish. It was actually thrown up when we (Greenplum) changed the macros
to be inline functions as part of changing Datum to be 8 bytes. By using
inline functions we get proper type checking from the compiler and since
we have only a small number of target platforms and architectures,
inlining isn't an issue.

Thanks,

Gavin

Attachment

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: datum passed to macro which expects a pointer
Next
From: Tom Lane
Date:
Subject: Re: datum passed to macro which expects a pointer