Re: generic plans and "initial" pruning

From: Rui Zhao <zhaorui126(at)gmail(dot)com>
To: Manu <manuelreyesbravo(at)gmail(dot)com>
Cc: Amit Langote <amitlangote09(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: generic plans and "initial" pruning
Date: 2026-09-27 17:45:30
Message-ID: CAHWVJhEk4fxnjL9g+zX_wY3bAtAPDcri9fopEV+MW583A4uZvg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2026-Sep-23 at 00:15 UTC, Manu wrote:
> If you have a way to reach that branch I am happy to run it.

I can reach it on Linux using v13's existing plancache.sql setup.
The new test fails on v13 and passes with Manu's ownership correction.
I've combined Manu's correction and the test in the attached patch,
which applies on top of v13.

The existing case uses EXPLAIN EXECUTE, whose retry is handled by
ExplainExecuteQuery(), not PortalLockCachedPlan(). Ordinary EXECUTE
exercises the latter.

In v13-0004's plancache.sql, immediately before
"deallocate inval_during_pruning_q", I ran:

execute inval_during_pruning_q;
update inval_during_pruning_signal set create_idx = true;
execute inval_during_pruning_q;

The first EXECUTE caches a valid plan after the earlier DDL. Setting
create_idx to true makes the helper create another partition index
during initial pruning in the last EXECUTE, invalidating that plan.

On v13 over master 3c5d9d914fa, the last command gives:

ERROR: plancache reference 0x233e2b0 is not owned by resource owner Portal

With Manu's correction it returns the expected row, a = 1. The attachment
keeps the existing EXPLAIN EXECUTE case and adds this EXECUTE case.

The original core regression, isolation and test_plan_advice suites
also pass both with and without Manu's correction.

Regards,
Rui

Attachment Content-Type Size
0001-Fix-cached-plan-ownership-during-portal-replanning.patch application/octet-stream 3.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Andrey Borodin 2026-09-27 17:26:08 Re: [PATCH] Add memory/disk usage for Function Scan nodes in EXPLAIN