mirror of
https://github.com/postgres/postgres.git
synced 2025-10-22 14:32:25 +03:00
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
This commit is contained in:
7
src/backend/utils/cache/typcache.c
vendored
7
src/backend/utils/cache/typcache.c
vendored
@@ -1820,8 +1820,11 @@ lookup_rowtype_tupdesc_internal(Oid type_id, int32 typmod, bool noError)
|
||||
* for example from record_in().)
|
||||
*
|
||||
* Note: on success, we increment the refcount of the returned TupleDesc,
|
||||
* and log the reference in CurrentResourceOwner. Caller should call
|
||||
* ReleaseTupleDesc or DecrTupleDescRefCount when done using the tupdesc.
|
||||
* and log the reference in CurrentResourceOwner. Caller must call
|
||||
* ReleaseTupleDesc when done using the tupdesc. (There are some
|
||||
* cases in which the returned tupdesc is not refcounted, in which
|
||||
* case PinTupleDesc/ReleaseTupleDesc are no-ops; but in these cases
|
||||
* the tupdesc is guaranteed to live till process exit.)
|
||||
*/
|
||||
TupleDesc
|
||||
lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
|
||||
|
Reference in New Issue
Block a user