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/nodeSubqueryscan.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/backend/executor/nodeSubqueryscan.c') diff --git a/src/backend/executor/nodeSubqueryscan.c b/src/backend/executor/nodeSubqueryscan.c index 02b072893a5..e16bf7fe3c5 100644 --- a/src/backend/executor/nodeSubqueryscan.c +++ b/src/backend/executor/nodeSubqueryscan.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.29 2006/03/05 15:58:26 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.30 2006/06/16 18:42:22 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -202,11 +202,13 @@ ExecInitSubqueryScan(SubqueryScan *node, EState *estate, int eflags) subquerystate->ss.ps.ps_TupFromTlist = false; /* - * Initialize scan tuple type (needed by ExecAssignScanProjectionInfo) + * Initialize scan tuple type (needed by ExecAssignScanProjectionInfo). + * Because the subplan is in its own memory context, we need to copy its + * result tuple type not just link to it; else the tupdesc will disappear + * too soon during shutdown. */ ExecAssignScanType(&subquerystate->ss, - ExecGetResultType(subquerystate->subplan), - false); + CreateTupleDescCopy(ExecGetResultType(subquerystate->subplan))); /* * Initialize result tuple type and projection info. -- cgit v1.2.3