Fix uninitialized variable in pgrowlocks
Because the variable rel is only used in if (SRF_IS_FIRSTCALL()) branch,
we should move it's declaration into this branch (suggested by Hubert Zhang).
@@ -74,7 +74,6 @@ pgrowlocks(PG_FUNCTION_ARGS)
AttInMetadata *attinmeta;
Datum result;
MyData *mydata;
- Relation rel;
if (SRF_IS_FIRSTCALL())
{
@@ -82,6 +81,7 @@ pgrowlocks(PG_FUNCTION_ARGS)
RangeVar *relrv;
MemoryContext oldcontext;
AclResult aclresult;
+ Relation rel;
funcctx = SRF_FIRSTCALL_INIT();
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
@@ -129,7 +129,7 @@ pgrowlocks(PG_FUNCTION_ARGS)
/* must hold a buffer lock to call HeapTupleSatisfiesUpdate */
LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE);
- htsu = HeapTupleSatisfiesUpdate(rel, tuple,
+ htsu = HeapTupleSatisfiesUpdate(mydata->rel, tuple,
GetCurrentCommandId(false),
scan->rs_cbuf);
xmax = HeapTupleHeaderGetRawXmax(tuple->t_data);
