From a9757078ede132a93a746eece0b0b605b19fb8af Mon Sep 17 00:00:00 2001
From: Robert Haas <rhaas@postgresql.org>
Date: Mon, 25 Aug 2025 14:29:02 -0400
Subject: [PATCH v4 5/6] Add extension_state member to PlannedStmt.

Extensions can stash data computed at plan time into this list using
planner_shutdown_hook (or perhaps other mechanisms) and then access
it from any code that has access to the PlannedStmt (such as explain
hooks), allowing for extensible debugging and instrumentation of
plans.
---
 src/include/nodes/plannodes.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index 3908847e3bf..afc00228396 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -149,6 +149,15 @@ typedef struct PlannedStmt
 	/* non-null if this is utility stmt */
 	Node	   *utilityStmt;
 
+	/*
+	 * DefElem objects added by extensions, e.g. using planner_shutdown_hook
+	 *
+	 * Set each DefElem's defname to the name of the plugin or extension, and
+	 * the argument to a tree of nodes that all have copy and read/write
+	 * support.
+	 */
+	List	   *extension_state;
+
 	/* statement location in source string (copied from Query) */
 	/* start location, or -1 if unknown */
 	ParseLoc	stmt_location;
-- 
2.39.5 (Apple Git-154)

