pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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 20:02:28 -0500
Message-ID: <602839.1639530148@sss.pgh.pa.us> (raw)
In-Reply-To: <61B92A54.30003@anastigmatix.net>
References: <61B901A4.1050808@anastigmatix.net>
	<560418.1639522980@sss.pgh.pa.us>
	<61B92A54.30003@anastigmatix.net>

Chapman Flack <chap@anastigmatix.net> writes:
> But if I have gone straight to the typcache to ask for a RECORD tupdesc,
> and the one it gives me has -1 refcount, is it reasonable to assume
> I can retain a reference to that without the defensive copy?

The API contract for lookup_rowtype_tupdesc specifies that you must "call
ReleaseTupleDesc or DecrTupleDescRefCount when done using the tupdesc".
It's safe to assume that the tupdesc will stick around as long as you
haven't done that.

APIs that don't mention a refcount are handing you a tupdesc of uncertain
lifespan (no more than the current query, likely), so if you want the
tupdesc to last a long time you'd better copy it into storage you control.

			regards, tom lane





view thread (10+ messages)  latest in thread

Message-ID: <602839.1639530148@sss.pgh.pa.us>
Permalink:  ../602839.1639530148@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/602839.1639530148@sss.pgh.pa.us

 · 

reply

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: <602839.1639530148@sss.pgh.pa.us>
  References: <61B901A4.1050808@anastigmatix.net> <560418.1639522980@sss.pgh.pa.us> <61B92A54.30003@anastigmatix.net> <602839.1639530148@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