From 8ea02b0f2a183cab1f7c471550d5b662ad9f1fad Mon Sep 17 00:00:00 2001 From: Diego Fronza Date: Tue, 16 Nov 2021 13:10:56 -0300 Subject: [PATCH] PG-228: Fix hash table creation flags on PG <= 13. Before PostgreSQL 14, HASH_STRINGS flag was not available when creating a hash table with ShmemInitHash(). Use HASH_BLOBS for previous PostgreSQL versions. --- pgsm_errors.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pgsm_errors.c b/pgsm_errors.c index 0a4bcde..95f0197 100644 --- a/pgsm_errors.c +++ b/pgsm_errors.c @@ -47,6 +47,12 @@ static HTAB *pgsm_errors_ht = NULL; void psgm_errors_init(void) { HASHCTL info; +#if PG_VERSION_NUM >= 140000 + int flags = HASH_ELEM | HASH_STRINGS; +#else + int flags = HASH_ELEM | HASH_BLOBS; +#endif + memset(&info, 0, sizeof(info)); info.keysize = ERROR_MSG_MAX_LEN; @@ -55,7 +61,7 @@ void psgm_errors_init(void) PSGM_ERRORS_MAX, /* initial size */ PSGM_ERRORS_MAX, /* maximum size */ &info, - HASH_ELEM | HASH_STRINGS); + flags); } size_t pgsm_errors_size(void)