Re: datum passed to macro which expects a pointer

From: Gavin Sherry <swm(at)alcove(dot)com(dot)au>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: datum passed to macro which expects a pointer
Date: 2008-04-12 22:57:55
Message-ID: 20080412225755.GG26250@europa.idg.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

On Sat, Apr 12, 2008 at 06:02:39PM -0400, Tom Lane wrote:
> Gavin Sherry <swm(at)alcove(dot)com(dot)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 Content-Type Size
datum2.diff text/x-diff 2.2 KB

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2008-04-12 23:07:48 Re: datum passed to macro which expects a pointer
Previous Message Tom Lane 2008-04-12 22:02:39 Re: datum passed to macro which expects a pointer