diff options
author | Robert Haas <rhaas@postgresql.org> | 2012-06-26 13:33:23 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2012-06-26 13:33:23 -0400 |
commit | 0caa0d04db24d2c571fa7daa410bc6a5b319a2a2 (patch) | |
tree | 736e5c9f1066fc684b219f0865d1667a3826b879 /src | |
parent | 76837c1507cb5a5a0048046233568447729e66dd (diff) | |
download | postgresql-0caa0d04db24d2c571fa7daa410bc6a5b319a2a2.tar.gz postgresql-0caa0d04db24d2c571fa7daa410bc6a5b319a2a2.zip |
Make DROP FUNCTION hint more informative.
If you decide you want to take the hint, this gives you something you
can paste right back to the server.
Dean Rasheed
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/catalog/pg_proc.c | 15 | ||||
-rw-r--r-- | src/test/regress/expected/polymorphism.out | 6 | ||||
-rw-r--r-- | src/test/regress/expected/rangefuncs.out | 4 |
3 files changed, 15 insertions, 10 deletions
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index 599f04242f3..ac53b09af6b 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -404,7 +404,8 @@ ProcedureCreate(const char *procedureName, ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("cannot change return type of existing function"), - errhint("Use DROP FUNCTION first."))); + errhint("Use DROP FUNCTION %s first.", + format_procedure(HeapTupleGetOid(oldtup))))); /* * If it returns RECORD, check for possible change of record type @@ -427,7 +428,8 @@ 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 first."))); + errhint("Use DROP FUNCTION %s first.", + format_procedure(HeapTupleGetOid(oldtup))))); } /* @@ -469,7 +471,8 @@ 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 first."))); + errhint("Use DROP FUNCTION %s first.", + format_procedure(HeapTupleGetOid(oldtup))))); } } @@ -492,7 +495,8 @@ ProcedureCreate(const char *procedureName, ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("cannot remove parameter defaults from existing function"), - errhint("Use DROP FUNCTION first."))); + errhint("Use DROP FUNCTION %s first.", + format_procedure(HeapTupleGetOid(oldtup))))); proargdefaults = SysCacheGetAttr(PROCNAMEARGSNSP, oldtup, Anum_pg_proc_proargdefaults, @@ -518,7 +522,8 @@ 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 first."))); + errhint("Use DROP FUNCTION %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 1e879532f87..a65e3b998f9 100644 --- a/src/test/regress/expected/polymorphism.out +++ b/src/test/regress/expected/polymorphism.out @@ -1026,7 +1026,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 first. +HINT: Use DROP FUNCTION dfunc(integer[]) first. \df dfunc List of functions Schema | Name | Result data type | Argument data types | Type @@ -1239,13 +1239,13 @@ returns record as $$ select $1, $2; $$ language sql; ERROR: cannot change name of input parameter "c" -HINT: Use DROP FUNCTION first. +HINT: Use DROP FUNCTION 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 first. +HINT: Use DROP FUNCTION dfunc(character varying,numeric) first. drop function dfunc(varchar, numeric); --fail, named parameters are not unique create function testfoo(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 5f20c932497..9fbdd83f674 100644 --- a/src/test/regress/expected/rangefuncs.out +++ b/src/test/regress/expected/rangefuncs.out @@ -439,7 +439,7 @@ CREATE OR REPLACE FUNCTION foo(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 first. +HINT: Use DROP FUNCTION foo(integer) first. CREATE OR REPLACE FUNCTION foor(in f1 int, out f2 int, out text) AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sql; SELECT f1, foor(f1) FROM int4_tbl; @@ -521,7 +521,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 first. +HINT: Use DROP FUNCTION 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) |