Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxJpE-0002hy-EU for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Dec 2021 02:15:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mxJpC-00006S-Oc for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Dec 2021 02:15:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxJpC-00006H-A9 for pgsql-hackers@lists.postgresql.org; Wed, 15 Dec 2021 02:15:22 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxJp9-0004bq-N9 for pgsql-hackers@postgresql.org; Wed, 15 Dec 2021 02:15:21 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1BF2EceY609407; Tue, 14 Dec 2021 21:14:38 -0500 From: Tom Lane To: Chapman Flack cc: PostgreSQL Hackers Subject: Re: Life cycles of tuple descriptors In-reply-to: <61B94BC8.6090709@anastigmatix.net> References: <61B901A4.1050808@anastigmatix.net> <560418.1639522980@sss.pgh.pa.us> <61B92A54.30003@anastigmatix.net> <602839.1639530148@sss.pgh.pa.us> <61B94BC8.6090709@anastigmatix.net> Comments: In-reply-to Chapman Flack message dated "Tue, 14 Dec 2021 20:58:32 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <609405.1639534478.1@sss.pgh.pa.us> Date: Tue, 14 Dec 2021 21:14:38 -0500 Message-ID: <609406.1639534478@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Chapman Flack writes: > On 12/14/21 20:02, Tom Lane wrote: >> 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. > I think what threw me was having a function whose API contract mentions > reference counts, but that sometimes gives me things that don't have them. That's supposed to be hidden under ReleaseTupleDesc; you shouldn't have to think about it. > Oh, hmm, maybe one thing in that API comment ought to be changed. It says > I must call ReleaseTupleDesc *or* DecrTupleDescRefCount. Maybe that dates > from before the shared registry? ReleaseTupleDesc is safe, but anybody who > uses DecrTupleDescRefCount on a lookup_rowtype_tupdesc result could be > in for an assertion failure if a non-refcounted tupdesc is returned. Yeah, I was just wondering the same. I think DecrTupleDescRefCount is safe if you know you are looking up a named composite type, but maybe that's still too much familiarity with typcache innards. regards, tom lane