From 06e10abc0bb4297a0754313b4f158bdd5622ca24 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 16 Jun 2006 18:42:24 +0000 Subject: Fix problems with cached tuple descriptors disappearing while still in use by creating a reference-count mechanism, similar to what we did a long time ago for catcache entries. The back branches have an ugly solution involving lots of extra copies, but this way is more efficient. Reference counting is only applied to tupdescs that are actually in caches --- there seems no need to use it for tupdescs that are generated in the executor, since they'll go away during plan shutdown by virtue of being in the per-query memory context. Neil Conway and Tom Lane --- src/backend/executor/execUtils.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/backend/executor/execUtils.c') diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index d1a294f9bb8..c30c8f2badf 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.134 2006/04/30 18:30:38 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.135 2006/06/16 18:42:22 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -427,12 +427,11 @@ ExecAssignExprContext(EState *estate, PlanState *planstate) * ---------------- */ void -ExecAssignResultType(PlanState *planstate, - TupleDesc tupDesc, bool shouldFree) +ExecAssignResultType(PlanState *planstate, TupleDesc tupDesc) { TupleTableSlot *slot = planstate->ps_ResultTupleSlot; - ExecSetSlotDescriptor(slot, tupDesc, shouldFree); + ExecSetSlotDescriptor(slot, tupDesc); } /* ---------------- @@ -461,7 +460,7 @@ ExecAssignResultTypeFromTL(PlanState *planstate) * to set up planstate->targetlist ... */ tupDesc = ExecTypeFromTL(planstate->plan->targetlist, hasoid); - ExecAssignResultType(planstate, tupDesc, true); + ExecAssignResultType(planstate, tupDesc); } /* ---------------- @@ -659,12 +658,11 @@ ExecGetScanType(ScanState *scanstate) * ---------------- */ void -ExecAssignScanType(ScanState *scanstate, - TupleDesc tupDesc, bool shouldFree) +ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc) { TupleTableSlot *slot = scanstate->ss_ScanTupleSlot; - ExecSetSlotDescriptor(slot, tupDesc, shouldFree); + ExecSetSlotDescriptor(slot, tupDesc); } /* ---------------- @@ -680,7 +678,7 @@ ExecAssignScanTypeFromOuterPlan(ScanState *scanstate) outerPlan = outerPlanState(scanstate); tupDesc = ExecGetResultType(outerPlan); - ExecAssignScanType(scanstate, tupDesc, false); + ExecAssignScanType(scanstate, tupDesc); } -- cgit v1.2.3