Skip to content

Commit 8ec05b2

Browse files
author
Neil Conway
committed
Modify hash_create() to elog(ERROR) if an error occurs, rather than
returning a NULL pointer (some callers remembered to check the return value, but some did not -- it is safer to just bail out). Also, cleanup pgstat.c to use elog(ERROR) rather than elog(LOG) followed by exit().
1 parent 346aff0 commit 8ec05b2

File tree

9 files changed

+48
-174
lines changed

9 files changed

+48
-174
lines changed

contrib/dblink/dblink.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,19 +2043,11 @@ static HTAB *
20432043
createConnHash(void)
20442044
{
20452045
HASHCTL ctl;
2046-
HTAB *ptr;
20472046

20482047
ctl.keysize = NAMEDATALEN;
20492048
ctl.entrysize = sizeof(remoteConnHashEnt);
20502049

2051-
ptr = hash_create("Remote Con hash", NUMCONN, &ctl, HASH_ELEM);
2052-
2053-
if (!ptr)
2054-
ereport(ERROR,
2055-
(errcode(ERRCODE_OUT_OF_MEMORY),
2056-
errmsg("out of memory")));
2057-
2058-
return (ptr);
2050+
return hash_create("Remote Con hash", NUMCONN, &ctl, HASH_ELEM);
20592051
}
20602052

20612053
static void

src/backend/commands/prepare.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Copyright (c) 2002-2004, PostgreSQL Global Development Group
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.32 2004/09/13 20:06:29 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.33 2004/10/25 00:46:40 neilc Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -264,9 +264,6 @@ InitQueryHashTable(void)
264264
32,
265265
&hash_ctl,
266266
HASH_ELEM);
267-
268-
if (!prepared_queries)
269-
elog(ERROR, "could not create hash table");
270267
}
271268

272269
/*

src/backend/executor/execGrouping.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/execGrouping.c,v 1.11 2004/08/29 05:06:42 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/execGrouping.c,v 1.12 2004/10/25 00:46:40 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -322,10 +322,6 @@ BuildTupleHashTable(int numCols, AttrNumber *keyColIdx,
322322
hashtable->hashtab = hash_create("TupleHashTable", (long) nbuckets,
323323
&hash_ctl,
324324
HASH_ELEM | HASH_FUNCTION | HASH_COMPARE | HASH_CONTEXT);
325-
if (hashtable->hashtab == NULL)
326-
ereport(ERROR,
327-
(errcode(ERRCODE_OUT_OF_MEMORY),
328-
errmsg("out of memory")));
329325

330326
return hashtable;
331327
}

src/backend/executor/nodeIndexscan.c

Lines changed: 1 addition & 5 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.97 2004/08/29 05:06:42 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.98 2004/10/25 00:46:40 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1045,10 +1045,6 @@ create_duphash(IndexScanState *node)
10451045
nbuckets,
10461046
&hash_ctl,
10471047
HASH_ELEM | HASH_FUNCTION | HASH_CONTEXT);
1048-
if (node->iss_DupHash == NULL)
1049-
ereport(ERROR,
1050-
(errcode(ERRCODE_OUT_OF_MEMORY),
1051-
errmsg("out of memory")));
10521048
}
10531049

10541050
int

0 commit comments

Comments
 (0)