mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Mark factorial operator, and postfix operators in general, as deprecated.
Per discussion, we're planning to remove parser support for postfix
operators in order to simplify the grammar. So it behooves us to
put out a deprecation notice at least one release before that.
There is only one built-in postfix operator, ! for factorial.
Label it deprecated in the docs and in pg_description, and adjust
some examples that formerly relied on it. (The sister prefix
operator !! is also deprecated. We don't really have to remove
that one, but since we're suggesting that people use factorial()
instead, it seems better to remove both operators.)
Also state in the CREATE OPERATOR ref page that postfix operators
in general are going away.
Although this changes the initial contents of pg_description,
I did not force a catversion bump; it doesn't seem essential.
In v13, also back-patch 4c5cf5431
, so that there's someplace for
the <link>s to point to.
Mark Dilger and John Naylor, with some adjustments by me
Discussion: https://postgr.es/m/BE2DF53D-251A-4E26-972F-930E523580E9@enterprisedb.com
This commit is contained in:
@ -977,27 +977,8 @@ CAST ( '<replaceable>string</replaceable>' AS <replaceable>type</replaceable> )
|
||||
Most operators have the same precedence and are left-associative.
|
||||
The precedence and associativity of the operators is hard-wired
|
||||
into the parser.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
You will
|
||||
sometimes need to add parentheses when using combinations of
|
||||
binary and unary operators. For instance:
|
||||
<programlisting>
|
||||
SELECT 5 ! - 6;
|
||||
</programlisting>
|
||||
will be parsed as:
|
||||
<programlisting>
|
||||
SELECT 5 ! (- 6);
|
||||
</programlisting>
|
||||
because the parser has no idea — until it is too late
|
||||
— that <token>!</token> is defined as a postfix operator,
|
||||
not an infix one. To get the desired behavior in this case, you
|
||||
must write:
|
||||
<programlisting>
|
||||
SELECT (5 !) - 6;
|
||||
</programlisting>
|
||||
This is the price one pays for extensibility.
|
||||
Add parentheses if you want an expression with multiple operators
|
||||
to be parsed in some other way than what the precedence rules imply.
|
||||
</para>
|
||||
|
||||
<table id="sql-precedence-table">
|
||||
|
Reference in New Issue
Block a user