Avoid "could not determine interpretation of row comparisonoperator =" - Mailing list pgsql-sql

From Voillequin, Jean-Marc
Subject Avoid "could not determine interpretation of row comparisonoperator ="
Date
Msg-id 1EC8157EB499BF459A516ADCF135ADCE39FFD3A4@LON-WGMSX712.ad.moodys.net
Whole thread Raw
Responses Re: Avoid "could not determine interpretation of row comparison operator ="
List 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
-----------------------------------------

pgsql-sql by date:

Previous
From: Olivier Leprêtre
Date:
Subject: RE: error code 8
Next
From: Tom Lane
Date:
Subject: Re: Avoid "could not determine interpretation of row comparison operator ="