Skip to content

Commit 51300b4

Browse files
committed
Fix use-after-release issue in PL/Sample
Introduced in adbe62d. Per buildfarm member prion, when using RELCACHE_FORCE_RELEASE.
1 parent adbe62d commit 51300b4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/test/modules/plsample/plsample.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ plsample_func_handler(PG_FUNCTION_ARGS)
9797
char *proname;
9898
Form_pg_type pg_type_entry;
9999
Oid result_typioparam;
100+
Oid prorettype;
100101
FmgrInfo result_in_func;
101102
int numargs;
102103

@@ -117,7 +118,6 @@ plsample_func_handler(PG_FUNCTION_ARGS)
117118
if (isnull)
118119
elog(ERROR, "could not find source text of function \"%s\"",
119120
proname);
120-
ReleaseSysCache(pl_tuple);
121121
source = DatumGetCString(DirectFunctionCall1(textout, ret));
122122
ereport(NOTICE,
123123
(errmsg("source text of function \"%s\": %s",
@@ -157,6 +157,10 @@ plsample_func_handler(PG_FUNCTION_ARGS)
157157
i, argnames[i], value)));
158158
}
159159

160+
/* Type of the result */
161+
prorettype = pl_struct->prorettype;
162+
ReleaseSysCache(pl_tuple);
163+
160164
/*
161165
* Get the required information for input conversion of the return value.
162166
*
@@ -165,13 +169,13 @@ plsample_func_handler(PG_FUNCTION_ARGS)
165169
* we can do here. This returns NULL except if the result type is text,
166170
* where the result is the source text of the function.
167171
*/
168-
if (pl_struct->prorettype != TEXTOID)
172+
if (prorettype != TEXTOID)
169173
PG_RETURN_NULL();
170174

171175
type_tuple = SearchSysCache1(TYPEOID,
172-
ObjectIdGetDatum(pl_struct->prorettype));
176+
ObjectIdGetDatum(prorettype));
173177
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);
175179
pg_type_entry = (Form_pg_type) GETSTRUCT(type_tuple);
176180
result_typioparam = getTypeIOParam(type_tuple);
177181

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy