returning array in a field together with other types

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: pgsql-hackers(at)postgresql(dot)org
Subject: returning array in a field together with other types
Date: 2010-01-29 00:00:26
Message-ID: 20100129010026.0d0a2841@dawn.webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I'm trying to return a set of record as:
(text, int[]),
(text, int[]),
...
row from C
and I really would like to avoid to use BuildTupleFromCString

So this is how I think my function should end...

char *curout; /* cstring */
int4 *pos;

...

get_typlenbyvalalign(INT4OID, &typlen, &typbyval, &typalign);
v_pos = construct_array(
pos,
npos,
INT4OID, typlen, typbyval, typalign
);

values[0] = GET_TEXT(curout); /* correct? */
values[1] = PointerGetDatum(v_pos); /* ???? */

resultTuple = heap_form_tuple(inter_call_data->tupd, values, nulls);
result = HeapTupleGetDatum(resultTuple);

SRF_RETURN_NEXT(fctx, result);

...

I've seen that GET_TEXT(curout) just call textin.
I wonder if other GET_ macro aren't really converting to text
representation and then back to Datum... so there is no real
difference with using BuildTupleFromCString.

BTW could I pass static values to construct_array since they are
"basic type" array so the size etc... should be known at compile
time, inspite of having to call get_typlenbyvalalign?

thanks

--
Ivan Sergio Borgonovo
http://www.webthatworks.it

Browse pgsql-hackers by date

  From Date Subject
Next Message KaiGai Kohei 2010-01-29 00:13:02 Re: [BUG?] strange behavior in ALTER TABLE ... RENAME TO on inherited columns
Previous Message KaiGai Kohei 2010-01-28 23:40:19 Re: Largeobject Access Controls (r2460)