On Tuesday, May 10, 2016, David E. Wheeler <da...@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. > > http://www.postgresql.org/docs/9.5/interactive/catalog-pg-amop.html http://www.postgresql.org/docs/9.5/interactive/xindex.html 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. http://www.postgresql.org/docs/9.5/interactive/functions-info.html This option is a young one from what I remember. David J.