Re: C-Function: Returning Rows

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Carel Combrink <s25291930(at)tuks(dot)co(dot)za>
Cc: PostgreSQL Novice List <pgsql-novice(at)postgresql(dot)org>
Subject: Re: C-Function: Returning Rows
Date: 2010-05-10 16:44:56
Message-ID: 11969.1273509896@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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.

> 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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Carel Combrink 2010-05-10 17:24:52 Re: C-Function: Returning Rows
Previous Message Carel Combrink 2010-05-10 15:49:34 Re: C-Function: Returning Rows