snapshot = RegisterSnapshot(GetLatestSnapshot());
scan = table_beginscan(oldrel, snapshot, 0, NULL);
- /*
- * Switch to per-tuple memory context and reset it for each tuple
- * produced, so we don't leak memory.
- */
- oldCxt = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
while (table_scan_getnextslot(scan, ForwardScanDirection, oldslot))
{
TupleTableSlot *insertslot;
+ /*
+ * Switch to per-tuple memory context and reset it for each tuple
+ * produced, so we don't leak memory.
+ */
+ oldCxt = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
+
if (tab->rewrite > 0)
{
/* Extract data from old tuple */
table_insert(newrel, insertslot, mycid, hi_options, bistate);
ResetExprContext(econtext);
+ MemoryContextSwitchTo(oldCxt);
CHECK_FOR_INTERRUPTS();
}
- MemoryContextSwitchTo(oldCxt);
table_endscan(scan);
UnregisterSnapshot(snapshot);
snapshot = RegisterSnapshot(GetLatestSnapshot());
scan = table_beginscan(rel, snapshot, 0, NULL);
- /*
- * Switch to per-tuple memory context and reset it for each tuple
- * produced, so we don't leak memory.
- */
- oldcxt = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
while (table_scan_getnextslot(scan, ForwardScanDirection, slot))
{
+ /*
+ * Switch to per-tuple memory context and reset it for each tuple
+ * produced, so we don't leak memory.
+ */
+ oldcxt = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
+
if (!ExecCheck(exprstate, econtext))
ereport(ERROR,
(errcode(ERRCODE_CHECK_VIOLATION),
errtableconstraint(rel, NameStr(constrForm->conname))));
ResetExprContext(econtext);
+ MemoryContextSwitchTo(oldcxt);
}
- MemoryContextSwitchTo(oldcxt);
table_endscan(scan);
UnregisterSnapshot(snapshot);
ExecDropSingleTupleTableSlot(slot);
scan = table_beginscan(part_rel, snapshot, 0, NULL);
tupslot = table_gimmegimmeslot(parent, &estate->es_tupleTable);
- /*
- * Switch to per-tuple memory context and reset it for each tuple
- * produced, so we don't leak memory.
- */
- oldCxt = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
-
while (table_scan_getnextslot(scan, ForwardScanDirection, tupslot))
{
+ /*
+ * Switch to per-tuple memory context and reset it for each tuple
+ * produced, so we don't leak memory.
+ */
+ oldCxt = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
+
econtext->ecxt_scantuple = tupslot;
if (!ExecCheck(partqualstate, econtext))
RelationGetRelationName(default_rel))));
ResetExprContext(econtext);
+ MemoryContextSwitchTo(oldCxt);
CHECK_FOR_INTERRUPTS();
}
- MemoryContextSwitchTo(oldCxt);
table_endscan(scan);
UnregisterSnapshot(snapshot);
ExecDropSingleTupleTableSlot(tupslot);