Re: Custom type, operators and operator class not sorting/indexing correctly

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Roger Leigh <rleigh(at)codelibre(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: Custom type, operators and operator class not sorting/indexing correctly
Date: 2009-01-21 19:52:19
Message-ID: 20090121195219.GA31050@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jan 21, 2009 at 10:48:09AM +0000, Roger Leigh wrote:
> Ah, thanks for the clarification. So I need to use CREATE TYPE
> rather than CREATE DOMAIN. Because I'm essentially just storing
> a text string with different operators, can I derive a type from
> TEXT (perhaps by reusing the same input, output, receive and send
> functions as TEXT?) I saw the textsend and textreceive functions,
> which I assume are the appropriate functions for send and receive?
> Are there any for input and output which I may reuse?

Yes, you can copy all the existing attributes. Use:

select * from pg_type where typname='text';

To get the relevent info (upcoming 8.4 will have CREATE TYPE xxx
(LIKE=text) ). Lookup the citext project for an example.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Brent Wood 2009-01-21 20:53:54 how to implement a foreign key type constraint against a not unique column
Previous Message Kirk Strauser 2009-01-21 19:18:47 Followup: Here's why I want to use connection pooling middleware!