From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Chapman Flack <chap(at)anastigmatix(dot)net> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
Subject: | Re: Life cycles of tuple descriptors |
Date: | 2021-12-15 22:50:41 |
Message-ID: | 753943.1639608641@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I wrote:
> Chapman Flack <chap(at)anastigmatix(dot)net> writes:
>> 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.
Here's a draft patch for this. There are several places that are
directly using DecrTupleDescRefCount after lookup_rowtype_tupdesc
or equivalent, which'd now be forbidden. I think they are all safe
given the assumption that the typcache's tupdescs for named composites
are refcounted. (The calls in expandedrecord.c could be working
with RECORD, but those code paths just checked that the tupdesc
is refcounted.) So there's no actual bug here, and no reason to
back-patch, but this seems like a good idea to decouple callers
a bit more from typcache's internal logic. None of these call
sites are so performance-critical that one extra test will hurt.
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
tighten-API-spec-for-lookup_rowtype_tupdesc.patch | text/x-diff | 3.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2021-12-15 23:18:04 | Re: Life cycles of tuple descriptors |
Previous Message | Michael Paquier | 2021-12-15 22:39:52 | Re: Confused comment about drop replica identity index |