diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-06-16 18:42:24 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-06-16 18:42:24 +0000 |
commit | 06e10abc0bb4297a0754313b4f158bdd5622ca24 (patch) | |
tree | 6d413dfdfab3fea4a6d96b07b7fdb8ba81498860 /src/backend/optimizer | |
parent | b49ce32da1975b2fdab26e463b7189b95e770809 (diff) | |
download | postgresql-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/optimizer')
-rw-r--r-- | src/backend/optimizer/util/clauses.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index 10a994bcb3f..4da9f47dec5 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.211 2006/04/22 01:25:59 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.212 2006/06/16 18:42:22 tgl Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -1418,12 +1418,19 @@ rowtype_field_matches(Oid rowtypeid, int fieldnum, return true; tupdesc = lookup_rowtype_tupdesc(rowtypeid, -1); if (fieldnum <= 0 || fieldnum > tupdesc->natts) + { + ReleaseTupleDesc(tupdesc); return false; + } attr = tupdesc->attrs[fieldnum - 1]; if (attr->attisdropped || attr->atttypid != expectedtype || attr->atttypmod != expectedtypmod) + { + ReleaseTupleDesc(tupdesc); return false; + } + ReleaseTupleDesc(tupdesc); return true; } |