FileClose(res);
}
-#ifdef XCP
/* Ditto for prepared statements */
- while (owner->nstmts > 0)
+ while (ResourceArrayGetAny(&(owner->prepstmts), &foundres))
{
- char *stmt = owner->stmts + ((owner->nstmts - 1) * CNAME_MAXLEN);
+ char *stmt = (char *) DatumGetPointer(foundres);
+
if (isCommit)
PrintPreparedStmtLeakWarning(stmt);
DropPreparedStatement(stmt, false);
}
-#endif
/* Clean up index scans too */
ReleaseResources_hash();
file);
}
-#ifdef XCP
/*
* Make sure there is room for at least one more entry in a ResourceOwner's
* prepared statements reference array.
void
ResourceOwnerEnlargePreparedStmts(ResourceOwner owner)
{
- int newmax;
-
- if (owner->nstmts < owner->maxstmts)
- return; /* nothing to do */
-
- if (owner->stmts == NULL)
- {
- newmax = 16;
- owner->stmts = (char *)
- MemoryContextAlloc(TopMemoryContext, newmax * CNAME_MAXLEN);
- owner->maxstmts = newmax;
- }
- else
- {
- newmax = owner->maxstmts * 2;
- owner->stmts = (char *)
- repalloc(owner->stmts, newmax * CNAME_MAXLEN);
- owner->maxstmts = newmax;
- }
+ ResourceArrayEnlarge(&(owner->prepstmts));
}
/*
void
ResourceOwnerRememberPreparedStmt(ResourceOwner owner, char *stmt)
{
- Assert(owner->nstmts < owner->maxstmts);
- strncpy(owner->stmts + (owner->nstmts * CNAME_MAXLEN), stmt, CNAME_MAXLEN);
- owner->nstmts++;
+ ResourceArrayAdd(&(owner->prepstmts), PointerGetDatum(stmt));
}
/*
void
ResourceOwnerForgetPreparedStmt(ResourceOwner owner, char *stmt)
{
- char *stmts = owner->stmts;
- int ns1 = owner->nstmts - 1;
- int i;
-
- for (i = ns1; i >= 0; i--)
- {
- if (strncmp(stmts + (i * CNAME_MAXLEN), stmt, CNAME_MAXLEN) == 0)
- {
- while (i < ns1)
- {
- strncpy(stmts + (i * CNAME_MAXLEN),
- stmts + ((i + 1) * CNAME_MAXLEN),
- CNAME_MAXLEN);
- i++;
- }
- owner->nstmts = ns1;
- return;
- }
- }
- elog(ERROR, "prepared statement %s is not owned by resource owner %s",
- stmt, owner->name);
+ if (!ResourceArrayRemove(&(owner->prepstmts), PointerGetDatum(stmt)))
+ elog(ERROR, "prepared statement %p is not owned by resource owner %s",
+ stmt, owner->name);
}
-
/*
* Debugging subroutine
*/
"prepared statement leak: Statement %s still referenced",
stmt);
}
-#endif
/*