On Wed, Jul 27, 2016 at 5:11 AM, Robert Haas <[email protected]> wrote:
> Committed with minor kibitizing: you don't need an "else" after a
> statement that transfers control out of the function.
Thanks. Right, I forgot that.
> Shouldn't
> pg_get_function_arguments, pg_get_function_identity_arguments,
> pg_get_function_result, and pg_get_function_arg_default get the same
> treatment?
Changing all of them make sense. Please see attached.
While looking at the series of functions pg_get_*, I have noticed as
well that pg_get_userbyid() returns "unknown (OID=%u)" when it does
not know a user. Perhaps we'd want to change that to NULL for
consistency with the rest?
--
Michael
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 2915e21..51d0c23 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -2238,11 +2238,11 @@ pg_get_function_arguments(PG_FUNCTION_ARGS)
StringInfoData buf;
HeapTuple proctup;
- initStringInfo(&buf);
-
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
- elog(ERROR, "cache lookup failed for function %u", funcid);
+ PG_RETURN_NULL();
+
+ initStringInfo(&buf);
(void) print_function_arguments(&buf, proctup, false, true);
@@ -2264,11 +2264,11 @@ pg_get_function_identity_arguments(PG_FUNCTION_ARGS)
StringInfoData buf;
HeapTuple proctup;
- initStringInfo(&buf);
-
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
- elog(ERROR, "cache lookup failed for function %u", funcid);
+ PG_RETURN_NULL();
+
+ initStringInfo(&buf);
(void) print_function_arguments(&buf, proctup, false, false);
@@ -2289,11 +2289,11 @@ pg_get_function_result(PG_FUNCTION_ARGS)
StringInfoData buf;
HeapTuple proctup;
- initStringInfo(&buf);
-
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
- elog(ERROR, "cache lookup failed for function %u", funcid);
+ PG_RETURN_NULL();
+
+ initStringInfo(&buf);
print_function_rettype(&buf, proctup);
@@ -2547,7 +2547,7 @@ pg_get_function_arg_default(PG_FUNCTION_ARGS)
proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(proctup))
- elog(ERROR, "cache lookup failed for function %u", funcid);
+ PG_RETURN_NULL();
numargs = get_func_arg_info(proctup, &argtypes, &argnames, &argmodes);
if (nth_arg < 1 || nth_arg > numargs || !is_input_argument(nth_arg - 1, argmodes))
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index 7c633ac..c5ff318 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -3094,3 +3094,33 @@ SELECT pg_get_viewdef(0);
(1 row)
+SELECT pg_get_function_arguments(0);
+ pg_get_function_arguments
+---------------------------
+
+(1 row)
+
+SELECT pg_get_function_identity_arguments(0);
+ pg_get_function_identity_arguments
+------------------------------------
+
+(1 row)
+
+SELECT pg_get_function_result(0);
+ pg_get_function_result
+------------------------
+
+(1 row)
+
+SELECT pg_get_function_arg_default(0, 0);
+ pg_get_function_arg_default
+-----------------------------
+
+(1 row)
+
+SELECT pg_get_function_arg_default('pg_class'::regclass, 0);
+ pg_get_function_arg_default
+-----------------------------
+
+(1 row)
+
diff --git a/src/test/regress/sql/rules.sql b/src/test/regress/sql/rules.sql
index 111c9ba..835945f 100644
--- a/src/test/regress/sql/rules.sql
+++ b/src/test/regress/sql/rules.sql
@@ -1152,3 +1152,8 @@ SELECT pg_get_indexdef(0);
SELECT pg_get_ruledef(0);
SELECT pg_get_triggerdef(0);
SELECT pg_get_viewdef(0);
+SELECT pg_get_function_arguments(0);
+SELECT pg_get_function_identity_arguments(0);
+SELECT pg_get_function_result(0);
+SELECT pg_get_function_arg_default(0, 0);
+SELECT pg_get_function_arg_default('pg_class'::regclass, 0);
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers