Skip to content

Commit ddd2435

Browse files
committed
Fix leakage of memory context header in find_all_inheritors().
Commit 827d6f9 contained the same misunderstanding of hash_create's API as commit 090010f. As in 5d00b76, remove the unnecessary layer of memory context. (This bug is less significant than the other one, since the extra context would be under a relatively short-lived context, but it's still a bug.)
1 parent a19ea9c commit ddd2435

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/backend/catalog/pg_inherits.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
#include "storage/lmgr.h"
3030
#include "utils/builtins.h"
3131
#include "utils/fmgroids.h"
32+
#include "utils/memutils.h"
3233
#include "utils/syscache.h"
3334
#include "utils/tqual.h"
34-
#include "utils/memutils.h"
3535

3636
/*
3737
* Entry of a hash table used in find_all_inheritors. See below.
@@ -169,29 +169,19 @@ find_all_inheritors(Oid parentrelId, LOCKMODE lockmode, List **numparents)
169169
/* hash table for O(1) rel_oid -> rel_numparents cell lookup */
170170
HTAB *seen_rels;
171171
HASHCTL ctl;
172-
MemoryContext new_ctx;
173172
List *rels_list,
174173
*rel_numparents;
175174
ListCell *l;
176175

177-
/*
178-
* We need a separate memory context for a hash table. This is because
179-
* hash table is used only in this procedure. To free a memory we need to
180-
* call hash_destroy which is just a wrapper around MemoryContextDelete.
181-
*/
182-
new_ctx = AllocSetContextCreate(CurrentMemoryContext,
183-
"FindAllInheritorsSeenRelsContext",
184-
ALLOCSET_DEFAULT_SIZES);
185-
186176
memset(&ctl, 0, sizeof(ctl));
187177
ctl.keysize = sizeof(Oid);
188178
ctl.entrysize = sizeof(SeenRelsEntry);
189-
ctl.hcxt = new_ctx;
179+
ctl.hcxt = CurrentMemoryContext;
190180

191-
seen_rels = hash_create(
192-
"find_all_inheritors temporary table",
193-
32, /* start small and extend */
194-
&ctl, HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
181+
seen_rels = hash_create("find_all_inheritors temporary table",
182+
32, /* start small and extend */
183+
&ctl,
184+
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
195185

196186
/*
197187
* We build a list starting with the given rel and adding all direct and

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