Hi.

On 2018/08/07 3:32, Jeremy Evans wrote:
> When testing out CREATE PROCEDURE with 11 beta 2, I noticed, the hints
> in the errors reference DROP FUNCTION, which doesn't work for
> procedures.

Good catch.

> DROP ROUTINE works for both functions and procedures, so
> this patch should work for both.

Not sure if we should fix it the way your patch does, but it seems you
forgot to include changes to the expected output of some of the regression
tests affected by this patch.  Attached updated patch includes those.

Thanks,
Amit
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index 9b4015d0d4..84ee8d686d 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -409,7 +409,7 @@ ProcedureCreate(const char *procedureName,
                        ereport(ERROR,
                                        
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
                                         errmsg("cannot change return type of 
existing function"),
-                                        errhint("Use DROP FUNCTION %s first.",
+                                        errhint("Use DROP ROUTINE %s first.",
                                                         
format_procedure(HeapTupleGetOid(oldtup)))));
 
                /*
@@ -434,7 +434,7 @@ ProcedureCreate(const char *procedureName,
                                                
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
                                                 errmsg("cannot change return 
type of existing function"),
                                                 errdetail("Row type defined by 
OUT parameters is different."),
-                                                errhint("Use DROP FUNCTION %s 
first.",
+                                                errhint("Use DROP ROUTINE %s 
first.",
                                                                 
format_procedure(HeapTupleGetOid(oldtup)))));
                }
 
@@ -477,7 +477,7 @@ ProcedureCreate(const char *procedureName,
                                                        
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
                                                         errmsg("cannot change 
name of input parameter \"%s\"",
                                                                        
old_arg_names[j]),
-                                                        errhint("Use DROP 
FUNCTION %s first.",
+                                                        errhint("Use DROP 
ROUTINE %s first.",
                                                                         
format_procedure(HeapTupleGetOid(oldtup)))));
                        }
                }
@@ -501,7 +501,7 @@ ProcedureCreate(const char *procedureName,
                                ereport(ERROR,
                                                
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
                                                 errmsg("cannot remove 
parameter defaults from existing function"),
-                                                errhint("Use DROP FUNCTION %s 
first.",
+                                                errhint("Use DROP ROUTINE %s 
first.",
                                                                 
format_procedure(HeapTupleGetOid(oldtup)))));
 
                        proargdefaults = SysCacheGetAttr(PROCNAMEARGSNSP, 
oldtup,
@@ -527,7 +527,7 @@ ProcedureCreate(const char *procedureName,
                                        ereport(ERROR,
                                                        
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
                                                         errmsg("cannot change 
data type of existing parameter default value"),
-                                                        errhint("Use DROP 
FUNCTION %s first.",
+                                                        errhint("Use DROP 
ROUTINE %s first.",
                                                                         
format_procedure(HeapTupleGetOid(oldtup)))));
                                newlc = lnext(newlc);
                        }
diff --git a/src/test/regress/expected/polymorphism.out 
b/src/test/regress/expected/polymorphism.out
index 67e70c8c14..ec88621dc3 100644
--- a/src/test/regress/expected/polymorphism.out
+++ b/src/test/regress/expected/polymorphism.out
@@ -1081,7 +1081,7 @@ select dfunc(10,20);
 create or replace function dfunc(a variadic int[]) returns int as
 $$ select array_upper($1, 1) $$ language sql;
 ERROR:  cannot remove parameter defaults from existing function
-HINT:  Use DROP FUNCTION dfunc(integer[]) first.
+HINT:  Use DROP ROUTINE dfunc(integer[]) first.
 \df dfunc
                                      List of functions
  Schema | Name  | Result data type |               Argument data types         
      | Type 
@@ -1294,13 +1294,13 @@ returns record as $$
   select $1, $2;
 $$ language sql;
 ERROR:  cannot change name of input parameter "c"
-HINT:  Use DROP FUNCTION dfunc(character varying,numeric) first.
+HINT:  Use DROP ROUTINE dfunc(character varying,numeric) first.
 create or replace function dfunc(a varchar = 'def a', out _a varchar, numeric 
= NULL, out _c numeric)
 returns record as $$
   select $1, $2;
 $$ language sql;
 ERROR:  cannot change name of input parameter "c"
-HINT:  Use DROP FUNCTION dfunc(character varying,numeric) first.
+HINT:  Use DROP ROUTINE dfunc(character varying,numeric) first.
 drop function dfunc(varchar, numeric);
 --fail, named parameters are not unique
 create function testpolym(a int, a int) returns int as $$ select 1;$$ language 
sql;
diff --git a/src/test/regress/expected/rangefuncs.out 
b/src/test/regress/expected/rangefuncs.out
index 34ca0ef890..a870f9843b 100644
--- a/src/test/regress/expected/rangefuncs.out
+++ b/src/test/regress/expected/rangefuncs.out
@@ -1433,7 +1433,7 @@ CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, 
out f3 text)
 RETURNS record
 AS 'select $1+1' LANGUAGE sql;
 ERROR:  cannot change return type of existing function
-HINT:  Use DROP FUNCTION rngfunc(integer) first.
+HINT:  Use DROP ROUTINE rngfunc(integer) first.
 CREATE OR REPLACE FUNCTION rngfuncr(in f1 int, out f2 int, out text)
 AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sql;
 SELECT f1, rngfuncr(f1) FROM int4_tbl;
@@ -1515,7 +1515,7 @@ SELECT * FROM dup('xyz'::text);
 CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray)
 AS 'select $1, array[$1,$1]' LANGUAGE sql;
 ERROR:  cannot change name of input parameter "f1"
-HINT:  Use DROP FUNCTION dup(anyelement) first.
+HINT:  Use DROP ROUTINE dup(anyelement) first.
 DROP FUNCTION dup(anyelement);
 -- equivalent behavior, though different name exposed for input arg
 CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray)

Reply via email to