Re: hash_create(): check return code

From: Neil Conway <neilc(at)samurai(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: hash_create(): check return code
Date: 2004-10-24 08:27:20
Message-ID: 417B6768.7060107@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Tom Lane wrote:
> With all due respect to Jan, that coding seems 100% bogus. elog(ERROR)
> will work (it had better, because pgstat.c certainly calls routines that
> might do it) and the insistence on using exit() rather than proc_exit()
> is just plain wrong anyway.

Attached is a patch that makes the following cleanups:

- use elog(ERROR) in pgstat.c to indicate fatal errors, rather than
elog(LOG) followed by exit(1)

- use elog(ERROR) to indicate an error in hash_create() rather than
returning a NULL pointer

- adjust callers of hash_create() to assume the return value is non-NULL

There was one case in pgstat.c where I had to wrap the hash_create()
call in a PG_TRY() block to ensure a file handle is closed (this code
might be invoked by a regular backend it appears, so elog(ERROR) won't
necessarily close the file handle).

Barring any objections, I'll apply this to HEAD on Monday.

-Neil

Attachment Content-Type Size
hash_create-3.patch text/plain 12.0 KB

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-10-24 14:25:59 Re: hash_create(): check return code
Previous Message Tom Lane 2004-10-23 21:25:52 Re: to_char/to_number loses sign