pgsql: Fix EPQ crash from missing partition pruning state in EState

From: Amit Langote <amitlan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix EPQ crash from missing partition pruning state in EState
Date: 2025-09-19 02:41:07
Message-ID: E1uzR3a-001QKs-25@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix EPQ crash from missing partition pruning state in EState

Commit bb3ec16e14 moved partition pruning metadata into PlannedStmt.
At executor startup this metadata is used to initialize the EState
fields es_part_prune_infos, es_part_prune_states, and
es_part_prune_results. EvalPlanQualStart() failed to copy those
fields into the child EState, causing NULL dereference when Append
ran partition pruning during a recheck. This can occur with DELETE
or UPDATE on partitioned tables that use runtime pruning, e.g. with
generic plans.

Fix by copying all partition pruning state into the EPQ estate.

Add an isolation test that reproduces the crash with concurrent
UPDATE and DELETE on a partitioned table, where the DELETE session
hits the crash during its EPQ recheck after the UPDATE commits.

Bug: #19056
Reported-by: Fei Changhong <feichanghong(at)qq(dot)com>
Diagnozed-by: Fei Changhong <feichanghong(at)qq(dot)com>
Author: David Rowley <dgrowleyml(at)gmail(dot)com>
Co-authored-by: Amit Langote <amitlangote09(at)gmail(dot)com>
Discussion: https://postgr.es/m/19056-a677cef9b54d76a0%40postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8741e48e5ddaab1148419ad8a4cd00098de57efc

Modified Files
--------------
src/backend/executor/execMain.c | 9 +++++++++
src/test/isolation/expected/eval-plan-qual.out | 9 +++++++++
src/test/isolation/specs/eval-plan-qual.spec | 8 ++++++++
3 files changed, 26 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-09-19 04:49:04 pgsql: Make XLogFlush() and XLogNeedsFlush() decision-making more consi
Previous Message Amit Langote 2025-09-19 02:40:53 pgsql: Fix EPQ crash from missing partition pruning state in EState