@@ -97,6 +97,7 @@ plsample_func_handler(PG_FUNCTION_ARGS)
97
97
char * proname ;
98
98
Form_pg_type pg_type_entry ;
99
99
Oid result_typioparam ;
100
+ Oid prorettype ;
100
101
FmgrInfo result_in_func ;
101
102
int numargs ;
102
103
@@ -117,7 +118,6 @@ plsample_func_handler(PG_FUNCTION_ARGS)
117
118
if (isnull )
118
119
elog (ERROR , "could not find source text of function \"%s\"" ,
119
120
proname );
120
- ReleaseSysCache (pl_tuple );
121
121
source = DatumGetCString (DirectFunctionCall1 (textout , ret ));
122
122
ereport (NOTICE ,
123
123
(errmsg ("source text of function \"%s\": %s" ,
@@ -157,6 +157,10 @@ plsample_func_handler(PG_FUNCTION_ARGS)
157
157
i , argnames [i ], value )));
158
158
}
159
159
160
+ /* Type of the result */
161
+ prorettype = pl_struct -> prorettype ;
162
+ ReleaseSysCache (pl_tuple );
163
+
160
164
/*
161
165
* Get the required information for input conversion of the return value.
162
166
*
@@ -165,13 +169,13 @@ plsample_func_handler(PG_FUNCTION_ARGS)
165
169
* we can do here. This returns NULL except if the result type is text,
166
170
* where the result is the source text of the function.
167
171
*/
168
- if (pl_struct -> prorettype != TEXTOID )
172
+ if (prorettype != TEXTOID )
169
173
PG_RETURN_NULL ();
170
174
171
175
type_tuple = SearchSysCache1 (TYPEOID ,
172
- ObjectIdGetDatum (pl_struct -> prorettype ));
176
+ ObjectIdGetDatum (prorettype ));
173
177
if (!HeapTupleIsValid (type_tuple ))
174
- elog (ERROR , "cache lookup failed for type %u" , pl_struct -> prorettype );
178
+ elog (ERROR , "cache lookup failed for type %u" , prorettype );
175
179
pg_type_entry = (Form_pg_type ) GETSTRUCT (type_tuple );
176
180
result_typioparam = getTypeIOParam (type_tuple );
177
181
0 commit comments