postgresql/contrib/postgres_fdw
Etsuro Fujita 9e283fc85d postgres_fdw: Fix handling of a pending asynchronous request in postgresReScanForeignScan().
Commit 27e1f1456 failed to process a pending asynchronous request made
for a given ForeignScan node in postgresReScanForeignScan() (if any) in
cases where we would only reset the next_tuple counter in that function,
contradicting the assumption that there should be no pending
asynchronous requests that have been made for async-capable subplans for
the parent Append node after ReScan.  This led to an assert failure in
an assert-enabled build.  I think this would also lead to mis-rewinding
the cursor in that function in the case where we have already fetched
one batch for the ForeignScan node and the asynchronous request has been
made for the second batch, because even in that case we would just reset
the counter when called from that function, so we would fail to execute
MOVE BACKWARD ALL.

To fix, modify that function to process the asynchronous request before
restarting the scan.

While at it, add a comment to a function to match other places.

Per bug #17344 from Alexander Lakhin.  Back-patch to v14 where the
aforesaid commit came in.

Patch by me.  Test case by Alexander Lakhin, adjusted by me.  Reviewed
and tested by Alexander Lakhin and Dmitry Dolgov.

Discussion: https://postgr.es/m/17344-226b78b00de73a7e@postgresql.org
2022-01-27 16:15:00 +09:00
..
expected postgres_fdw: Fix handling of a pending asynchronous request in postgresReScanForeignScan(). 2022-01-27 16:15:00 +09:00
sql postgres_fdw: Fix handling of a pending asynchronous request in postgresReScanForeignScan(). 2022-01-27 16:15:00 +09:00
.gitignore Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
Makefile postgres_fdw: Add function to list cached connections to foreign servers. 2021-01-18 15:11:08 +09:00
connection.c postgres_fdw: Fix subabort cleanup of connections used in asynchronous execution. 2022-01-21 17:45:00 +09:00
deparse.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
option.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
postgres_fdw--1.0--1.1.sql postgres_fdw: Add functions to discard cached connections. 2021-01-26 15:35:54 +09:00
postgres_fdw--1.0.sql Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
postgres_fdw.c postgres_fdw: Fix handling of a pending asynchronous request in postgresReScanForeignScan(). 2022-01-27 16:15:00 +09:00
postgres_fdw.control postgres_fdw: Add function to list cached connections to foreign servers. 2021-01-18 15:11:08 +09:00
postgres_fdw.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
shippable.c Update copyright for 2022 2022-01-07 19:04:57 -05:00