From d12782898eb5979bef3c6dd0d80b93d1aaf53cac Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 15 Aug 2018 18:05:46 +0200 Subject: 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 Reviewed-by: Jonathan S. Katz --- doc/src/sgml/extend.sgml | 2 +- doc/src/sgml/ref/create_operator.sgml | 12 ++++++++++-- doc/src/sgml/xoper.sgml | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/extend.sgml b/doc/src/sgml/extend.sgml index a3cb064131b..d5731621e7b 100644 --- a/doc/src/sgml/extend.sgml +++ b/doc/src/sgml/extend.sgml @@ -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) diff --git a/doc/src/sgml/ref/create_operator.sgml b/doc/src/sgml/ref/create_operator.sgml index c8263437abd..d5c385c087f 100644 --- a/doc/src/sgml/ref/create_operator.sgml +++ b/doc/src/sgml/ref/create_operator.sgml @@ -22,7 +22,7 @@ PostgreSQL documentation CREATE OPERATOR name ( - PROCEDURE = function_name + {FUNCTION|PROCEDURE} = function_name [, LEFTARG = left_type ] [, RIGHTARG = right_type ] [, COMMUTATOR = com_op ] [, NEGATOR = neg_op ] [, RESTRICT = res_proc ] [, JOIN = join_proc ] @@ -99,6 +99,14 @@ CREATE OPERATOR name ( of arguments (either one or two) of the indicated types. + + In the syntax of CREATE OPERATOR, the keywords + FUNCTION and PROCEDURE are + equivalent, but the referenced function must in any case be a function, not + a procedure. The use of the keyword PROCEDURE here is + historical and deprecated. + + The other clauses specify optional operator optimization clauses. Their meaning is detailed in . @@ -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, diff --git a/doc/src/sgml/xoper.sgml b/doc/src/sgml/xoper.sgml index 2aa7cf9b642..2f5560ac505 100644 --- a/doc/src/sgml/xoper.sgml +++ b/doc/src/sgml/xoper.sgml @@ -44,7 +44,7 @@ CREATE FUNCTION complex_add(complex, complex) CREATE OPERATOR + ( leftarg = complex, rightarg = complex, - procedure = complex_add, + function = complex_add, commutator = + ); @@ -66,7 +66,7 @@ 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 procedure + rightarg (for right unary). 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 -- cgit v1.2.3