Re: user defined type - Mailing list pgsql-novice

From Kjetil Haaland
Subject Re: user defined type
Date
Msg-id 200411191542.24292.kjetil.haaland@student.uib.no
Whole thread Raw
In response to Re: user defined type  (Michael Fuhr <mike@fuhr.org>)
Responses Re: user defined type  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
On Wednesday 10 November 2004 19:30, Michael Fuhr wrote:
> On Wed, Nov 10, 2004 at 02:37:49PM +0100, Kjetil Haaland wrote:
> > Is there anyway to have two or more strings in one type or do i have to
> > save them both in one string?
>
> PostgreSQL needs all the data in a single buffer.  If you want to
> work with multiple variable-length fields, then you could define a
> structure that's easy for your code to work with and serialize it
> before returning it to PostgreSQL, or one that uses pointers that
> point to the correct places in the buffer.  Your alignres_out()
> function will need to reverse that effect so it can work with the
> data that PostgreSQL passes it.

Hello again
Thanks a lot for all the help!
I have one more question about user defined types. When i create a char
pointer in the alignres_out (the out function of the type) function why is it
always default "alignres_out" ? Is it supposed to be that or have i done
something wrong?

an example:
Datum alignres_out(PG_FUNCTION_ARGS) {
    char *result;
    elog(NOTICE, "result=%s", result);
}
This will give me NOTICE: result=alignres_out.
It is not just in the output function this happens, it is the same in the
input - alignres_in gives default alignres_in.

- Kjetil

pgsql-novice by date:

Previous
From: Raphael Bauduin
Date:
Subject: Re: setting custom session variables?
Next
From: Tom Lane
Date:
Subject: Re: user defined type