aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeSubqueryscan.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-06-16 18:42:24 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-06-16 18:42:24 +0000
commit06e10abc0bb4297a0754313b4f158bdd5622ca24 (patch)
tree6d413dfdfab3fea4a6d96b07b7fdb8ba81498860 /src/backend/executor/nodeSubqueryscan.c
parentb49ce32da1975b2fdab26e463b7189b95e770809 (diff)
downloadpostgresql-06e10abc0bb4297a0754313b4f158bdd5622ca24.tar.gz
postgresql-06e10abc0bb4297a0754313b4f158bdd5622ca24.zip
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
Diffstat (limited to 'src/backend/executor/nodeSubqueryscan.c')
-rw-r--r--src/backend/executor/nodeSubqueryscan.c10
1 files changed, 6 insertions, 4 deletions
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.