Let plan_cache_mode to be a little less strict

Andrei Lepikhov <lepihov@gmail.com>

From: Andrei Lepikhov <lepihov@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-07-15T10:53:18Z
Lists: pgsql-hackers

Attachments

Hi,

I believe the behaviour of the choose_custom_plan function should be 
adjusted slightly.

The CachedPlanSource can operate in either auto mode or force a specific 
plan type. Currently, the force_generic_plan option declares all plans 
as generic, except one-shot plans, of course. However, the 
CachedPlanSource entry also has a cursor_options field that indicates 
the caller's anticipation of a specific plan type for the statement.
This means that the configuration parameter (GUC) currently overrides 
any explicit request for a plan type. The documentation does not clearly 
explain the rationale behind this, at least to me.
I propose that the declaration of cursor_options should take precedence 
over the GUC. This change would alter the interpretation of the GUC from 
a 'forced' plan type to a 'default' plan type. By making this 
adjustment, users and extensions can be more assured that they will 
receive the requested plan type.

If there are no objections, I will add this patch to the next commitfest.

-- 
regards, Andrei Lepikhov