From 1ed6b895634ce0dc5fd4bd040e87252b32182cba Mon Sep 17 00:00:00 2001
From: Tom Lane
Date: Thu, 17 Sep 2020 19:38:05 -0400
Subject: Remove support for postfix (right-unary) operators.
This feature has been a thorn in our sides for a long time, causing
many grammatical ambiguity problems. It doesn't seem worth the
pain to continue to support it, so remove it.
There are some follow-on improvements we can make in the grammar,
but this commit only removes the bare minimum number of productions,
plus assorted backend support code.
Note that pg_dump and psql continue to have full support, since
they may be used against older servers. However, pg_dump warns
about postfix operators. There is also a check in pg_upgrade.
Documentation-wise, I (tgl) largely removed the "left unary"
terminology in favor of saying "prefix operator", which is
a more standard and IMO less confusing term.
I included a catversion bump, although no initial catalog data
changes here, to mark the boundary at which oprkind = 'r'
stopped being valid in pg_operator.
Mark Dilger, based on work by myself and Robert Haas;
review by John Naylor
Discussion: https://postgr.es/m/38ca86db-42ab-9b48-2902-337a0d6b8311@2ndquadrant.com
---
doc/src/sgml/catalogs.sgml | 8 ++++----
doc/src/sgml/ref/alter_extension.sgml | 2 +-
doc/src/sgml/ref/alter_operator.sgml | 9 ++++-----
doc/src/sgml/ref/alter_opfamily.sgml | 2 +-
doc/src/sgml/ref/comment.sgml | 2 +-
doc/src/sgml/ref/create_opclass.sgml | 2 +-
doc/src/sgml/ref/create_operator.sgml | 22 +++++-----------------
doc/src/sgml/ref/drop_operator.sgml | 16 ++++------------
doc/src/sgml/syntax.sgml | 5 ++---
doc/src/sgml/typeconv.sgml | 6 +++---
doc/src/sgml/xoper.sgml | 12 ++++++------
11 files changed, 32 insertions(+), 54 deletions(-)
(limited to 'doc/src')
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index 508bea3bc64..7e99928d0c1 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -5159,8 +5159,8 @@ SCRAM-SHA-256$<iteration count>:&l
oprkindchar
- b = infix (both), l = prefix
- (left), r = postfix (right)
+ b = infix operator (both),
+ or l = prefix operator (left)
@@ -5188,7 +5188,7 @@ SCRAM-SHA-256$<iteration count>:&l
(references pg_type.oid)
- Type of the left operand
+ Type of the left operand (0 if none)
@@ -5266,7 +5266,7 @@ SCRAM-SHA-256$<iteration count>:&l
- Unused column contain zeroes. For example, oprleft
+ Unused columns contain zeroes. For example, oprleft
is zero for a prefix operator.
diff --git a/doc/src/sgml/ref/alter_extension.sgml b/doc/src/sgml/ref/alter_extension.sgml
index a2d405d6cdf..c819c7bb4e3 100644
--- a/doc/src/sgml/ref/alter_extension.sgml
+++ b/doc/src/sgml/ref/alter_extension.sgml
@@ -251,7 +251,7 @@ ALTER EXTENSION name DROP
The data type(s) of the operator's arguments (optionally
schema-qualified). Write NONE for the missing argument
- of a prefix or postfix operator.
+ of a prefix operator.
diff --git a/doc/src/sgml/ref/alter_operator.sgml b/doc/src/sgml/ref/alter_operator.sgml
index ac35f229a0c..ad90c137f14 100644
--- a/doc/src/sgml/ref/alter_operator.sgml
+++ b/doc/src/sgml/ref/alter_operator.sgml
@@ -21,13 +21,13 @@ PostgreSQL documentation
-ALTER OPERATOR name ( { left_type | NONE } , { right_type | NONE } )
+ALTER OPERATOR name ( { left_type | NONE } , right_type )
OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
-ALTER OPERATOR name ( { left_type | NONE } , { right_type | NONE } )
+ALTER OPERATOR name ( { left_type | NONE } , right_type )
SET SCHEMA new_schema
-ALTER OPERATOR name ( { left_type | NONE } , { right_type | NONE } )
+ALTER OPERATOR name ( { left_type | NONE } , right_type )
SET ( { RESTRICT = { res_proc | NONE }
| JOIN = { join_proc | NONE }
} [, ... ] )
@@ -79,8 +79,7 @@ ALTER OPERATOR name ( { left_typeright_type
- The data type of the operator's right operand; write
- NONE if the operator has no right operand.
+ The data type of the operator's right operand.
diff --git a/doc/src/sgml/ref/alter_opfamily.sgml b/doc/src/sgml/ref/alter_opfamily.sgml
index 59d5bf10700..b3b5d61a852 100644
--- a/doc/src/sgml/ref/alter_opfamily.sgml
+++ b/doc/src/sgml/ref/alter_opfamily.sgml
@@ -141,7 +141,7 @@ ALTER OPERATOR FAMILY name USING name [ DEFAUL
In an OPERATOR clause,
the operand data type(s) of the operator, or NONE to
- signify a left-unary or right-unary operator. The operand data
+ signify a prefix operator. The operand data
types can be omitted in the normal case where they are the same
as the operator class's data type.
diff --git a/doc/src/sgml/ref/create_operator.sgml b/doc/src/sgml/ref/create_operator.sgml
index 66c34e0072f..9462bc1e8ca 100644
--- a/doc/src/sgml/ref/create_operator.sgml
+++ b/doc/src/sgml/ref/create_operator.sgml
@@ -86,20 +86,9 @@ CREATE OPERATOR name (
- At least one of LEFTARG and RIGHTARG must be defined. For
- binary operators, both must be defined. For right unary
- operators, only LEFTARG should be defined, while for left
- unary operators only RIGHTARG should be defined.
-
-
-
-
- Right unary, also called postfix, operators are deprecated and will be
- removed in PostgreSQL version 14.
-
-
-
-
+ For binary operators, both LEFTARG and
+ RIGHTARG must be defined. For prefix operators only
+ RIGHTARG should be defined.
The function_name
function must have been previously defined using CREATE
FUNCTION and must be defined to accept the correct number
@@ -160,7 +149,7 @@ CREATE OPERATOR name (
The data type of the operator's left operand, if any.
- This option would be omitted for a left-unary operator.
+ This option would be omitted for a prefix operator.
@@ -169,8 +158,7 @@ CREATE OPERATOR name (
right_type
- The data type of the operator's right operand, if any.
- This option would be omitted for a right-unary operator.
+ The data type of the operator's right operand.
diff --git a/doc/src/sgml/ref/drop_operator.sgml b/doc/src/sgml/ref/drop_operator.sgml
index 2dff050ecf2..7bcdd082ae7 100644
--- a/doc/src/sgml/ref/drop_operator.sgml
+++ b/doc/src/sgml/ref/drop_operator.sgml
@@ -21,7 +21,7 @@ PostgreSQL documentation
-DROP OPERATOR [ IF EXISTS ] name ( { left_type | NONE } , { right_type | NONE } ) [, ...] [ CASCADE | RESTRICT ]
+DROP OPERATOR [ IF EXISTS ] name ( { left_type | NONE } , right_type ) [, ...] [ CASCADE | RESTRICT ]
@@ -73,8 +73,7 @@ DROP OPERATOR [ IF EXISTS ] name (
right_type
- The data type of the operator's right operand; write
- NONE if the operator has no right operand.
+ The data type of the operator's right operand.
@@ -113,24 +112,17 @@ DROP OPERATOR ^ (integer, integer);
- Remove the left unary bitwise complement operator
+ Remove the bitwise-complement prefix operator
~b for type bit:
DROP OPERATOR ~ (none, bit);
-
- Remove the right unary factorial operator x!
- for type bigint:
-
-DROP OPERATOR ! (bigint, none);
-
-
Remove multiple operators in one command:
-DROP OPERATOR ~ (none, bit), ! (bigint, none);
+DROP OPERATOR ~ (none, bit), ^ (integer, integer);
diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml
index b0ae5d2e127..3fdd87823e0 100644
--- a/doc/src/sgml/syntax.sgml
+++ b/doc/src/sgml/syntax.sgml
@@ -836,7 +836,7 @@ CAST ( 'string' AS type )
When working with non-SQL-standard operator names, you will usually
need to separate adjacent operators with spaces to avoid ambiguity.
- For example, if you have defined a left unary operator named @,
+ For example, if you have defined a prefix operator named @,
you cannot write X*@Y; you must write
X* @Y to ensure that
PostgreSQL reads it as two operator names
@@ -1444,11 +1444,10 @@ $1.somecolumn
- There are three possible syntaxes for an operator invocation:
+ There are two possible syntaxes for an operator invocation:
expressionoperatorexpression (binary infix operator)operatorexpression (unary prefix operator)
- expressionoperator (unary postfix operator)
where the operator token follows the syntax
rules of , or is one of the
diff --git a/doc/src/sgml/typeconv.sgml b/doc/src/sgml/typeconv.sgml
index 98662fc91fb..cfeb851a507 100644
--- a/doc/src/sgml/typeconv.sgml
+++ b/doc/src/sgml/typeconv.sgml
@@ -97,8 +97,8 @@ Operators
PostgreSQL allows expressions with
-prefix and postfix unary (one-argument) operators,
-as well as binary (two-argument) operators. Like functions, operators can
+prefix (one-argument) operators,
+as well as infix (two-argument) operators. Like functions, operators can
be overloaded, so the same problem of selecting the right operator
exists.
@@ -266,7 +266,7 @@ create objects. In such situations, cast arguments to force an exact match.
If one argument of a binary operator invocation is of the unknown type,
then assume it is the same type as the other argument for this check.
-Invocations involving two unknown inputs, or a unary operator
+Invocations involving two unknown inputs, or a prefix operator
with an unknown input, will never find a match at this step.
diff --git a/doc/src/sgml/xoper.sgml b/doc/src/sgml/xoper.sgml
index 56b08491c96..98f4c5c4aa4 100644
--- a/doc/src/sgml/xoper.sgml
+++ b/doc/src/sgml/xoper.sgml
@@ -20,8 +20,8 @@
- PostgreSQL supports left unary, right
- unary, and binary operators. Operators can be
+ PostgreSQL supports prefix
+ and infix operators. Operators can be
overloaded;overloadingoperators
that is, the same operator name can be used for different operators
that have different numbers and types of operands. When a query is
@@ -64,9 +64,9 @@ SELECT (a + b) AS c FROM test_complex;
- We've shown how to create a binary operator here. To create unary
- operators, just omit one of leftarg (for left unary) or
- rightarg (for right unary). The function
+ We've shown how to create a binary operator here. To create a prefix
+ operator, just omit the leftarg.
+ The function
clause and the argument clauses are the only required items in
CREATE OPERATOR. The commutator
clause shown in the example is an optional hint to the query
@@ -202,7 +202,7 @@ SELECT (a + b) AS c FROM test_complex;
Unlike commutators, a pair of unary operators could validly be marked
as each other's negators; that would mean (A x) equals NOT (B x)
- for all x, or the equivalent for right unary operators.
+ for all x.
--
cgit v1.2.3