postgresql/contrib/postgres_fdw
Etsuro Fujita 5a9af48689 Fix EvalPlanQual handling of foreign/custom joins in ExecScanFetch.
If inside an EPQ recheck, ExecScanFetch would run the recheck method
function for foreign/custom joins even if they aren't descendant nodes
in the EPQ recheck plan tree, which is problematic at least in the
foreign-join case, because such a foreign join isn't guaranteed to have
an alternative local-join plan required for running the recheck method
function; in the postgres_fdw case this could lead to a segmentation
fault or an assert failure in an assert-enabled build when running the
recheck method function.

Even if inside an EPQ recheck, any scan nodes that aren't descendant
ones in the EPQ recheck plan tree should be normally processed by using
the access method function; fix by modifying ExecScanFetch so that if
inside an EPQ recheck, it runs the recheck method function for
foreign/custom joins that are descendant nodes in the EPQ recheck plan
tree as before and runs the access method function for foreign/custom
joins that aren't.

This fix also adds to postgres_fdw an isolation test for an EPQ recheck
that caused issues stated above.

Oversight in commit 385f337c9.

Reported-by: Kristian Lejao <kristianlejao@gmail.com>
Author: Masahiko Sawada <sawada.mshk@gmail.com>
Co-authored-by: Etsuro Fujita <etsuro.fujita@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com>
Discussion: https://postgr.es/m/CAD21AoBpo6Gx55FBOW+9s5X=nUw3Xpq64v35fpDEKsTERnc4TQ@mail.gmail.com
Backpatch-through: 13
2025-10-15 17:15:03 +09:00
..
expected Fix EvalPlanQual handling of foreign/custom joins in ExecScanFetch. 2025-10-15 17:15:03 +09:00
specs Fix EvalPlanQual handling of foreign/custom joins in ExecScanFetch. 2025-10-15 17:15:03 +09:00
sql postgres_fdw: Fix tests with ANALYZE and remote sampling 2025-08-13 13:11:51 +09:00
.gitignore Fix EvalPlanQual handling of foreign/custom joins in ExecScanFetch. 2025-10-15 17:15:03 +09:00
connection.c Make postgres_fdw request remote time zone 'GMT' not 'UTC'. 2024-04-21 13:46:20 -04:00
deparse.c Fix deparsing of Consts in postgres_fdw ORDER BY 2024-03-11 12:27:46 +13:00
Makefile Fix EvalPlanQual handling of foreign/custom joins in ExecScanFetch. 2025-10-15 17:15:03 +09:00
meson.build Fix EvalPlanQual handling of foreign/custom joins in ExecScanFetch. 2025-10-15 17:15:03 +09:00
option.c Fix Y2038 issues with MyStartTime. 2024-10-07 13:51:03 -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 Fix memory leakage in postgres_fdw's DirectModify code path. 2025-05-30 13:45:41 -04: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 Check relkind before using TABLESAMPLE in postgres_fdw 2023-01-07 14:39:33 +01:00
shippable.c Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00