Re: Using a composite SQL type in C

From: "Toby Chavez" <odnamr(at)gmail(dot)com>
To: "Dan Heron Myers" <heron(at)xnapid(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Using a composite SQL type in C
Date: 2008-05-08 17:11:26
Message-ID: a2987f9e0805081011g12cdd67dn2e49a6e3f621e4df@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Check the documentation about using composite-type arguments in C
http://www.postgresql.org/docs/8.2/static/xfunc-c.html#AEN37402

You can use GetAttributeByNum() or GetAttributeByName() to get each value
from your custom type. You will need to get the HeapTupleHeader first by
calling PG_GETARG_HEAPTUPLEHEADER(). A quick google search brought up this
tutorial that might help http://linuxgazette.net/142/peterson.html

Cheers

>
> 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?
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2008-05-08 17:14:34 Re: statistics collector process is thrashing my cpu
Previous Message Shane Ambler 2008-05-08 16:02:58 Re: Problems with memory