diff options
| author | Neil Conway | 2004-10-25 00:46:43 +0000 |
|---|---|---|
| committer | Neil Conway | 2004-10-25 00:46:43 +0000 |
| commit | 8ec05b28b712fa4b2de5cc088ee978e05cd7e69a (patch) | |
| tree | 3220f2edfd254450493b1977d8a1f374f93f70d4 /src/backend/utils/hash | |
| parent | 346aff04be3311cefc0570022f86d43622d85f5e (diff) | |
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().
Diffstat (limited to 'src/backend/utils/hash')
| -rw-r--r-- | src/backend/utils/hash/dynahash.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/backend/utils/hash/dynahash.c b/src/backend/utils/hash/dynahash.c index 020589ba7b1..cf4e60e3c42 100644 --- a/src/backend/utils/hash/dynahash.c +++ b/src/backend/utils/hash/dynahash.c @@ -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"))); } } |
