Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dHtnH-0004Ag-DE for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Jun 2017 15:19:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dHtnG-0003Gn-Lb for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Jun 2017 15:19:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dHtnF-0003GN-VC for pgsql-hackers@postgreSQL.org; Mon, 05 Jun 2017 15:19:46 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dHtnD-0001WR-Ch for pgsql-hackers@postgreSQL.org; Mon, 05 Jun 2017 15:19:45 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v55FJfRk009698 for ; Mon, 5 Jun 2017 11:19:41 -0400 From: Tom Lane To: pgsql-hackers@postgreSQL.org Subject: shm_toc_lookup API MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9696.1496675981.1@sss.pgh.pa.us> Date: Mon, 05 Jun 2017 11:19:41 -0400 Message-ID: <9697.1496675981@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) 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 shm_toc_lookup() returns NULL if it fails to find the desired key. Out of the 30 or so call sites, there is exactly one that has any use for that. Some of the rest have Asserts that they get back a non-null result, but the majority just blithely dereference the pointer. I do not find this cool at all; given that we're accessing a shared data structure, we should assign more than zero probability to the idea that we might not find what we expect to find when we expect to find it. I think that shm_toc_lookup() ought to be made to throw elog(ERROR) on an unexpected failure. To satisfy the one caller that doesn't want an error, we could either add a "bool noError" parameter to it, or split it into two functions shm_toc_lookup() and shm_toc_lookup_noerror(). The latter would require touching less code, but the former is probably more like what we'd have had if this were designed more carefully to begin with. Any preferences? regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers