#include "pgstat.h"
#include "access/transam.h"
+#include "access/xact.h"
#include "catalog/namespace.h"
#include "commands/vacuum.h"
#include "executor/executor.h"
standard_ExecutorEnd(queryDesc);
}
+static void
+removeTable(XactEvent event, void *arg)
+{
+ List *toremove = arg;
+ ListCell *cell;
+
+ if (event != XACT_EVENT_COMMIT)
+ return;
+
+ foreach(cell, toremove)
+ {
+ Oid relOid = lfirst_oid(cell);
+
+ hash_search(relstats, &relOid, HASH_REMOVE, NULL);
+ }
+}
+
+
#if PG_VERSION_NUM >= 90200
static void
onlineAnalyzeHookerUtility(
tblnames = list_copy(((TruncateStmt*)parsetree)->relations);
op = CK_TRUNCATE;
}
+ else if (IsA(parsetree, DropStmt) &&
+ ((DropStmt*)parsetree)->removeType == OBJECT_TABLE)
+ {
+ ListCell *cell;
+ List *toremove = NIL;
+
+ foreach(cell, ((DropStmt*)parsetree)->objects)
+ {
+ List *relname = (List *) lfirst(cell);
+ RangeVar *rel = makeRangeVarFromNameList(relname);
+ Oid relOid = RangeVarGetRelid(rel, NoLock, true);
+
+ if (OidIsValid(relOid))
+ {
+ MemoryContext ctx;
+
+ ctx = MemoryContextSwitchTo(TopTransactionContext);
+ toremove = lappend_oid(toremove, relOid);
+ MemoryContextSwitchTo(ctx);
+ }
+ }
+
+ if (list_length(toremove) > 0)
+ RegisterXactCallback(removeTable, toremove);
+ }
else if (IsA(parsetree, VacuumStmt))
{
VacuumStmt *vac = (VacuumStmt*)parsetree;