Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n5sV9-00075M-Th for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Jan 2022 16:54:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n5sV8-0001nV-FJ for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Jan 2022 16:54:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n5sV8-0001nM-5X for pgsql-hackers@lists.postgresql.org; Fri, 07 Jan 2022 16:54:02 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n5sV5-0000Jp-Cv for pgsql-hackers@lists.postgresql.org; Fri, 07 Jan 2022 16:54:01 +0000 Received: from [192.168.11.9] (p3315238-ipngn8901funabasi.chiba.ocn.ne.jp [153.171.29.238]) by oss.nttdata.com (Postfix) with ESMTPSA id 5A9A860891; Sat, 8 Jan 2022 01:53:53 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.4 at oss.nttdata.com Message-ID: <01c32f6c-8101-1ce4-8295-534cf067df94@oss.nttdata.com> Date: Sat, 8 Jan 2022 01:53:52 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Subject: Re: make MaxBackends available in _PG_init Content-Language: en-US To: "Bossart, Nathan" , "wangsh.fnst@fujitsu.com" Cc: Robert Haas , Andres Freund , Bharath Rupireddy , Greg Sabino Mullane , Tom Lane , "pgsql-hackers@lists.postgresql.org" References: <4f20d57b2aeb447b8eb1495319940c5f@G08CNEXMBPEKD06.g08.fujitsu.local> <8499D41B-628A-4CE0-9139-00D718F9D06B@amazon.com> <20210802203724.ujmzgwukenm2en3j@alap3.anarazel.de> <9B2E85FE-14BC-407A-93B7-4EE2F84BEF05@amazon.com> <77F481D5-2F4C-405E-9335-E68550375D4B@amazon.com> <3969791.1628690881@sss.pgh.pa.us> From: Fujii Masao In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021/08/16 13:02, Bossart, Nathan wrote: > On 8/15/21, 1:05 AM, "wangsh.fnst@fujitsu.com" wrote: >> I don't think calling function GetMaxBackends() in the for loop is a good idea. >> How about use a temp variable to save the return value of function GetMaxBackends() ? > > I did this in v4. There may be a couple of remaining places that call > GetMaxBackends() several times, but the function should be relatively > inexpensive. The patch handles only MaxBackends. But isn't there other variable having the same issue? It seems overkill to remove "extern" from MaxBackends and replace MaxBackends with GetMaxBackends() in the existing PostgreSQL codes. I'm not sure how much it's actually worth doing that. Instead, isn't it enough to just add the comment like "Use GetMaxBackends() if you want to treat the lookup for uninitialized MaxBackends as an error" in the definition of MaxBackends? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION