Re: Does Type Have = Operator?

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Does Type Have = Operator?
Дата
Msg-id CAKFQuwYwJVS4rRgjHMi2tA+f7psKPj4_+Qa4b5WzYx6VTWQuyQ@mail.gmail.com
обсуждение исходный текст
Ответ на Does Type Have = Operator?  ("David E. Wheeler" <david@justatheory.com>)
Ответы Re: Does Type Have = Operator?  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Re: Does Type Have = Operator?  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
On Tuesday, May 10, 2016, David E. Wheeler <david@justatheory.com> wrote:

This makes sense, of course, and I could fix it by comparing text values instead of json values when the values are JSON. But of course the lack of a = operator is not limited to JSON. So I’m wondering if there’s an interface at the SQL level to tell me whether a type has an = operator? That way I could always use text values in those situations.



Brute force: you'd have to query pg_amop and note the absence of a row with a btree (maybe hash too...) family strategy 3 (1 for hash) [equality] where the left and right types are the same and match the type in question.

There is likely more to it - though absence is pretty much a given I'd be concerned about false negatives due to ignoring other factors like "amoppurpose".

In theory you should be able to trade off convenience for correctness by calling:

to_regoperator('=(type,type)')

But I've never tried it and it assumes that = is the equality operator and that its presence is sufficient.  I'm also guessing on the text type name syntax.


This option is a young one from what I remember.

David J.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Does Type Have = Operator?
Следующее
От: Euler Taveira
Дата:
Сообщение: Re: Does Type Have = Operator?