why commutator doesn't work?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: why commutator doesn't work?
Date: 2018-10-29 04:02:53
Message-ID: CAFj8pRAr08kJRDxtf7vEZmaNY4RKQh-rWqr+3XaD4MJX4PV-DQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

I try to create operator + for varchar and integer with Oracle behave.

create or replace function sum(varchar, int)
returns int as $$ select $1::int + $2 $$ language sql;

create operator + (function = sum, leftarg = varchar, rightarg = int,
commutator = +);

create table foo2(a varchar);
insert into foo2 values('10');
select a + 1 from foo2; -- it is ok

but

select 1 + a from foo2; -- fails

ERROR: operator is only a shell: integer + character varying
LINE 1: select 1 + a from foo2;

Why? This should be solved by COMMUTATOR = +

Regards

Pavel

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message myungkyu.lim 2018-10-29 04:12:20 RE: COPY FROM WHEN condition
Previous Message Michael Paquier 2018-10-29 03:59:42 Re: partition tree inspection functions