From: Tom Lane <tgl@sss.pgh.pa.us>
To: Chapman Flack <chap@anastigmatix.net>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Subject: Re: Life cycles of tuple descriptors
Date: Tue, 14 Dec 2021 18:03:00 -0500
Message-ID: <560418.1639522980@sss.pgh.pa.us> (raw)
In-Reply-To: <61B901A4.1050808@anastigmatix.net>
References: <61B901A4.1050808@anastigmatix.net>
Chapman Flack <chap@anastigmatix.net> writes:
> There are some things about the life cycle of the common TupleDesc
> that I'm not 100% sure about.
> 1. In general, if you get one from relcache or typcache, it is
> reference-counted, right?
Tupdescs for named composite types should be, since those are
potentially modifiable by DDL. The refcount allows a stale tupdesc
to go away when it's no longer referenced anywhere.
Tupdescs for RECORD types are a different story: there's no way to
change them once created, so they'll live as long as the process
does (at least for tupdescs kept in the typcache). Refcounting
isn't terribly necessary in that case; and at least for the shared
tupdesc case, we don't do it, to avoid questions of modifying a
piece of shared state.
> 3. Is that shared case the only way you could see a non-refcounted
> TupleDesc handed to you by the typcache?
I'm not sure what happens for a non-shared RECORD tupdesc, but it
probably wouldn't be wise to assume anything either way.
> 5. When a constructed TupleDesc is blessed, the copy placed in the cache
> by assign_record_type_typmod is born with a refcount of 1. Assuming every
> later user of that TupleDesc plays nicely with balanced pin and release,
> what event(s), if any, could ever occur to decrease that initial 1 to 0?
That refcount is describing the cache's own reference, so as long as
that reference remains it'd be incorrect to decrease the refcount to 0.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, chap@anastigmatix.net
Subject: Re: Life cycles of tuple descriptors
In-Reply-To: <560418.1639522980@sss.pgh.pa.us>
References: <61B901A4.1050808@anastigmatix.net> <560418.1639522980@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox