Avoid "could not determine interpretation of row comparison operator ="

From: "Voillequin, Jean-Marc" <Jean-Marc(dot)Voillequin(at)moodys(dot)com>
To: "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Avoid "could not determine interpretation of row comparison operator ="
Date: 2018-11-30 13:35:27
Message-ID: 1EC8157EB499BF459A516ADCF135ADCE39FFD3A4@LON-WGMSX712.ad.moodys.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,

When I run the following sql:
create or replace function cmp_numeric_text(a numeric, b text) returns boolean as $$ select a=b::numeric;$$ language sql strict immutable;
create operator = (leftarg = numeric, rightarg = text, procedure = cmp_numeric_text);
select 'OK' where (1,2) in (select '1'::text,'2'::text);

I get:
ERROR: could not determine interpretation of row comparison operator =
LINE 1: select 'OK' where (1,2) in (select '1'::text,'2'::text);
^
HINT: Row comparison operators must be associated with btree operator families.

I understand that row (1,2) (int,int) cannot be compared to row ('1','2') (text,text) without coding a new comparison operator = for row type.
I have read the documentation on "create/alter operator class/family" but could not figure out how to do this.
Is it just possible to implement such feature within PG thanks to operator class/family ?

Of course, the case I have to solve is more complex. But a small example or recommendation will be greatly appreciated.

Thanks.
Regards.
-----------------------------------------

Moody's monitors email communications through its networks for regulatory compliance purposes and to protect its customers, employees and business and where allowed to do so by applicable law. The information contained in this e-mail message, and any attachment thereto, is confidential and may not be disclosed without our express permission. If you are not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution or copying of this message, or any attachment thereto, in whole or in part, is strictly prohibited. If you have received this message in error, please immediately notify us by telephone, fax or e-mail and delete the message and all of its attachments. Every effort is made to keep our network free from viruses. You should, however, review this e-mail message, as well as any attachment thereto, for viruses. We take no responsibility and have no liability for any computer virus which may be transferred via this e-mail message.

This email was sent to you by Moody’s Investors Service EMEA Limited
Registered office address:
One Canada Square
Canary Wharf
London, E14 5FA
Registered in England and Wales No: 8922701

-----------------------------------------

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2018-11-30 15:31:00 Re: Avoid "could not determine interpretation of row comparison operator ="
Previous Message Olivier Leprêtre 2018-11-28 18:37:25 RE: error code 8