Re: Hashable custom types

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Hashable custom types
Дата
Msg-id 13110.1436387502@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Hashable custom types  (Paul Ramsey <pramsey@cleverelephant.ca>)
Ответы Re: Hashable custom types  (Paul Ramsey <pramsey@cleverelephant.ca>)
Список pgsql-hackers
Paul Ramsey <pramsey@cleverelephant.ca> writes:
> On Fri, Apr 25, 2014 at 4:54 PM, Peter Geoghegan <pg@heroku.com> wrote:
>> On Fri, Apr 25, 2014 at 4:47 PM, Paul Ramsey <pramsey@cleverelephant.ca> wrote:
>>> Is it possible to make custom types hashable? There's no hook in the
>>> CREATE TYPE call for a hash function, but can one be hooked up
>>> somewhere else? In an operator?

>> See 35.14.6., System Dependencies on Operator Classes

> Coming back to this, I created an appropriate opclass...

> CREATE OR REPLACE FUNCTION geometry_hash_eq(geom1 geometry, geom2 geometry)
> RETURNS boolean
> AS '$libdir/postgis-2.2', 'lwgeom_hash_eq'
> LANGUAGE 'c' IMMUTABLE STRICT;

Why are you creating a separate equality operator, rather than just using
the type's existing equality operator (I assume it's got one) in the
hash opclass?

> It still says I lack the secret sauce...

> ERROR:  could not implement recursive UNION
> DETAIL:  All column datatypes must be hashable.

UNION will preferentially glom onto the btree equality operator, if memory
serves.  If that isn't also the hash equality operator, things won't work
pleasantly.
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Paul Ramsey
Дата:
Сообщение: Re: Hashable custom types
Следующее
От: Paul Ramsey
Дата:
Сообщение: Re: Hashable custom types