Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 44ccdce

Browse files
committed
postgres_fdw: Fix bug in checking of return value of PQsendQuery().
When postgres_fdw begins an asynchronous data fetch, it submits FETCH query by using PQsendQuery(). If PQsendQuery() fails and returns 0, postgres_fdw should report an error. But, previously, postgres_fdw reported an error only when the return value is less than 0, though PQsendQuery() never return the values other than 0 and 1. Therefore postgres_fdw could not handle the failure to send FETCH query in an asynchronous data fetch. This commit fixes postgres_fdw so that it reports an error when PQsendQuery() returns 0. Back-patch to v14 where asynchronous execution was supported in postgres_fdw. Author: Fujii Masao Reviewed-by: Japin Li, Tom Lane Discussion: https://postgr.es/m/b187a7cf-d4e3-5a32-4d01-8383677797f3@oss.nttdata.com
1 parent a1b5609 commit 44ccdce

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contrib/postgres_fdw/postgres_fdw.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -7070,7 +7070,7 @@ fetch_more_data_begin(AsyncRequest *areq)
70707070
snprintf(sql, sizeof(sql), "FETCH %d FROM c%u",
70717071
fsstate->fetch_size, fsstate->cursor_number);
70727072

7073-
if (PQsendQuery(fsstate->conn, sql) < 0)
7073+
if (!PQsendQuery(fsstate->conn, sql))
70747074
pgfdw_report_error(ERROR, NULL, fsstate->conn, false, fsstate->query);
70757075

70767076
/* Remember that the request is in process */

0 commit comments

Comments
 (0)