diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c index e6f66df9a139d4693083e1dfd84bc70e8b0a2d61..f0bfae661229fcbcee135ae80b5cf85c8f56da26 100644 --- a/src/backend/utils/cache/typcache.c +++ b/src/backend/utils/cache/typcache.c @@ -646,6 +646,9 @@ cache_record_field_properties(TypeCacheEntry *typentry) load_typcache_tupdesc(typentry); tupdesc = typentry->tupDesc; + /* Must bump the refcount while we do additional catalog lookups */ + IncrTupleDescRefCount(tupdesc); + /* Have each property if all non-dropped fields have the property */ newflags = (TCFLAGS_HAVE_FIELD_EQUALITY | TCFLAGS_HAVE_FIELD_COMPARE); @@ -669,6 +672,8 @@ cache_record_field_properties(TypeCacheEntry *typentry) break; } typentry->flags |= newflags; + + DecrTupleDescRefCount(tupdesc); } typentry->flags |= TCFLAGS_CHECKED_FIELD_PROPERTIES; }