Overloading '<' operator

Started by Suresh Triover 21 years ago4 messagesgeneral
Jump to latest
#1Suresh Tri
trisuresh@yahoo.co.in

Hi all,
I was trying to overload '<' operator for (varchar,varchar). But in
the function which handles the comparision I want to use the previous
'<' operator.. but it is going into a recursion.

My simplified code looks like :

create or replace function orastringcmp (varchar, varchar) returns
boolean as
'declare
firstarg alias for $1;
secondarg alias for $2;
begin
return firstarg < secondarg;
end;
'language 'plpgsql';

create operator < (
procedure = orastringcmp,
leftarg = varchar,
rightarg = varchar
);

Can any one tell how to use the previous version of ooperator while
overloading one. Are there any material online which gives the
detailed description of operator overloading? ( i could not find much
information apart from CREATE OPERATOR documentation )

Thanks,
Abhiman

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Suresh Tri (#1)
Re: Overloading '<' operator

Am Dienstag, 31. August 2004 15:18 schrieb Suresh Tri:

Can any one tell how to use the previous version of ooperator while
overloading one.

Don't call the previous operator, call the function underlying the previous
operator.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#2)
Re: Overloading '<' operator

Peter Eisentraut <peter_e@gmx.net> writes:

Am Dienstag, 31. August 2004 15:18 schrieb Suresh Tri:

Can any one tell how to use the previous version of ooperator while
overloading one.

Don't call the previous operator, call the function underlying the previous
operator.

Or put them in different schemas and use a schema-qualified operator
reference (x operator(foo.<) y). But if you actually *replace* the
previous definition of the operator, there's no way you can expect
to still be able to use it.

regards, tom lane

#4Suresh Tri
trisuresh@yahoo.co.in
In reply to: Suresh Tri (#1)
Re: Overloading '<' operator

I used the internal function text_pattern_lt and it is working fine!
Thanks for helping.

cheers
Suresh