1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-14 08:21:07 +03:00

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
This commit is contained in:
Tom Lane
2006-06-16 18:42:24 +00:00
parent b49ce32da1
commit 06e10abc0b
36 changed files with 581 additions and 246 deletions

View File

@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/typcache.h,v 1.10 2006/03/05 15:59:08 momjian Exp $
* $PostgreSQL: pgsql/src/include/utils/typcache.h,v 1.11 2006/06/16 18:42:23 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -58,7 +58,7 @@ typedef struct TypeCacheEntry
/*
* Tuple descriptor if it's a composite type (row type). NULL if not
* composite or information hasn't yet been requested. (NOTE: this is
* actually just a link to information maintained by relcache.c.)
* a reference-counted tupledesc.)
*/
TupleDesc tupDesc;
} TypeCacheEntry;
@ -79,6 +79,8 @@ extern TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod);
extern TupleDesc lookup_rowtype_tupdesc_noerror(Oid type_id, int32 typmod,
bool noError);
extern TupleDesc lookup_rowtype_tupdesc_copy(Oid type_id, int32 typmod);
extern void assign_record_type_typmod(TupleDesc tupDesc);
extern void flush_rowtype_cache(Oid type_id);