Re: postgres_fdw: Fix bug in checking of return value of PQsendQuery().

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: postgres_fdw: Fix bug in checking of return value of PQsendQuery().
Date: 2022-07-22 03:07:28
Message-ID: bc4ddc79-2115-02d0-7dab-baa269d7a769@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2022/07/21 23:41, Japin Li wrote:
>
> On Thu, 21 Jul 2022 at 22:22, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Junwang Zhao 2022-07-22 03:08:54 Re: question about `static inline` functions in header files
Previous Message Tom Lane 2022-07-22 03:03:43 Re: question about `static inline` functions in header files