Add a caveat to hash_seq_init_with_hash_value() header comment
authorAlexander Korotkov <[email protected]>
Thu, 8 Aug 2024 08:48:57 +0000 (11:48 +0300)
committerAlexander Korotkov <[email protected]>
Thu, 8 Aug 2024 08:48:57 +0000 (11:48 +0300)
The typical use-case for hash_seq_init_with_hash_value() is syscache
callback.  Add a caveat that the default hash function doesn't match syscache
hash function.  So, one needs to define a custom hash function.

Reported-by: Pavel Stehule
Discussion: https://postgr.es/m/CAFj8pRAXmv6eyYx%3DE_BTfyK%3DO_%2ByOF8sXB%3D0bn9eOBt90EgWRA%40mail.gmail.com
Reviewed-by: Pavel Stehule
src/backend/utils/hash/dynahash.c

index 8040416a13c166b3fb585cda01d81afc12b7e3c7..5d9c62b652ad89bf06b55298aa90087e42d1714f 100644 (file)
@@ -1395,6 +1395,11 @@ hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
 /*
  * Same as above but scan by the given hash value.
  * See also hash_seq_search().
+ *
+ * NOTE: the default hash function doesn't match syscache hash function.
+ * Thus, if you're going to use this function in syscache callback, make sure
+ * you're using custom hash function.  See relatt_cache_syshash()
+ * for example.
  */
 void
 hash_seq_init_with_hash_value(HASH_SEQ_STATUS *status, HTAB *hashp,