Skip to content

Commit 851ff93

Browse files
committed
Fix hash_array
Commit a3d2b1b neglected to initialize the type_id field of the synthesized type cache entry, so it would make a new one on every call. Also, better use the per-function memory context for this; otherwise it leaks memory. Discussion: https://www.postgresql.org/message-id/flat/17158-8a2ba823982537a4%40postgresql.org
1 parent 379591f commit 851ff93

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/backend/utils/adt/arrayfuncs.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3992,13 +3992,14 @@ hash_array(PG_FUNCTION_ARGS)
39923992
MemoryContext oldcontext;
39933993
TypeCacheEntry *record_typentry;
39943994

3995-
oldcontext = MemoryContextSwitchTo(CacheMemoryContext);
3995+
oldcontext = MemoryContextSwitchTo(fcinfo->flinfo->fn_mcxt);
39963996

39973997
/*
39983998
* Make fake type cache entry structure. Note that we can't just
39993999
* modify typentry, since that points directly into the type cache.
40004000
*/
4001-
record_typentry = palloc(sizeof(*record_typentry));
4001+
record_typentry = palloc0(sizeof(*record_typentry));
4002+
record_typentry->type_id = element_type;
40024003

40034004
/* fill in what we need below */
40044005
record_typentry->typlen = typentry->typlen;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy