"text to text" operator redefinition ignored

From: ta(at)lavabit(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: "text to text" operator redefinition ignored
Date: 2012-12-21 19:10:42
Message-ID: 17605.87.252.128.91.1356117042.squirrel@lavabit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG 9.2.2, Windows, empty database

just curious, redefinition of various operators seems to work nicely but
"text to text" operator redefinition (last block down here) seems
completely ignored:

set search_path to public;

select 'aa'::varchar = 'aa '::varchar; -- returns false
create or replace function public.opr_vceqvc(varchar, varchar)
returns boolean as
$$
select rtrim($1)=rtrim($2)
$$
language sql immutable;
create operator public.= (leftarg = varchar, rightarg = varchar, procedure
= public.opr_vceqvc, commutator = =, negator = <>, restrict = eqsel, join
= eqjoinsel, hashes, merges);
select 'aa'::varchar = 'aa '::varchar; -- returns true
drop operator if exists public.= (varchar, varchar);

select 'aa'::text = 'aa '::varchar; -- returns false
create or replace function public.opr_txeqvc(text, varchar)
returns boolean as
$$
select rtrim($1)=rtrim($2)
$$
language sql immutable;
create operator public.= (leftarg = text, rightarg = varchar, procedure =
public.opr_txeqvc, commutator = =, negator = <>, restrict = eqsel, join =
eqjoinsel, hashes, merges);
select 'aa'::text = 'aa '::varchar; -- returns true
drop operator if exists public.= (text, varchar);

select 'aa'::text = 'aa '::text; -- returns false
create or replace function public.opr_txeqtx(text, text)
returns boolean as
$$
-- select rtrim($1)=rtrim($2);
select true;
$$
language sql immutable;
create operator public.= (leftarg = text, rightarg = text, procedure =
public.opr_txeqtx, commutator = =, negator = <>, restrict = eqsel, join =
eqjoinsel, hashes, merges);
select 'aa'::text = 'aa '::text; -- ALWAYS RETURNS FALSE!
drop operator if exists public.= (text, text);

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2012-12-21 20:17:06 Re: [JDBC] BUG #7766: Running a DML statement that affects more than 4 billion rows results in an exception
Previous Message Dave Cramer 2012-12-21 18:55:43 Re: [BUGS] BUG #7766: Running a DML statement that affects more than 4 billion rows results in an exception