1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

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().
This commit is contained in:
Neil Conway
2004-10-25 00:46:43 +00:00
parent 346aff04be
commit 8ec05b28b7
9 changed files with 49 additions and 175 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.85 2004/10/01 20:39:54 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.86 2004/10/25 00:46:42 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -515,10 +515,6 @@ record_C_func(HeapTuple procedureTuple,
100,
&hash_ctl,
HASH_ELEM | HASH_FUNCTION);
if (CFuncHash == NULL)
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
}
entry = (CFuncHashTabEntry *)

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.55 2004/10/22 07:21:06 neilc Exp $
* $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.56 2004/10/25 00:46:43 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -120,8 +120,6 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
/* Initialize the hash header */
hashp = (HTAB *) MEM_ALLOC(sizeof(HTAB));
if (!hashp)
return NULL;
MemSet(hashp, 0, sizeof(HTAB));
hashp->tabname = (char *) MEM_ALLOC(strlen(tabname) + 1);
@@ -175,7 +173,9 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
{
hashp->hctl = (HASHHDR *) hashp->alloc(sizeof(HASHHDR));
if (!hashp->hctl)
return NULL;
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
}
hdefault(hashp);
@@ -231,7 +231,7 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
if (!init_htab(hashp, nelem))
{
hash_destroy(hashp);
return NULL;
elog(ERROR, "failed to initialize hash table");
}
/*
@@ -243,7 +243,9 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
if (!element_alloc(hashp, (int) nelem))
{
hash_destroy(hashp);
return NULL;
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
}
}