Re: C-Function: Returning Rows

From: Carel Combrink <s25291930(at)tuks(dot)co(dot)za>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: C-Function: Returning Rows
Date: 2010-05-10 17:24:52
Message-ID: 20100510192452.954n91hm2ogs84co@student.up.ac.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Quoting Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:

> Carel Combrink <s25291930(at)tuks(dot)co(dot)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(at)tuks(dot)co(dot)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.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Wilcox 2010-05-11 23:13:08 Out of memory
Previous Message Tom Lane 2010-05-10 16:44:56 Re: C-Function: Returning Rows