Re: Does Type Have = Operator? - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: Does Type Have = Operator?
Date
Msg-id CAKFQuwYwJVS4rRgjHMi2tA+f7psKPj4_+Qa4b5WzYx6VTWQuyQ@mail.gmail.com
Whole thread Raw
In response to Does Type Have = Operator?  ("David E. Wheeler" <david@justatheory.com>)
Responses Re: Does Type Have = Operator?  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Re: Does Type Have = Operator?  (Robert Haas <robertmhaas@gmail.com>)
List 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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: Does Type Have = Operator?
Next
From: Euler Taveira
Date:
Subject: Re: Does Type Have = Operator?