From 0132dddab33a6eae2d3d63eda9f053e745fedb06 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Tue, 7 Oct 2025 12:09:30 -0400 Subject: Allow private state in certain planner data structures. Extension that make extensive use of planner hooks may want to coordinate their efforts, for example to avoid duplicate computation, but that's currently difficult because there's no really good way to pass data between different hooks. To make that easier, allow for storage of extension-managed private state in PlannerGlobal, PlannerInfo, and RelOptInfo, along very similar lines to what we have permitted for ExplainState since commit c65bc2e1d14a2d4daed7c1921ac518f2c5ac3d17. Reviewed-by: Andrei Lepikhov Reviewed-by: Melanie Plageman Reviewed-by: Tom Lane Discussion: http://postgr.es/m/CA+TgmoYWKHU2hKr62Toyzh-kTDEnMDeLw7gkOOnjL-TnOUq0kQ@mail.gmail.com --- src/include/nodes/pathnodes.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/include/nodes/pathnodes.h') diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h index 7ee9a7a68d8..554d7c3ef67 100644 --- a/src/include/nodes/pathnodes.h +++ b/src/include/nodes/pathnodes.h @@ -185,6 +185,10 @@ typedef struct PlannerGlobal /* hash table for NOT NULL attnums of relations */ struct HTAB *rel_notnullatts_hash pg_node_attr(read_write_ignore); + + /* extension state */ + void **extension_state pg_node_attr(read_write_ignore); + int extension_state_allocated; } PlannerGlobal; /* macro for fetching the Plan associated with a SubPlan node */ @@ -586,6 +590,10 @@ struct PlannerInfo /* PartitionPruneInfos added in this query's plan. */ List *partPruneInfos; + + /* extension state */ + void **extension_state pg_node_attr(read_write_ignore); + int extension_state_allocated; }; @@ -1097,6 +1105,10 @@ typedef struct RelOptInfo List **partexprs pg_node_attr(read_write_ignore); /* Nullable partition key expressions */ List **nullable_partexprs pg_node_attr(read_write_ignore); + + /* extension state */ + void **extension_state pg_node_attr(read_write_ignore); + int extension_state_allocated; } RelOptInfo; /* -- cgit v1.2.3