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 1oEj0q-0001ba-JT for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Jul 2022 03:07:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oEj0p-0001FY-7c for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Jul 2022 03:07:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oEj0o-0001FG-UW for pgsql-hackers@lists.postgresql.org; Fri, 22 Jul 2022 03:07:34 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oEj0m-0007MR-8b for pgsql-hackers@lists.postgresql.org; Fri, 22 Jul 2022 03:07:33 +0000 Received: from [10.6.216.58] (unknown [203.180.48.65]) by oss.nttdata.com (Postfix) with ESMTPSA id 5E9666083F; Fri, 22 Jul 2022 12:07:29 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.6 at oss.nttdata.com Message-ID: Date: Fri, 22 Jul 2022 12:07:28 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: postgres_fdw: Fix bug in checking of return value of PQsendQuery(). Content-Language: en-US To: Japin Li Cc: pgsql-hackers@postgresql.org, pgsql-hackers@lists.postgresql.org References: 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 2022/07/21 23:41, Japin Li wrote: > > On Thu, 21 Jul 2022 at 22:22, Fujii Masao wrote: >> Hi, >> >> I found that fetch_more_data_begin() in postgres_fdw reports an error when PQsendQuery() returns the value less than 0 as follows though PQsendQuery() can return only 1 or 0. I think this is a bug. Attached is the patch that fixes this bug. This needs to be back-ported to v14 where async execution was supported in postgres_fdw. >> >> if (PQsendQuery(fsstate->conn, sql) < 0) >> pgfdw_report_error(ERROR, NULL, fsstate->conn, false, fsstate->query); >> >> Regards, > > +1. However, I think check whether the result equals 0 or 1 might be better. Maybe. I just used "if (!PQsendQuery())" style because it's used in postgres_fdw elsewhere. > Anyway, the patch works correctly. Thanks for the review! Pushed. Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION