forming tuple as an attribute inside another tuple in c function
От | Marios Vodas |
---|---|
Тема | forming tuple as an attribute inside another tuple in c function |
Дата | |
Msg-id | AANLkTinJv16K-XE=dPETr3DvGU+zU9P1GaPsH76Vs5rO@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: forming tuple as an attribute inside another tuple in c function
|
Список | pgsql-hackers |
Is it posible? Either by using heap_form_tuple or BuildTupleFromCStrings.
CREATE TYPE p_type AS
(
x double precision,y double precision
);
CREATE TYPE d_type AS
(
i p_type,e p_type,id integer
);
CREATE OR REPLACE FUNCTION demo()
RETURNS d_type
AS '/home/user/PostgreSQL/9.0/lib/mylib','demo'
LANGUAGE C STRICT;
Datum demo(PG_FUNCTION_ARGS) {
float8 yi = 2;
float8 xe = 3;
float8 ye = 4;
int32 id = 1;
TupleDesc tupdesc;
Datum values[3];
HeapTuple tuple;
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("function returning record called in context that cannot accept type record")));
}
BlessTupleDesc(tupdesc);
values[0] = ?; //how?
values[1] = ?; //how?
values[2] = Int32GetDatum(id);
tuple = heap_form_tuple(tupdesc, values, &isnull);
PG_RETURN_DATUM(HeapTupleGetDatum(tuple));
В списке pgsql-hackers по дате отправления: