Re: Domains and supporting functions

From: elein <elein(at)varlena(dot)com>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Domains and supporting functions
Date: 2006-02-20 00:04:44
Message-ID: 20060220000444.GO15582@varlena.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Feb 19, 2006 at 11:34:21PM +0100, Martijn van Oosterhout wrote:
> On Sun, Feb 19, 2006 at 01:36:41PM -0800, elein wrote:
> > On Sun, Feb 19, 2006 at 10:29:35PM +0100, Martijn van Oosterhout wrote:
> > > On Sun, Feb 19, 2006 at 12:59:35PM -0800, elein wrote:
> > > > On Sun, Feb 19, 2006 at 07:57:42PM +0100, Martijn van Oosterhout wrote:
> > > > > ORDER BY x ASC is a synonym for ORDER BY x USING >. That's the way it
> > > > > is currently. To use ORDER BY by itself you need to call your operators
> > > > > < and >.
> > > > >
> > > >
> > > > This does not work where x is datatype foo with opclass foo_ops.
> > > > In this case, it uses the text > instead of the foo >.
> > >
> > > Huh? You must be doing something unusual because it does work normally.
> > > Did you specify the opclass as the default for the type?
> > >
> >
> > I'll show you my test case if you'll show me yours :)
>
> Ok, here's a quick example I whipped up and if you run it it clearly
> shows it's using the comparison function from the operator class.
>
> http://svana.org/kleptog/temp/text2.example
>
> It basically replicates the entire infrastructure for the text type as
> a new type, "text2" so there's planty of scope for confusion, but
> postgresql correctly picks the right function.
>
> Have a nice day,
> --
> Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> > Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> > tool for doing 5% of the work and then sitting around waiting for someone
> > else to do the other 95% so you can sue them.

Comparing test cases we found that Martijn was using a true CREATE TYPE while
I am using CREATE DOMAIN. That was the only difference that mattered.

So far there are only two gotchas with this exercise of making a
domain based base type.
1) LIKE doesn't work. Workaround: create and use like-ish operator. Arguably correct behavior.
2) ORDER BY requires the USING op clause. Workaround: use the USING op clause.

--elein

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Kirkwood 2006-02-20 00:28:50 Re: postgresql query string length limit
Previous Message Neil Conway 2006-02-19 23:59:44 Re: patch fixing the old RETURN NEXT bug