Search Postgresql Archives

Re: preferred way to use PG_GETARG_BYTEA_P in SPI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Merlin Moncure" <mmoncure@xxxxxxxxx> 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

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux