Re: Life cycles of tuple descriptors - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Life cycles of tuple descriptors
Date
Msg-id 602839.1639530148@sss.pgh.pa.us
Whole thread Raw
In response to Re: Life cycles of tuple descriptors  (Chapman Flack <chap@anastigmatix.net>)
Responses Re: Life cycles of tuple descriptors  (Chapman Flack <chap@anastigmatix.net>)
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: generalized conveyor belt storage
Next
From: Peter Smith
Date:
Subject: Re: row filtering for logical replication