forming tuple as an attribute inside another tuple in c function

From: Marios Vodas <mvodas(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: forming tuple as an attribute inside another tuple in c function
Date: 2010-09-26 20:20:42
Message-ID: AANLkTinJv16K-XE=dPETr3DvGU+zU9P1GaPsH76Vs5rO@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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));
}

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-09-26 20:28:20 Re: do we want to gitignore regression-test-failure files?
Previous Message Robert Haas 2010-09-26 20:19:11 Re: do we want to gitignore regression-test-failure files?