Re: preferred way to use PG_GETARG_BYTEA_P in SPI - Mailing list pgsql-general

From Tom Lane
Subject Re: preferred way to use PG_GETARG_BYTEA_P in SPI
Date
Msg-id 2580.1192125128@sss.pgh.pa.us
Whole thread Raw
In response to Re: preferred way to use PG_GETARG_BYTEA_P in SPI  ("Merlin Moncure" <mmoncure@gmail.com>)
List pgsql-general
"Merlin Moncure" <mmoncure@gmail.com> writes:
> well, there aren't all that many examples in contrib, and some of the
> ones that are there look like this (edited) from tsearch2:

> Datum
> rewrite_accum(PG_FUNCTION_ARGS)
> {
>     QUERYTYPE  *acc = (QUERYTYPE *) PG_GETARG_POINTER(0);
>     ArrayType  *qa = (ArrayType *)
> DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(1)));
>     if (acc == NULL || PG_ARGISNULL(0))
>     {

That might be safe but it sure looks like bad practice to me.
In particular I think it's unwise to assume that the Datum value
for a null will always be zero.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: XMIN semantic at peril ?
Next
From: Chris Travers
Date:
Subject: Feature request: SSL Client Cert Authentication