Error handling for ShmemInitStruct and ShmemInitHash

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Error handling for ShmemInitStruct and ShmemInitHash
Date: 2010-04-28 02:34:42
Message-ID: 13370.1272422082@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The functions ShmemInitStruct and ShmemInitHash will return NULL on
certain failure conditions, apparently on the grounds that their caller
can print a more useful error message than they can. A quick survey
shows that about half the callers aren't remembering to check for NULL,
and none of the other half are printing messages that are more useful
than "out of shared memory" (which isn't even necessarily correct).

I think that this is pretty error-prone, and that considering that
PG hackers are accustomed to not checking palloc() results, it's
inevitable that we'll make the same mistake in future if we leave
this API as it is. I suggest making these functions throw
their own errors rather than returning NULL on failure, and removing
the redundant error reports from the callers that have 'em.

Comments?

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2010-04-28 02:43:59 Re: Wierd quirk of HS/SR, probably not fixable
Previous Message Robert Haas 2010-04-28 01:59:31 Re: including PID or backend ID in relpath of temp rels