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

Commit7af16b2

Browse files
committed
Avoid running out of memory during hash_create, by not passing a
number-of-buckets that exceeds the size we actually plan to allowthe hash table to grow to. Per trouble report from Sean Shanny.
1 parente8aa10e commit7af16b2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

‎src/backend/executor/nodeIndexscan.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.87 2003/11/29 19:51:48 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.88 2003/12/30 20:05:05 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -953,22 +953,28 @@ static void
953953
create_duphash(IndexScanState*node)
954954
{
955955
HASHCTLhash_ctl;
956+
longnbuckets;
956957

958+
node->iss_MaxHash= (SortMem*1024L) /
959+
(MAXALIGN(sizeof(HASHELEMENT))+MAXALIGN(sizeof(DupHashTabEntry)));
957960
MemSet(&hash_ctl,0,sizeof(hash_ctl));
958961
hash_ctl.keysize=SizeOfIptrData;
959962
hash_ctl.entrysize=sizeof(DupHashTabEntry);
960963
hash_ctl.hash=tag_hash;
961964
hash_ctl.hcxt=CurrentMemoryContext;
965+
nbuckets= (long)ceil(node->ss.ps.plan->plan_rows);
966+
if (nbuckets<1)
967+
nbuckets=1;
968+
if (nbuckets>node->iss_MaxHash)
969+
nbuckets=node->iss_MaxHash;
962970
node->iss_DupHash=hash_create("DupHashTable",
963-
(long)ceil(node->ss.ps.plan->plan_rows),
971+
nbuckets,
964972
&hash_ctl,
965973
HASH_ELEM |HASH_FUNCTION |HASH_CONTEXT);
966974
if (node->iss_DupHash==NULL)
967975
ereport(ERROR,
968976
(errcode(ERRCODE_OUT_OF_MEMORY),
969977
errmsg("out of memory")));
970-
node->iss_MaxHash= (SortMem*1024L) /
971-
(MAXALIGN(sizeof(HASHELEMENT))+MAXALIGN(sizeof(DupHashTabEntry)));
972978
}
973979

974980
int

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp