Re: factorial function/phase out postfix operators?

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Vik Fearing <vik@postgresfriends.org>, Peter Eisentraut <peter.eisentraut@2ndquadrant.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2020-05-19T18:30:08Z
Lists: pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Tue, May 19, 2020 at 11:32 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Before we go much further on this, we should have some proof
>> that there's actually material benefit to be gained.  I spent some
>> time just now trying to relax the AS restriction by ripping out
>> postfix ops, and the results were not too promising.

> I came to similar conclusions a couple of years ago:
> https://www.postgresql.org/message-id/CA+TgmoYzPvT7uiHjWgKtyTivHHLNCp0yLavCoipE-LyG3w2wOQ@mail.gmail.com

Ah, right.

> What I proposed at the time was creating a new category of keywords.

Might work.  My main concern would be if we have to forbid those keywords
as column names --- for words like "year", in particular, that'd be a
disaster.  If the net effect is only that they can't be AS-less col labels,
it won't break any cases that worked before.

Our existing four-way keyword classification is not something that was
handed down on stone tablets.  I wonder whether postfix-ectomy changes
the situation enough that a complete rethinking would be helpful.

I also continue to think that more lookahead and token-merging would
be interesting to pursue.  It'd hardly surprise anybody if the
token pair "character varying" were always treated as a type name,
for instance.

Anyway, the bottom-line conclusion remains the same: let's make sure
we know what we'd do after getting rid of postfix ops, before we do
that.

			regards, tom lane



Commits

  1. Remove precedence hacks no longer needed without postfix operators.

  2. Allow most keywords to be used as column labels without requiring AS.

  3. Remove support for postfix (right-unary) operators.

  4. Remove factorial operators, leaving only the factorial() function.

  5. Further refine patch for commenting operator implementation functions.