Using a composite SQL type in C

From: "Dan \"Heron\" Myers" <heron(at)xnapid(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Using a composite SQL type in C
Date: 2008-05-07 23:29:32
Message-ID: 48223B5C.9060109@xnapid.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a type defined in SQL:

CREATE TYPE text_info AS (str text, id integer);

I'd like to use this type as the aggregate type in an aggregate function:

CREATE FUNCTION foobar(text_info,integer,text,text) RETURNS text_info AS
'$libdir/plugins/mylib.dll', 'foobar' LANGUAGE C;

CREATE AGGREGATE foobar(integer,text,text) (SFUNC = foobar, STYPE =
text_info);

My problem is, how do I access this type in my function (in C), and how
do I create a new object of this type to return from the function? I
need to store both a text and an int, to avoid doing an extra query
around the result of this aggregate (to get the corresponding text
value), which is what I'm currently doing. Any ideas?

Thanks,
Dan

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Toby Chavez 2008-05-08 00:02:29 Re: Custom Base Type in C
Previous Message Alvaro Herrera 2008-05-07 23:15:10 Re: Custom Base Type in C