Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bej9G-0003Kz-Kd for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Aug 2016 13:32:18 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bej9G-0002CZ-3i for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Aug 2016 13:32:18 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bej9E-0002Bu-Oy for pgsql-hackers@postgresql.org; Tue, 30 Aug 2016 13:32:17 +0000 Received: from newmail.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bej9C-0004HB-09 for pgsql-hackers@postgresql.org; Tue, 30 Aug 2016 13:32:15 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 7E19021C2539; Tue, 30 Aug 2016 16:32:11 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Received: from mail.postgrespro.ru ([127.0.0.1]) by localhost (mail.postgrespro.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id s4PbbUO3Cwdr; Tue, 30 Aug 2016 16:32:11 +0300 (MSK) Received: from localhost (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id 37F8421C2532; Tue, 30 Aug 2016 16:32:11 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1472563931; bh=Vye1BVDAaziNfkquzYvBpBiaVIDjyGXWJUdwuO3obTU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=B7z7CHjBjImUHy6LHdz5EuPETntoisbGOyqyiXiW+zNpI8jwPqiAL0E9mSN56YTKJ 6vVjCNNGf29Rw/mQMuPgIqHKddm9LZm1inn5Ym5o2YYYi7V9mmWveVJD38RPTirqRV INyLYlkbVY3r5zCj55iACn2Kg0+P5XXXemF50E0s= Date: Tue, 30 Aug 2016 16:30:49 +0300 From: Aleksander Alekseev To: Michael Paquier Cc: Tom Lane , Heikki Linnakangas , PostgreSQL mailing lists Subject: Re: Missing checks when malloc returns NULL... Message-ID: <20160830133048.GA84635@e733> References: <7978.1466516782@sss.pgh.pa.us> <20160829130513.GA8340@e733> <20160829141315.GB8340@e733> <24843.1472563085@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) X-Pg-Spam-Score: -3.5 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org > > I think what we ought to do is make ShmemAlloc act like palloc > > (ie throw error not return NULL), and remove the duplicated error > > checks. For the one caller that that would be bad for, we could > > invent something like ShmemAllocNoError, or ShmemAllocExtended with > > a no_error flag, or whatever other new API suits your fancy. But > > as-is, it's just inviting more errors-of-omission like the large > > number that already exist. I think people are conditioned by palloc > > to expect such functions to throw error. > > The only reason why I did not propose that for ShmemAlloc is because > of extensions potentially using this routine and having some special > handling when it returns NULL. And changing it to behave like palloc > would break such extensions. I suggest to keep ShmemAlloc as is for backward compatibility and introduce a new procedure ShmemAllocSafe. Also we could add a scary comment (and also a warning log message?) that ShmemAlloc is deprecated and possibly will be removed in later releases. -- Best regards, Aleksander Alekseev -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers