renaming, phase 2
authorRobert Haas <rhaas@postgresql.org>
Wed, 16 Jul 2025 13:52:02 +0000 (09:52 -0400)
committerRobert Haas <rhaas@postgresql.org>
Wed, 16 Jul 2025 13:52:02 +0000 (09:52 -0400)
contrib/pg_plan_advice/pgpa_output.c
contrib/pg_plan_advice/pgpa_scan.h [new file with mode: 0644]
src/tools/pgindent/typedefs.list

index 4c637d6b14bfbbe89f14558322859704791dcd7c..43b82f028ab715f391582d17f4758109b7a6f308 100644 (file)
@@ -20,7 +20,7 @@ typedef struct pgpa_output_context
        const char **rt_identifiers;
        StringInfo      buf;
        List       *unrolled_joins[NUM_PGPA_JOIN_STRATEGY];
-       List       *scans[NUM_PGPA_CLUMP_JOIN_STRATEGY];
+       List       *scans[NUM_PGPA_SCAN_STRATEGY];
        List       *query_features[NUM_PGPA_QF_TYPES];
        int                     wrap_column;
 } pgpa_output_context;
@@ -32,8 +32,8 @@ static void pgpa_output_join_member(pgpa_output_context *context,
 static void pgpa_output_relations(pgpa_output_context *context, StringInfo buf,
                                                                  Bitmapset *relids);
 
-static char *pgpa_cstring_join_clump_strategy(pgpa_join_clump_strategy strategy);
 static char *pgpa_cstring_join_strategy(pgpa_join_strategy strategy);
+static char *pgpa_cstring_scan_strategy(pgpa_scan_strategy strategy);
 
 static void pgpa_maybe_linebreak(StringInfo buf, int wrap_column);
 
@@ -148,9 +148,9 @@ pgpa_output_advice(StringInfo buf, pgpa_plan_walker_context *walker,
         * types as well as join types, and the question of how to handle that
         * deserves more thought.
         */
-       for (int c = 0; c < NUM_PGPA_CLUMP_JOIN_STRATEGY; ++c)
+       for (int c = 0; c < NUM_PGPA_SCAN_STRATEGY; ++c)
        {
-               char *cstrategy = pgpa_cstring_join_clump_strategy(c);
+               char *cstrategy = pgpa_cstring_scan_strategy(c);
                bool    first = true;
 
                if (context.scans[c] == NIL)
@@ -345,25 +345,6 @@ pgpa_output_relations(pgpa_output_context *context, StringInfo buf,
        }
 }
 
-/*
- * Get a C string that corresponds to the specified join clump strategy.
- */
-static char *
-pgpa_cstring_join_clump_strategy(pgpa_join_clump_strategy strategy)
-{
-       switch (strategy)
-       {
-               case JSTRAT_CLUMP_DEGENERATE:
-                       return "DEGENERATE";
-               case JSTRAT_CLUMP_FOREIGN:
-                       return "FOREIGN";
-               case JSTRAT_CLUMP_PARTITIONWISE:
-                       return "PARTITIONWISE";
-       }
-
-       Assert(false);
-}
-
 /*
  * Get a C string that corresponds to the specified join strategy.
  */
@@ -389,6 +370,25 @@ pgpa_cstring_join_strategy(pgpa_join_strategy strategy)
        Assert(false);
 }
 
+/*
+ * Get a C string that corresponds to the specified scan strategy.
+ */
+static char *
+pgpa_cstring_scan_strategy(pgpa_scan_strategy strategy)
+{
+       switch (strategy)
+       {
+               case JSTRAT_CLUMP_DEGENERATE:
+                       return "DEGENERATE";
+               case JSTRAT_CLUMP_FOREIGN:
+                       return "FOREIGN";
+               case JSTRAT_CLUMP_PARTITIONWISE:
+                       return "PARTITIONWISE";
+       }
+
+       Assert(false);
+}
+
 /*
  * Insert a line break into the StringInfoData, if needed.
  *
diff --git a/contrib/pg_plan_advice/pgpa_scan.h b/contrib/pg_plan_advice/pgpa_scan.h
new file mode 100644 (file)
index 0000000..5724af1
--- /dev/null
@@ -0,0 +1,64 @@
+/*-------------------------------------------------------------------------
+ *
+ * pgpa_scan.h
+ *       analysis of scans in Plan trees
+ *
+ * Note that our definition of "scan" is extremely broad. It includes
+ * (1) single plan nodes that scan multiple RTIs, such as a degenerate
+ * Result node that replaces what would otherwise have been a join, and
+ * (2) Append and MergeAppend nodes implementing a partitionwise scan
+ * or a partitionwise join.
+ *
+ * Copyright (c) 2016-2025, PostgreSQL Global Development Group
+ *
+ *       contrib/pg_plan_advice/pgpa_scan.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef PGPA_SCAN_H
+#define PGPA_SCAN_H
+
+#include "nodes/plannodes.h"
+
+/*
+ * Certain types of plan nodes can join any number of input relations in
+ * a single step; we call these "clumped joins".
+ *
+ * For our purposes, the important thing about a clumped join is that we
+ * can't meaningfully speak about the order in which tables are joined
+ * within a single clump. For example, if the optimizer chooses a
+ * partitionwise join on tables A and B, we can't say whether A was joined
+ * to B or whether B was joined to A; instead, each pair of child tables
+ * has its own join order. Likewise, if a foreign data wrapper pushes a
+ * join to the remote side, we don't know the join order.
+ *
+ * JSTRAT_CLUMP_DEGENERATE refers to the case where several relations are
+ * all proven empty and replaced with a single Result node. Here again, while
+ * the Result node may be joined to other things and we can speak about its
+ * place within the larger join order, we can't speak about a join ordering
+ * within the Result node itself.
+ */
+typedef enum
+{
+       JSTRAT_CLUMP_DEGENERATE = 0,
+       JSTRAT_CLUMP_FOREIGN,
+       JSTRAT_CLUMP_PARTITIONWISE
+       /* update NUM_PGPA_CLUMP_JOIN_STRATEGY if you add anything here */
+} pgpa_scan_strategy;
+
+#define NUM_PGPA_SCAN_STRATEGY ((int) JSTRAT_CLUMP_PARTITIONWISE + 1)
+
+/*
+ * All of the details we need regarding a scan.
+ */
+typedef struct pgpa_scan
+{
+       Plan       *plan;
+       pgpa_scan_strategy strategy;
+       Bitmapset  *relids;
+} pgpa_scan;
+
+extern pgpa_scan *pgpa_build_scan(PlannedStmt *pstmt, Plan *plan,
+                                                                 ElidedNode *elided_node);
+
+#endif
index f8622e276c623d19271a58e45953bb5fbb165bd2..2e2ee9aa9872bc5ee6384b986450dc76df499d65 100644 (file)
@@ -4311,17 +4311,17 @@ ExplainOptionHandler
 overexplain_options
 SubPlanRTInfo
 ElidedNode
+pgpa_collected_advice
 pgpa_join_class
-pgpa_join_clump_strategy
 pgpa_join_member
 pgpa_join_strategy
-pgpa_clumped_join
-pgpa_unrolled_join
 pgpa_join_unroller
-pgpa_plan_walker_context
-pgpa_output_context
-pgpa_collected_advice
-pgpa_local_advice_chunk
 pgpa_local_advice
-pgpa_shared_advice_chunk
+pgpa_local_advice_chunk
+pgpa_output_context
+pgpa_plan_walker_context
+pgpa_scan
+pgpa_scan_strategy
 pgpa_shared_advice
+pgpa_shared_advice_chunk
+pgpa_unrolled_join