diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 9e90acedb9..53588218cc 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2940,8 +2940,6 @@ pg_get_functiondef(PG_FUNCTION_ARGS) float4 procost; int oldlen; - initStringInfo(&buf); - /* Look up the function */ proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(proctup)) @@ -2957,6 +2955,8 @@ pg_get_functiondef(PG_FUNCTION_ARGS) isfunction = (proc->prokind != PROKIND_PROCEDURE); + initStringInfo(&buf); + /* * We always qualify the function name, to ensure the right function gets * replaced. @@ -3614,8 +3614,6 @@ pg_get_function_sqlbody(PG_FUNCTION_ARGS) HeapTuple proctup; bool isnull; - initStringInfo(&buf); - /* Look up the function */ proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(proctup)) @@ -3628,6 +3626,7 @@ pg_get_function_sqlbody(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } + initStringInfo(&buf); print_function_sqlbody(&buf, proctup); ReleaseSysCache(proctup);