mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21:12 +03:00
Change PROCEDURE to FUNCTION in CREATE OPERATOR syntax
Since procedures are now a different thing from functions, change the CREATE OPERATOR syntax to use FUNCTION in the clause that specifies the function. PROCEDURE is still accepted for compatibility. Reported-by: Peter Geoghegan <pg@bowt.ie> Reviewed-by: Jonathan S. Katz <jonathan.katz@excoventures.com>
This commit is contained in:
@ -1015,7 +1015,7 @@ CREATE TYPE pair AS ( k text, v text );
|
||||
CREATE OR REPLACE FUNCTION pair(text, text)
|
||||
RETURNS pair LANGUAGE SQL AS 'SELECT ROW($1, $2)::@extschema@.pair;';
|
||||
|
||||
CREATE OPERATOR ~> (LEFTARG = text, RIGHTARG = text, PROCEDURE = pair);
|
||||
CREATE OPERATOR ~> (LEFTARG = text, RIGHTARG = text, FUNCTION = pair);
|
||||
|
||||
-- "SET search_path" is easy to get right, but qualified names perform better.
|
||||
CREATE OR REPLACE FUNCTION lower(pair)
|
||||
|
@ -22,7 +22,7 @@ PostgreSQL documentation
|
||||
<refsynopsisdiv>
|
||||
<synopsis>
|
||||
CREATE OPERATOR <replaceable>name</replaceable> (
|
||||
PROCEDURE = <replaceable class="parameter">function_name</replaceable>
|
||||
{FUNCTION|PROCEDURE} = <replaceable class="parameter">function_name</replaceable>
|
||||
[, LEFTARG = <replaceable class="parameter">left_type</replaceable> ] [, RIGHTARG = <replaceable class="parameter">right_type</replaceable> ]
|
||||
[, COMMUTATOR = <replaceable class="parameter">com_op</replaceable> ] [, NEGATOR = <replaceable class="parameter">neg_op</replaceable> ]
|
||||
[, RESTRICT = <replaceable class="parameter">res_proc</replaceable> ] [, JOIN = <replaceable class="parameter">join_proc</replaceable> ]
|
||||
@ -99,6 +99,14 @@ CREATE OPERATOR <replaceable>name</replaceable> (
|
||||
of arguments (either one or two) of the indicated types.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
In the syntax of <literal>CREATE OPERATOR</literal>, the keywords
|
||||
<literal>FUNCTION</literal> and <literal>PROCEDURE</literal> are
|
||||
equivalent, but the referenced function must in any case be a function, not
|
||||
a procedure. The use of the keyword <literal>PROCEDURE</literal> here is
|
||||
historical and deprecated.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The other clauses specify optional operator optimization clauses.
|
||||
Their meaning is detailed in <xref linkend="xoper-optimization"/>.
|
||||
@ -264,7 +272,7 @@ COMMUTATOR = OPERATOR(myschema.===) ,
|
||||
CREATE OPERATOR === (
|
||||
LEFTARG = box,
|
||||
RIGHTARG = box,
|
||||
PROCEDURE = area_equal_function,
|
||||
FUNCTION = area_equal_function,
|
||||
COMMUTATOR = ===,
|
||||
NEGATOR = !==,
|
||||
RESTRICT = area_restriction_function,
|
||||
|
@ -44,7 +44,7 @@ CREATE FUNCTION complex_add(complex, complex)
|
||||
CREATE OPERATOR + (
|
||||
leftarg = complex,
|
||||
rightarg = complex,
|
||||
procedure = complex_add,
|
||||
function = complex_add,
|
||||
commutator = +
|
||||
);
|
||||
</programlisting>
|
||||
@ -66,7 +66,7 @@ SELECT (a + b) AS c FROM test_complex;
|
||||
<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>procedure</literal>
|
||||
<literal>rightarg</literal> (for right unary). 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
|
||||
|
Reference in New Issue
Block a user