context long after it had been destroyed.
Per problem report from Justin Pasher. Patch by Tom Lane and me.
8.3 and later do not have this bug, because this code has been restructured for
unrelated reasons. In 8.2 it does not manifest as a crash, but it still seems
safer fixing it nonetheless.
bool freeze)
{
VacuumStmt *vacstmt;
- MemoryContext old_cxt;
/*
* The node must survive transaction boundaries, so make sure we create it
* in a long-lived context
*/
- old_cxt = MemoryContextSwitchTo(AutovacMemCxt);
+ MemoryContextSwitchTo(AutovacMemCxt);
vacstmt = makeNode(VacuumStmt);
vacuum(vacstmt, relids);
pfree(vacstmt);
- MemoryContextSwitchTo(old_cxt);
+
+ /* Make sure we end up pointing to the long-lived context at exit */
+ MemoryContextSwitchTo(AutovacMemCxt);
}
/*