Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitddd2435

Browse files
committed
Fix leakage of memory context header in find_all_inheritors().
Commit827d6f9 contained the same misunderstanding of hash_create's APIas commit090010f. As in5d00b76, remove the unnecessary layer ofmemory context. (This bug is less significant than the other one, sincethe extra context would be under a relatively short-lived context, butit's still a bug.)
1 parenta19ea9c commitddd2435

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
HASHCTLctl;
172-
MemoryContextnew_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)

[8]ページ先頭

©2009-2025 Movatter.jp