diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-12-15 18:58:20 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-12-15 18:58:20 -0500 |
commit | bbc227e951ecc59a29205be4952a623e7d1dd534 (patch) | |
tree | 054287e408745e688bb4303f830044b197237199 /src/backend/utils/adt/expandedrecord.c | |
parent | 2a712066d0587f65fcecd44e884dc6a09958dbdd (diff) | |
download | postgresql-bbc227e951ecc59a29205be4952a623e7d1dd534.tar.gz postgresql-bbc227e951ecc59a29205be4952a623e7d1dd534.zip |
Always use ReleaseTupleDesc after lookup_rowtype_tupdesc et al.
The API spec for lookup_rowtype_tupdesc previously said you could use
either ReleaseTupleDesc or DecrTupleDescRefCount. However, the latter
choice means the caller must be certain that the returned tupdesc is
refcounted. I don't recall right now whether that was always true
when this spec was written, but it's certainly not always true since
we introduced shared record typcaches for parallel workers. That means
that callers using DecrTupleDescRefCount are dependent on typcache
behavior details that they probably shouldn't be. Hence, change the API
spec to say that you must call ReleaseTupleDesc, and fix the half-dozen
callers that weren't.
AFAICT this is just future-proofing, there's no live bug here.
So no back-patch.
Per gripe from Chapman Flack.
Discussion: https://postgr.es/m/61B901A4.1050808@anastigmatix.net
Diffstat (limited to 'src/backend/utils/adt/expandedrecord.c')
-rw-r--r-- | src/backend/utils/adt/expandedrecord.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/utils/adt/expandedrecord.c b/src/backend/utils/adt/expandedrecord.c index e19491ecf74..38d5384c00e 100644 --- a/src/backend/utils/adt/expandedrecord.c +++ b/src/backend/utils/adt/expandedrecord.c @@ -171,7 +171,7 @@ make_expanded_record_from_typeid(Oid type_id, int32 typmod, /* If we called lookup_rowtype_tupdesc, release the pin it took */ if (type_id == RECORDOID) - DecrTupleDescRefCount(tupdesc); + ReleaseTupleDesc(tupdesc); } else { @@ -854,7 +854,7 @@ expanded_record_fetch_tupdesc(ExpandedRecordHeader *erh) tupdesc->tdrefcount++; /* Release the pin lookup_rowtype_tupdesc acquired */ - DecrTupleDescRefCount(tupdesc); + ReleaseTupleDesc(tupdesc); } else { |