Re: Fixed length datatypes. WAS [GENERAL] UUID's as

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, mark(at)mark(dot)mielke(dot)cc, Thomas Hallgren <thomas(at)tada(dot)se>, Josh Berkus <josh(at)agliodbs(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, "A(dot)M(dot)" <agentm(at)themactionfaction(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fixed length datatypes. WAS [GENERAL] UUID's as
Date: 2006-07-01 14:48:09
Message-ID: 20060701144809.GG24775@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Sat, Jul 01, 2006 at 10:37:59AM -0400, Tom Lane wrote:
> > Where these input/output functions would work for any given length, so
> > the 16 could be replaced by any number, or even -1 to make a variable
> > length type...
>
> I believe you could make an input function that would support that,
> though it would have to do a catalog lookup to find out the desired
> type length. The output function, however, would be quite a trick.
> It's not going to receive anything except the Datum itself.

Hmm, you're right. With the taggedtypes module I made it work by
cloning the output function with a new OID each time and setting the
arg type so that procLookupArgType() would work. Similarly, the input
function would use procLookupRettype() to find the desired type.

So the procedure would be slightly more complicated:

CREATE FUNCTION uuid_in(cstring) RETURNS uuid AS 'hex_raw_in' LANGUAGE internal;
CREATE FUNCTION uuid_out(uuid) RETURNS cstring AS 'hex_raw_out' LANGUAGE internal;
CREATE TYPE uuid (
input = uuid_in,
output = uuid_out,
internallength = 16
);

The cat lookups are irritating, but that's what syscache is for, I
guess :)

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Dunstan 2006-07-01 14:58:05 Re: Fixed length datatypes. WAS [GENERAL] UUID's as
Previous Message Tom Lane 2006-07-01 14:37:59 Re: Fixed length datatypes. WAS [GENERAL] UUID's as

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2006-07-01 14:58:05 Re: Fixed length datatypes. WAS [GENERAL] UUID's as
Previous Message Tom Lane 2006-07-01 14:37:59 Re: Fixed length datatypes. WAS [GENERAL] UUID's as