Re: lookup_rowtype_tupdesc considered harmful

Поиск
Список
Период
Сортировка
От Neil Conway
Тема Re: lookup_rowtype_tupdesc considered harmful
Дата
Msg-id 1136846315.9116.20.camel@localhost.localdomain
обсуждение исходный текст
Ответ на Re: lookup_rowtype_tupdesc considered harmful  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: lookup_rowtype_tupdesc considered harmful  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: lookup_rowtype_tupdesc considered harmful  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
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
recordtype */
 
} 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




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: plperl vs LC_COLLATE (was Re: Possible savepoint bug)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: lookup_rowtype_tupdesc considered harmful