1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-03 01:21:48 +03:00

Maintain RelIdToTypeIdCacheHash in TypeCacheOpcCallback()

b85a9d046efd introduced a new RelIdToTypeIdCacheHash, whose entries should
exist for typecache entries with TCFLAGS_HAVE_PG_TYPE_DATA flag set or any
of TCFLAGS_OPERATOR_FLAGS set or tupDesc set.  However, TypeCacheOpcCallback(),
which resets TCFLAGS_OPERATOR_FLAGS, was forgotten to update
RelIdToTypeIdCacheHash.

This commit adds a delete_rel_type_cache_if_needed() call to the
TypeCacheOpcCallback() function to maintain RelIdToTypeIdCacheHash after
resetting TCFLAGS_OPERATOR_FLAGS.

Also, this commit fixes the name of the delete_rel_type_cache_if_needed()
function in its mentions in the comments.

Reported-by: Noah Misch
Discussion: https://postgr.es/m/20250411203241.e9.nmisch%40google.com
This commit is contained in:
Alexander Korotkov 2025-04-23 20:14:32 +03:00
parent 9f404d7922
commit bb78e42678

View File

@ -2395,7 +2395,10 @@ InvalidateCompositeTypeCacheEntry(TypeCacheEntry *typentry)
/* Reset equality/comparison/hashing validity information */
typentry->flags &= ~TCFLAGS_OPERATOR_FLAGS;
/* Call delete_rel_type_cache() if we actually cleared something */
/*
* Call delete_rel_type_cache_if_needed() if we actually cleared
* something.
*/
if (hadTupDescOrOpclass)
delete_rel_type_cache_if_needed(typentry);
}
@ -2542,7 +2545,7 @@ TypeCacheTypCallback(Datum arg, int cacheid, uint32 hashvalue)
TCFLAGS_CHECKED_DOMAIN_CONSTRAINTS);
/*
* Call delete_rel_type_cache() if we cleaned
* Call delete_rel_type_cache_if_needed() if we cleaned
* TCFLAGS_HAVE_PG_TYPE_DATA flag previously.
*/
if (hadPgTypeData)
@ -2576,8 +2579,17 @@ TypeCacheOpcCallback(Datum arg, int cacheid, uint32 hashvalue)
hash_seq_init(&status, TypeCacheHash);
while ((typentry = (TypeCacheEntry *) hash_seq_search(&status)) != NULL)
{
bool hadOpclass = (typentry->flags & TCFLAGS_OPERATOR_FLAGS);
/* Reset equality/comparison/hashing validity information */
typentry->flags &= ~TCFLAGS_OPERATOR_FLAGS;
/*
* Call delete_rel_type_cache_if_needed() if we actually cleared some
* of TCFLAGS_OPERATOR_FLAGS.
*/
if (hadOpclass)
delete_rel_type_cache_if_needed(typentry);
}
}