On Mon, 2006-01-09 at 14:51 -0500, Tom Lane wrote: > Nah, I don't think this works. The problem is that after an inval, > you may have to provide an updated TupleDesc to new callers while > old callers still have open reference counts to the old TupleDesc.
Good point. > However, you might be able to adopt the same trick used in catcache.c: > the callers think they have pointers to HeapTuples and are unaware that > that is just a field of a larger struct. Add a reference count and a > "dead" flag, and a "magic" value for safety checking, and you've got it. Hmm, okay. There's the additional complication that we need to handle record types (see RecordCacheArray in typcache.c). Since I don't think we need reference counting for those, I'm envisioning something like: TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod); void release_rowtype_tupdesc(TupleDesc tdesc); /* better name? */ TypeCacheEntry *lookup_type_cache(Oid type_id, int flags); void release_type_cache(TypeCacheEntry *tentry); where lookup_rowtype_tupdesc() returns a pointer to this struct: typedef struct { struct tupleDesc tdesc; /* must be first field */ TypeCacheEntry *tentry; /* pointer to owning TypeCacheEntry, or NULL if this is a record type */ } MagicTupleDesc; and where TypeCacheEntry has been modified to contain a reference count and an "is dead?" flag. Is there actually a need for the (ugly) "magic value" hackery used by catcache? -Neil ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly