Michael Enke <[EMAIL PROTECTED]> 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
        ORDER 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

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

                http://www.postgresql.org/about/donate

Reply via email to