diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-09-17 19:38:05 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-09-17 19:38:05 -0400 |
commit | 1ed6b895634ce0dc5fd4bd040e87252b32182cba (patch) | |
tree | d0f22d227e7df8ca5139baf4eba578de052f6a82 /doc/src | |
parent | 76f412ab310554acb970a0b73c8d1f37f35548c6 (diff) | |
download | postgresql-1ed6b895634ce0dc5fd4bd040e87252b32182cba.tar.gz postgresql-1ed6b895634ce0dc5fd4bd040e87252b32182cba.zip |
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
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/catalogs.sgml | 8 | ||||
-rw-r--r-- | doc/src/sgml/ref/alter_extension.sgml | 2 | ||||
-rw-r--r-- | doc/src/sgml/ref/alter_operator.sgml | 9 | ||||
-rw-r--r-- | doc/src/sgml/ref/alter_opfamily.sgml | 2 | ||||
-rw-r--r-- | doc/src/sgml/ref/comment.sgml | 2 | ||||
-rw-r--r-- | doc/src/sgml/ref/create_opclass.sgml | 2 | ||||
-rw-r--r-- | doc/src/sgml/ref/create_operator.sgml | 22 | ||||
-rw-r--r-- | doc/src/sgml/ref/drop_operator.sgml | 16 | ||||
-rw-r--r-- | doc/src/sgml/syntax.sgml | 5 | ||||
-rw-r--r-- | doc/src/sgml/typeconv.sgml | 6 | ||||
-rw-r--r-- | doc/src/sgml/xoper.sgml | 12 |
11 files changed, 32 insertions, 54 deletions
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$<replaceable><iteration count></replaceable>:<replaceable>&l <structfield>oprkind</structfield> <type>char</type> </para> <para> - <literal>b</literal> = infix (<quote>both</quote>), <literal>l</literal> = prefix - (<quote>left</quote>), <literal>r</literal> = postfix (<quote>right</quote>) + <literal>b</literal> = infix operator (<quote>both</quote>), + or <literal>l</literal> = prefix operator (<quote>left</quote>) </para></entry> </row> @@ -5188,7 +5188,7 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l (references <link linkend="catalog-pg-type"><structname>pg_type</structname></link>.<structfield>oid</structfield>) </para> <para> - Type of the left operand + Type of the left operand (0 if none) </para></entry> </row> @@ -5266,7 +5266,7 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l </table> <para> - Unused column contain zeroes. For example, <structfield>oprleft</structfield> + Unused columns contain zeroes. For example, <structfield>oprleft</structfield> is zero for a prefix operator. </para> 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 <replaceable class="parameter">name</replaceable> DROP <replacea <para> The data type(s) of the operator's arguments (optionally schema-qualified). Write <literal>NONE</literal> for the missing argument - of a prefix or postfix operator. + of a prefix operator. </para> </listitem> </varlistentry> 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 <refsynopsisdiv> <synopsis> -ALTER OPERATOR <replaceable>name</replaceable> ( { <replaceable>left_type</replaceable> | NONE } , { <replaceable>right_type</replaceable> | NONE } ) +ALTER OPERATOR <replaceable>name</replaceable> ( { <replaceable>left_type</replaceable> | NONE } , <replaceable>right_type</replaceable> ) OWNER TO { <replaceable>new_owner</replaceable> | CURRENT_ROLE | CURRENT_USER | SESSION_USER } -ALTER OPERATOR <replaceable>name</replaceable> ( { <replaceable>left_type</replaceable> | NONE } , { <replaceable>right_type</replaceable> | NONE } ) +ALTER OPERATOR <replaceable>name</replaceable> ( { <replaceable>left_type</replaceable> | NONE } , <replaceable>right_type</replaceable> ) SET SCHEMA <replaceable>new_schema</replaceable> -ALTER OPERATOR <replaceable>name</replaceable> ( { <replaceable>left_type</replaceable> | NONE } , { <replaceable>right_type</replaceable> | NONE } ) +ALTER OPERATOR <replaceable>name</replaceable> ( { <replaceable>left_type</replaceable> | NONE } , <replaceable>right_type</replaceable> ) SET ( { RESTRICT = { <replaceable class="parameter">res_proc</replaceable> | NONE } | JOIN = { <replaceable class="parameter">join_proc</replaceable> | NONE } } [, ... ] ) @@ -79,8 +79,7 @@ ALTER OPERATOR <replaceable>name</replaceable> ( { <replaceable>left_type</repla <term><replaceable class="parameter">right_type</replaceable></term> <listitem> <para> - The data type of the operator's right operand; write - <literal>NONE</literal> if the operator has no right operand. + The data type of the operator's right operand. </para> </listitem> </varlistentry> 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 <replaceable>name</replaceable> USING <replaceable class=" <para> In an <literal>OPERATOR</literal> clause, the operand data type(s) of the operator, or <literal>NONE</literal> to - signify a left-unary or right-unary operator. Unlike the comparable + signify a prefix operator. Unlike the comparable syntax in <command>CREATE OPERATOR CLASS</command>, the operand data types must always be specified. </para> diff --git a/doc/src/sgml/ref/comment.sgml b/doc/src/sgml/ref/comment.sgml index fd7492a2556..6e8ced3eaf1 100644 --- a/doc/src/sgml/ref/comment.sgml +++ b/doc/src/sgml/ref/comment.sgml @@ -224,7 +224,7 @@ COMMENT ON <para> The data type(s) of the operator's arguments (optionally schema-qualified). Write <literal>NONE</literal> for the missing argument - of a prefix or postfix operator. + of a prefix operator. </para> </listitem> </varlistentry> diff --git a/doc/src/sgml/ref/create_opclass.sgml b/doc/src/sgml/ref/create_opclass.sgml index f42fb6494c6..2d75a1c0b0d 100644 --- a/doc/src/sgml/ref/create_opclass.sgml +++ b/doc/src/sgml/ref/create_opclass.sgml @@ -161,7 +161,7 @@ CREATE OPERATOR CLASS <replaceable class="parameter">name</replaceable> [ DEFAUL <para> In an <literal>OPERATOR</literal> clause, the operand data type(s) of the operator, or <literal>NONE</literal> 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. </para> 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 <replaceable>name</replaceable> ( </para> <para> - At least one of <literal>LEFTARG</literal> and <literal>RIGHTARG</literal> must be defined. For - binary operators, both must be defined. For right unary - operators, only <literal>LEFTARG</literal> should be defined, while for left - unary operators only <literal>RIGHTARG</literal> should be defined. - </para> - - <note> - <para> - Right unary, also called postfix, operators are deprecated and will be - removed in <productname>PostgreSQL</productname> version 14. - </para> - </note> - - <para> + For binary operators, both <literal>LEFTARG</literal> and + <literal>RIGHTARG</literal> must be defined. For prefix operators only + <literal>RIGHTARG</literal> should be defined. The <replaceable class="parameter">function_name</replaceable> function must have been previously defined using <command>CREATE FUNCTION</command> and must be defined to accept the correct number @@ -160,7 +149,7 @@ CREATE OPERATOR <replaceable>name</replaceable> ( <listitem> <para> 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. </para> </listitem> </varlistentry> @@ -169,8 +158,7 @@ CREATE OPERATOR <replaceable>name</replaceable> ( <term><replaceable class="parameter">right_type</replaceable></term> <listitem> <para> - 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. </para> </listitem> </varlistentry> 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 <refsynopsisdiv> <synopsis> -DROP OPERATOR [ IF EXISTS ] <replaceable class="parameter">name</replaceable> ( { <replaceable class="parameter">left_type</replaceable> | NONE } , { <replaceable class="parameter">right_type</replaceable> | NONE } ) [, ...] [ CASCADE | RESTRICT ] +DROP OPERATOR [ IF EXISTS ] <replaceable class="parameter">name</replaceable> ( { <replaceable class="parameter">left_type</replaceable> | NONE } , <replaceable class="parameter">right_type</replaceable> ) [, ...] [ CASCADE | RESTRICT ] </synopsis> </refsynopsisdiv> @@ -73,8 +73,7 @@ DROP OPERATOR [ IF EXISTS ] <replaceable class="parameter">name</replaceable> ( <term><replaceable class="parameter">right_type</replaceable></term> <listitem> <para> - The data type of the operator's right operand; write - <literal>NONE</literal> if the operator has no right operand. + The data type of the operator's right operand. </para> </listitem> </varlistentry> @@ -113,7 +112,7 @@ DROP OPERATOR ^ (integer, integer); </para> <para> - Remove the left unary bitwise complement operator + Remove the bitwise-complement prefix operator <literal>~b</literal> for type <type>bit</type>: <programlisting> DROP OPERATOR ~ (none, bit); @@ -121,16 +120,9 @@ DROP OPERATOR ~ (none, bit); </para> <para> - Remove the right unary factorial operator <literal>x!</literal> - for type <type>bigint</type>: -<programlisting> -DROP OPERATOR ! (bigint, none); -</programlisting></para> - - <para> Remove multiple operators in one command: <programlisting> -DROP OPERATOR ~ (none, bit), ! (bigint, none); +DROP OPERATOR ~ (none, bit), ^ (integer, integer); </programlisting></para> </refsect1> 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 ( '<replaceable>string</replaceable>' AS <replaceable>type</replaceable> ) <para> 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 <literal>@</literal>, + For example, if you have defined a prefix operator named <literal>@</literal>, you cannot write <literal>X*@Y</literal>; you must write <literal>X* @Y</literal> to ensure that <productname>PostgreSQL</productname> reads it as two operator names @@ -1444,11 +1444,10 @@ $1.somecolumn </indexterm> <para> - There are three possible syntaxes for an operator invocation: + There are two possible syntaxes for an operator invocation: <simplelist> <member><replaceable>expression</replaceable> <replaceable>operator</replaceable> <replaceable>expression</replaceable> (binary infix operator)</member> <member><replaceable>operator</replaceable> <replaceable>expression</replaceable> (unary prefix operator)</member> - <member><replaceable>expression</replaceable> <replaceable>operator</replaceable> (unary postfix operator)</member> </simplelist> where the <replaceable>operator</replaceable> token follows the syntax rules of <xref linkend="sql-syntax-operators"/>, 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 <listitem> <para> <productname>PostgreSQL</productname> 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. </para> @@ -266,7 +266,7 @@ create objects. In such situations, cast arguments to force an exact match. <para> If one argument of a binary operator invocation is of the <type>unknown</type> type, then assume it is the same type as the other argument for this check. -Invocations involving two <type>unknown</type> inputs, or a unary operator +Invocations involving two <type>unknown</type> inputs, or a prefix operator with an <type>unknown</type> input, will never find a match at this step. </para> </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 @@ </para> <para> - <productname>PostgreSQL</productname> supports left unary, right - unary, and binary operators. Operators can be + <productname>PostgreSQL</productname> supports prefix + and infix operators. Operators can be overloaded;<indexterm><primary>overloading</primary><secondary>operators</secondary></indexterm> 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; </para> <para> - We've shown how to create a binary operator here. To create unary - operators, just omit one of <literal>leftarg</literal> (for left unary) or - <literal>rightarg</literal> (for right unary). The <literal>function</literal> + We've shown how to create a binary operator here. To create a prefix + operator, just omit the <literal>leftarg</literal>. + The <literal>function</literal> clause and the argument clauses are the only required items in <command>CREATE OPERATOR</command>. The <literal>commutator</literal> clause shown in the example is an optional hint to the query @@ -202,7 +202,7 @@ SELECT (a + b) AS c FROM test_complex; <para> 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. </para> <para> |