Re: C-Function: Returning Rows

Поиск
Список
Период
Сортировка
От Carel Combrink
Тема Re: C-Function: Returning Rows
Дата
Msg-id 20100510192452.954n91hm2ogs84co@student.up.ac.za
обсуждение исходный текст
Ответ на Re: C-Function: Returning Rows  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Quoting Tom Lane <tgl@sss.pgh.pa.us>:

> 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.
>

Sorry I'm sleep deprived :P
Used memset NOT malloc... If you look at the arguments you'll see I'm
using memset not malloc since malloc only takes the size as argument.

Sorry but thanks for the valued help

>> 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
>



--
Carel Combrink
s25291930@tuks.co.za

This message and attachments are subject to a disclaimer. Please refer
to www.it.up.ac.za/documentation/governance/disclaimer/ for full
details. / Hierdie boodskap en aanhangsels is aan 'n vrywaringsklousule
onderhewig. Volledige besonderhede is by
www.it.up.ac.za/documentation/governance/disclaimer/ beskikbaar.



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: C-Function: Returning Rows
Следующее
От: Atif Jung
Дата:
Сообщение: Interrupt