Re: COMMUTATOR doesn't seem to work

From: Florian Pflug <fgp(at)phlo(dot)org>
To: D'Arcy Cain <darcy(at)druid(dot)net>
Cc: pgsql-hackers(at)PostgreSQL(dot)org
Subject: Re: COMMUTATOR doesn't seem to work
Date: 2012-06-21 16:20:59
Message-ID: EA0330A1-D1EA-4357-81C5-F0C1701EFB71@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Jun21, 2012, at 17:46 , D'Arcy Cain wrote:

> Maybe I am using it wrong but I get no error message when I use it. I
> have a type called chkpass (a version is in the additional supplied
> modules) and I create the equality operator like this:
>
...
>
> So while it created the operator it didn't set a return type.
>
> I don't know if this is a new issue or I simply got lucky and never
> tried the opposite test before but I see this in 9.0.4 and 9.1.3.
> Am I using the command improperly?

COMMUTATOR (and also NEGATOR) only inform the planner/optimizer
about the relationship between operators, but you still have to create
all of them manually. What you see is the placeholder for that
to-be-created operator that CREATE OPERATOR fabricated. It does that
because if the COMMUTATOR or NEGATOR was required to already exist,
how would you ever be able to create a pair of commuting operators?

If you later use CREATE OPERATOR to actually create the COMMUTATOR
or NEGATOR you specified previously, it'll simply complete the
previously created placeholder.

Long story short, you need another CREATE OPERATOR command for the
COMMUTATOR (which argument types swapped), and it should in turn
name the original operator as it's COMMUTATOR.

best regards,
Florian Pflug

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dickson S. Guedes 2012-06-21 17:10:31 Re: Release versioning inconsistency
Previous Message Tom Lane 2012-06-21 16:18:36 Re: COMMUTATOR doesn't seem to work