Re: self defined data type "with limit"?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: self defined data type "with limit"?
Дата
Msg-id 7344.1183045435@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: self defined data type "with limit"?  (Michael Enke <michael.enke@wincor-nixdorf.com>)
Ответы Re: self defined data type "with limit"?  (Michael Enke <michael.enke@wincor-nixdorf.com>)
Список 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 по дате отправления:

Предыдущее
От: Greg Smith
Дата:
Сообщение: Re: Bgwriter LRU cleaning: we've been going at this all wrong
Следующее
От: "Pavan Deolasee"
Дата:
Сообщение: SetBufferCommitInfoNeedsSave and race conditions