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/parser/parse_target.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/backend/parser/parse_target.c') diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index 4e3c47eb208..86670d26794 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.142 2006/03/23 00:19:30 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.143 2006/06/16 18:42:22 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -850,7 +850,8 @@ ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind) ((Var *) expr)->vartype == RECORDOID) tupleDesc = expandRecordVariable(pstate, (Var *) expr, 0); else if (get_expr_result_type(expr, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE) - tupleDesc = lookup_rowtype_tupdesc(exprType(expr), exprTypmod(expr)); + tupleDesc = lookup_rowtype_tupdesc_copy(exprType(expr), + exprTypmod(expr)); Assert(tupleDesc); /* Generate a list of references to the individual fields */ @@ -1027,7 +1028,8 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup) * appropriate error message while failing. */ if (get_expr_result_type(expr, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE) - tupleDesc = lookup_rowtype_tupdesc(exprType(expr), exprTypmod(expr)); + tupleDesc = lookup_rowtype_tupdesc_copy(exprType(expr), + exprTypmod(expr)); return tupleDesc; } -- cgit v1.2.3