Re: user defined type

From: Kjetil Haaland <kjetil(dot)haaland(at)student(dot)uib(dot)no>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: user defined type
Date: 2004-11-19 14:42:24
Message-ID: 200411191542.24292.kjetil.haaland@student.uib.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2004-11-19 15:16:10 Re: user defined type
Previous Message Raphael Bauduin 2004-11-19 10:20:54 Re: setting custom session variables?