CREATE OPERATOR and precedence

Started by Marc Cousinalmost 16 years ago4 messagesdocs
Jump to latest
#1Marc Cousin
cousinmarc@gmail.com

Hi,

I just got caught by a precedence problem with CREATE OPERATOR.

Obviously, it was mostly my fault (I didn't think of the precedence of my
operator at all), but I didn't find anything in the CREATE OPERATOR
documentation about it either.

From looking at the code, I think I understood that it has a very low
precedence, but shouldn't it be specified in the documentation (so that at
least distracted people like me think of precedence next time they create an
operator :) ) ?

Cheers

Marc

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Marc Cousin (#1)
Re: CREATE OPERATOR and precedence

Marc Cousin <cousinmarc@gmail.com> writes:

I just got caught by a precedence problem with CREATE OPERATOR.

Obviously, it was mostly my fault (I didn't think of the precedence of my
operator at all), but I didn't find anything in the CREATE OPERATOR
documentation about it either.

CREATE OPERATOR has nothing to say on the subject because operator
precedences are hard-wired into the parser and can't be changed by
CREATE OPERATOR. See

http://www.postgresql.org/docs/8.4/static/sql-syntax-lexical.html#SQL-PRECEDENCE

regards, tom lane

#3Marc Cousin
cousinmarc@gmail.com
In reply to: Tom Lane (#2)
Re: CREATE OPERATOR and precedence

The Thursday 08 July 2010 16:31:41, Tom Lane wrote :

Marc Cousin <cousinmarc@gmail.com> writes:

I just got caught by a precedence problem with CREATE OPERATOR.

Obviously, it was mostly my fault (I didn't think of the precedence of my
operator at all), but I didn't find anything in the CREATE OPERATOR
documentation about it either.

CREATE OPERATOR has nothing to say on the subject because operator
precedences are hard-wired into the parser and can't be changed by
CREATE OPERATOR. See

http://www.postgresql.org/docs/8.4/static/sql-syntax-lexical.html#SQL-PRECE
DENCE

regards, tom lane

Yes, that's what I found out, afterwards.

From a technical point of view, I obviously totally agree, operators have no
control over precedence, but I was only reporting this because I thought that
it might be helpful to put something like a pointer to this table in the
CREATE OPERATOR doc.

From the user's point of view, even if precedence is hard-wired in the parser,
a note about it could help here, if only as a reminder. The first thing I
thought when facing the problem was : "how do I specify the precedence ?". I
found out I couldn't, but a pointer or a note would have been even easier.

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Marc Cousin (#3)
Re: CREATE OPERATOR and precedence

Marc Cousin <cousinmarc@gmail.com> writes:

From a technical point of view, I obviously totally agree, operators
have no control over precedence, but I was only reporting this because
I thought that it might be helpful to put something like a pointer to
this table in the CREATE OPERATOR doc.

Oh, that's a reasonable idea. Done in HEAD.

regards, tom lane