Re: self defined data type "with limit"? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: self defined data type "with limit"?
Date
Msg-id 7344.1183045435@sss.pgh.pa.us
Whole thread Raw
In response to Re: self defined data type "with limit"?  (Michael Enke <michael.enke@wincor-nixdorf.com>)
Responses Re: self defined data type "with limit"?
List pgsql-hackers
Michael Enke <michael.enke@wincor-nixdorf.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 writeORDER BY col USING <<<
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
anyway.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Greg Smith
Date:
Subject: Re: Bgwriter LRU cleaning: we've been going at this all wrong
Next
From: "Pavan Deolasee"
Date:
Subject: SetBufferCommitInfoNeedsSave and race conditions