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  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 xi = 1;
    float8 yi = 2;

    float8 xe = 3;
    float8 ye = 4;

    int32 id = 1;

    bool isnull;

    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 по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: do we want to gitignore regression-test-failure files?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: do we want to gitignore regression-test-failure files?