aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/src/sgml/func.sgml6
-rw-r--r--doc/src/sgml/ref/create_operator.sgml9
-rw-r--r--doc/src/sgml/syntax.sgml23
-rw-r--r--doc/src/sgml/typeconv.sgml17
-rw-r--r--src/include/catalog/pg_operator.dat4
-rw-r--r--src/include/catalog/pg_proc.dat1
6 files changed, 25 insertions, 35 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index bbbffd9d5bb..b9f591296a5 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -1055,6 +1055,7 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue>
</para>
<para>
Factorial
+ (deprecated, use <link linkend="function-factorial"><function>factorial()</function></link> instead)
</para>
<para>
<literal>5 !</literal>
@@ -1068,7 +1069,8 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue>
<returnvalue>numeric</returnvalue>
</para>
<para>
- Factorial (as a prefix operator)
+ Factorial as a prefix operator
+ (deprecated, use <link linkend="function-factorial"><function>factorial()</function></link> instead)
</para>
<para>
<literal>!! 5</literal>
@@ -1349,7 +1351,7 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue>
<row>
<entry role="func_table_entry"><para role="func_signature">
- <indexterm>
+ <indexterm id="function-factorial">
<primary>factorial</primary>
</indexterm>
<function>factorial</function> ( <type>bigint</type> )
diff --git a/doc/src/sgml/ref/create_operator.sgml b/doc/src/sgml/ref/create_operator.sgml
index d5c385c087f..66c34e0072f 100644
--- a/doc/src/sgml/ref/create_operator.sgml
+++ b/doc/src/sgml/ref/create_operator.sgml
@@ -87,11 +87,18 @@ CREATE OPERATOR <replaceable>name</replaceable> (
<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
+ 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>
The <replaceable class="parameter">function_name</replaceable>
function must have been previously defined using <command>CREATE
diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml
index 2f993ca2e03..0ee303cb87f 100644
--- a/doc/src/sgml/syntax.sgml
+++ b/doc/src/sgml/syntax.sgml
@@ -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 &mdash; until it is too late
- &mdash; 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">
diff --git a/doc/src/sgml/typeconv.sgml b/doc/src/sgml/typeconv.sgml
index 8900d0eb383..98662fc91fb 100644
--- a/doc/src/sgml/typeconv.sgml
+++ b/doc/src/sgml/typeconv.sgml
@@ -354,20 +354,19 @@ Some examples follow.
</para>
<example>
-<title>Factorial Operator Type Resolution</title>
+<title>Square Root Operator Type Resolution</title>
<para>
-There is only one factorial operator (postfix <literal>!</literal>)
+There is only one square root operator (prefix <literal>|/</literal>)
defined in the standard catalog, and it takes an argument of type
-<type>bigint</type>.
+<type>double precision</type>.
The scanner assigns an initial type of <type>integer</type> to the argument
in this query expression:
<screen>
-SELECT 40 ! AS "40 factorial";
-
- 40 factorial
---------------------------------------------------
- 815915283247897734345611269596115894272000000000
+SELECT |/ 40 AS "square root of 40";
+ square root of 40
+-------------------
+ 6.324555320336759
(1 row)
</screen>
@@ -375,7 +374,7 @@ So the parser does a type conversion on the operand and the query
is equivalent to:
<screen>
-SELECT CAST(40 AS bigint) ! AS "40 factorial";
+SELECT |/ CAST(40 AS double precision) AS "square root of 40";
</screen>
</para>
</example>
diff --git a/src/include/catalog/pg_operator.dat b/src/include/catalog/pg_operator.dat
index 5b0e063655d..4f8b9865eff 100644
--- a/src/include/catalog/pg_operator.dat
+++ b/src/include/catalog/pg_operator.dat
@@ -218,10 +218,10 @@
oprname => '>=', oprleft => 'xid8', oprright => 'xid8', oprresult => 'bool',
oprcom => '<=(xid8,xid8)', oprnegate => '<(xid8,xid8)', oprcode => 'xid8ge',
oprrest => 'scalargesel', oprjoin => 'scalargejoinsel' },
-{ oid => '388', descr => 'factorial',
+{ oid => '388', descr => 'deprecated, use factorial() instead',
oprname => '!', oprkind => 'r', oprleft => 'int8', oprright => '0',
oprresult => 'numeric', oprcode => 'numeric_fac' },
-{ oid => '389', descr => 'deprecated, use ! instead',
+{ oid => '389', descr => 'deprecated, use factorial() instead',
oprname => '!!', oprkind => 'l', oprleft => '0', oprright => 'int8',
oprresult => 'numeric', oprcode => 'numeric_fac' },
{ oid => '385', descr => 'equal',
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 27989971db7..1dd325e0e6f 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -328,6 +328,7 @@
proname => 'unknownout', prorettype => 'cstring', proargtypes => 'unknown',
prosrc => 'unknownout' },
{ oid => '111',
+ descr => 'implementation of deprecated ! and !! factorial operators',
proname => 'numeric_fac', prorettype => 'numeric', proargtypes => 'int8',
prosrc => 'numeric_fac' },