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 14:38:49 |
Message-ID: | 8313.1273502329@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:
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Carel Combrink | 2010-05-10 15:49:34 | Re: C-Function: Returning Rows |
Previous Message | Carel Combrink | 2010-05-10 10:12:17 | C-Function: Returning Rows |