Skip site navigation (1) Skip section navigation (2)

Re: self defined data type "with limit"?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Enke <michael(dot)enke(at)wincor-nixdorf(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: self defined data type "with limit"?
Date: 2007-06-28 15:43:55
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Michael Enke <michael(dot)enke(at)wincor-nixdorf(dot)com> writes:
> Heikki Linnakangas wrote:
>> You don't need to custom type for that. A custom operator class with 
>> custom comparison operators is enough.

> Ok, I tried with ordinary varchar and my own operators/op class. But than:
> 1) the index is never used (I created it 'with' my opclass)
> 2) the 'order by' doesn't care about my operator class, it's normal varchar sequence.

Yeah, because ORDER BY is still going to look to the default varchar
opclass to determine what the ordering is supposed to be.  Assuming
your custom less-than operator is named <<<, you'd have to write
to get this sort order.

If you want ORDER BY on the column to default to your custom ordering,
the only way is a distinct datatype that you can make your custom
opclass be the default for.

The domain idea might work, I'm not totally sure.  Defining
functions/operators on a domain is a bit ticklish because anything but
an exact match will get smashed to the domain base type and thus not
match your function.  I think though that in this case you might get
away with it because it would be an exact match --- it's worth a try

			regards, tom lane

In response to


pgsql-hackers by date

Next:From: Stephen FrostDate: 2007-06-28 17:01:44
Subject: 'SET LOCAL ROLE blah;' doesn't work?
Previous:From: Bruce McAlisterDate: 2007-06-28 15:40:13
Subject: Re: AutoVacuum Behaviour Question

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group