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@svana.org> http://svana.org/kleptog/ > From each according to his ability. To each according to his ability to > litigate.
signature.asc
Description: Digital signature