Обсуждение: returning array in a field together with other types

Поиск
Список
Период
Сортировка

returning array in a field together with other types

От
Ivan Sergio Borgonovo
Дата:
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