Re: preferred way to use PG_GETARG_BYTEA_P in SPI

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: preferred way to use PG_GETARG_BYTEA_P in SPI
Дата
Msg-id 2580.1192125128@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: preferred way to use PG_GETARG_BYTEA_P in SPI  ("Merlin Moncure" <mmoncure@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: XMIN semantic at peril ?
Следующее
От: Chris Travers
Дата:
Сообщение: Feature request: SSL Client Cert Authentication