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 1mLlxW-0004jr-T2 for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Sep 2021 12:36:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mLlxU-0003nO-Ps for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Sep 2021 12:36:44 +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 1mLlxU-0003nC-HW for pgsql-hackers@lists.postgresql.org; Thu, 02 Sep 2021 12:36:44 +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 1mLlxQ-000523-HM for pgsql-hackers@lists.postgresql.org; Thu, 02 Sep 2021 12:36:43 +0000 Received: from hrk.local (p2388012-ipbf1027funabasi.chiba.ocn.ne.jp [118.6.6.12]) by oss.nttdata.com (Postfix) with ESMTPSA id C49FA6079C; Thu, 2 Sep 2021 21:36:34 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.3 at oss.nttdata.com Subject: Re: Allow escape in application_name (was: [postgres_fdw] add local pid to fallback_application_name) To: "kuroda.hayato@fujitsu.com" Cc: "'pgsql-hackers@lists.postgresql.org'" , 'Tom Lane' References: <8f985ba0-2e79-ab67-4fa4-d35024188047@oss.nttdata.com> <0d5df322-c9ad-308e-982b-a3d3275bcdc0@oss.nttdata.com> From: Fujii Masao Message-ID: <2dde164d-bc49-b3ca-0cc1-1c5fe40f0886@oss.nttdata.com> Date: Thu, 2 Sep 2021 21:36:34 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=iso-2022-jp; format=flowed; delsp=yes Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021/09/02 18:27, kuroda.hayato@fujitsu.com wrote: > I added the following comments: > > ```diff > - /* Use "postgres_fdw" as fallback_application_name. */ > + /* > + * Use pgfdw_application_name as application_name. > + * > + * Note that this check must be behind constructing generic options > + * because pgfdw_application_name has higher priority. > + */ > ``` Thanks! What about updating the comments furthermore as follows? --------------------------------- Use pgfdw_application_name as application_name if set. PQconnectdbParams() processes the parameter arrays from start to end. If any key word is repeated, the last value is used. Therefore note that pgfdw_application_name must be added to the arrays after options of ForeignServer are, so that it can override application_name set in ForeignServer. --------------------------------- > Attached is the fixed version. 0002 will be rebased later. Thanks for updating the patch! + } + /* Use "postgres_fdw" as fallback_application_name */ It's better to add new empty line between these two lines. +-- Disconnect once because the value is used only when establishing connections +DO $$ + BEGIN + PERFORM postgres_fdw_disconnect_all(); + END +$$; Why does DO command need to be used here to execute postgres_fdw_disconnect_all()? Instead, we can just execute "SELECT 1 FROM postgres_fdw_disconnect_all();"? For test coverage, it's better to test at least the following three cases? (1) appname is set in neither GUC nor foreign server -> "postgres_fdw" set in fallback_application_name is used (2) appname is set in foreign server, but not in GUC -> appname in foreign server is used (3) appname is set both in GUC and foreign server -> appname in GUC is used +SELECT FROM ft1 LIMIT 1; "1" should be added just after SELECT in the above statement? Because postgres_fdw regression test basically uses "SELECT 1 FROM ..." in other places. + DefineCustomStringVariable("postgres_fdw.application_name", + "Sets the application name. This is used when connects to the remote server.", What about simplifying this description as follows? --------------- Sets the application name to be used on the remote server. --------------- + Configuration Parameters + The empty characters just after and before should be removed? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION