pgsql: Fix segfault during EvalPlanQual with mix of local and foreign p - Mailing list pgsql-committers

From Heikki Linnakangas
Subject pgsql: Fix segfault during EvalPlanQual with mix of local and foreign p
Date
Msg-id E1mE6Ep-0008Ie-Uy@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix segfault during EvalPlanQual with mix of local and foreign partitions.

It's not sensible to re-evaluate a direct-modify Foreign Update or Delete
during EvalPlanQual. However, ExecInitForeignScan() can still get called
if a table mixes local and foreign partitions. EvalPlanQualStart() left
the es_result_relations array uninitialized in the child EPQ EState, but
ExecInitForeignScan() still expected to find it. That caused a segfault.

Fix by skipping the es_result_relations lookup during EvalPlanQual
processing. To make things a bit more robust, also skip the
BeginDirectModify calls, and add a runtime check that ExecForeignScan()
is not called on direct-modify foreign scans during EvalPlanQual
processing.

This is new in v14, commit 1375422c782. Before that, EvalPlanQualStart()
copied the whole ResultRelInfo array to the EPQ EState. Backpatch to v14.

Report and diagnosis by Andrey Lepikhov.

Discussion: https://www.postgresql.org/message-id/cb2b808d-cbaa-4772-76ee-c8809bafcf3d%40postgrespro.ru

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6458ed18fe40ac91f29496128dd1a49c0ef2db5b

Modified Files
--------------
src/backend/executor/nodeForeignscan.c | 46 ++++++++++++++++++++++++++++++----
1 file changed, 41 insertions(+), 5 deletions(-)


pgsql-committers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o
Next
From: Michael Paquier
Date:
Subject: pgsql: Avoid unnecessary shared invalidations in ROLLBACK PREPARED