Re: C-Function: Returning Rows

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: C-Function: Returning Rows
Дата
Msg-id 11969.1273509896@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: C-Function: Returning Rows  (Carel Combrink <s25291930@tuks.co.za>)
Ответы Re: C-Function: Returning Rows  (Carel Combrink <s25291930@tuks.co.za>)
Список pgsql-novice
Carel Combrink <s25291930@tuks.co.za> writes:
> I've added a line to initialize the values like follow:
>     malloc(pNulls, false, iTup_Length * sizeof(bool));
> and it works perfectly each time.

malloc?  malloc doesn't guarantee to deliver pre-zeroed storage, though
it might happen to look like that if you don't test very thoroughly.
You've likely also got a problem with leaking the storage, unless you
remember to free it explicitly.  Personally I'd have used palloc0.

> I noted, if using fixed-length nulls array I should set the array to
> false also otherwise the same is experienced. Is this supposed to
> happen this way? Is there documentation on this, I tried googling the
> function with no success?

As a general rule, passing an uninitialized input parameter to a
function isn't a good thing ;-).  I can't say how helpful google
might be, but there are certainly plenty of examples of using
heap_form_tuple in the PG source code.

            regards, tom lane

В списке pgsql-novice по дате отправления:

Предыдущее
От: Carel Combrink
Дата:
Сообщение: Re: C-Function: Returning Rows
Следующее
От: Carel Combrink
Дата:
Сообщение: Re: C-Function: Returning Rows