Re: Error handling for ShmemInitStruct and ShmemInitHash

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Error handling for ShmemInitStruct and ShmemInitHash
Date: 2010-04-28 07:47:02
Message-ID: 4BD7E7F6.3070906@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> 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.

+1. I was just annoyed by this when working on the known-assigned-xids
hash -> sorted-array patch.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2010-04-28 08:00:04 Re: Re: [COMMITTERS] pgsql: Make CheckRequiredParameterValues() depend upon correct
Previous Message Heikki Linnakangas 2010-04-28 07:43:06 Re: Re: [COMMITTERS] pgsql: Make CheckRequiredParameterValues() depend upon correct