Обсуждение: "text to text" operator redefinition ignored

Поиск
Список
Период
Сортировка

"text to text" operator redefinition ignored

От
ta@lavabit.com
Дата:
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 =3D 'aa  '::varchar;  -- returns false
create or replace function public.opr_vceqvc(varchar, varchar)
  returns boolean as
  $$
    select rtrim($1)=3Drtrim($2)
  $$
  language sql immutable;
create operator public.=3D (leftarg =3D varchar, rightarg =3D varchar, pr=
ocedure
=3D public.opr_vceqvc,  commutator =3D =3D, negator =3D <>, restrict =3D =
eqsel, join
=3D eqjoinsel, hashes, merges);
select 'aa'::varchar =3D 'aa  '::varchar;  -- returns true
drop operator if exists public.=3D (varchar, varchar);


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


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

Re: "text to text" operator redefinition ignored

От
Tom Lane
Дата:
ta@lavabit.com writes:
> 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;

That search path setting doesn't do what you probably think.
See under "The System Catalog Schema" in
http://www.postgresql.org/docs/9.2/static/ddl-schemas.html

Other relevant documentation is in
http://www.postgresql.org/docs/9.2/static/typeconv-oper.html

            regards, tom lane