Re: C-Function: Returning Rows - Mailing list pgsql-novice

From Tom Lane
Subject Re: C-Function: Returning Rows
Date
Msg-id 8313.1273502329@sss.pgh.pa.us
Whole thread Raw
In response to C-Function: Returning Rows  (Carel Combrink <s25291930@tuks.co.za>)
Responses Re: C-Function: Returning Rows  (Carel Combrink <s25291930@tuks.co.za>)
List pgsql-novice
Carel Combrink <s25291930@tuks.co.za> writes:
> in my function I have the following:
>      TupleDesc tup_descriptor;
>      Datum dat_values[2];
>      HeapTuple heap_tuple;
>      bool *pNulls;

>      get_call_result_type(fcinfo, NULL, &tup_descriptor);
>      BlessTupleDesc(tup_descriptor);
>      dat_values[0] = Int32GetDatum(50);
>      dat_values[1] = Int32GetDatum(20);
>      iTup_Length = tup_descriptor->natts;
>      pNulls = palloc(iTup_Length * sizeof(bool));
>      heap_tuple = heap_form_tuple(tup_descriptor, dat_values, pNulls);
>      PG_RETURN_DATUM(HeapTupleGetDatum(heap_tuple));

> Am I doing something wrong in my function that would have this affect?

Failing to initialize the values of pNulls[], no doubt.

It would also be a good idea to check for a failure result from
get_call_result_type.

BTW, what's the rationale for using a fixed-length Datum array and
a variable-length nulls array?  Usually people handle both of those
the same way.

            regards, tom lane

pgsql-novice by date:

Previous
From: Carel Combrink
Date:
Subject: C-Function: Returning Rows
Next
From: Carel Combrink
Date:
Subject: Re: C-Function: Returning Rows