returning array in a field together with other types - Mailing list pgsql-hackers

From Ivan Sergio Borgonovo
Subject returning array in a field together with other types
Date
Msg-id 20100129010026.0d0a2841@dawn.webthatworks.it
Whole thread Raw
List 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



pgsql-hackers by date:

Previous
From: KaiGai Kohei
Date:
Subject: Re: Largeobject Access Controls (r2460)
Next
From: KaiGai Kohei
Date:
Subject: Re: [BUG?] strange behavior in ALTER TABLE ... RENAME TO on inherited columns