summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/nodes/nodes.h1
-rw-r--r--src/include/nodes/relation.h19
-rw-r--r--src/include/optimizer/paths.h7
-rw-r--r--src/include/optimizer/planmain.h2
4 files changed, 24 insertions, 5 deletions
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 8e94d9803f7..bc96ebf68e4 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -230,6 +230,7 @@ typedef enum NodeTag
T_SpecialJoinInfo,
T_AppendRelInfo,
T_PlaceHolderInfo,
+ T_MinMaxAggInfo,
T_PlannerParamItem,
/*
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h
index 6e3d0f35181..f885f5a0c46 100644
--- a/src/include/nodes/relation.h
+++ b/src/include/nodes/relation.h
@@ -189,6 +189,8 @@ typedef struct PlannerInfo
List *distinct_pathkeys; /* distinctClause pathkeys, if any */
List *sort_pathkeys; /* sortClause pathkeys, if any */
+ List *minmax_aggs; /* List of MinMaxAggInfos */
+
List *initial_rels; /* RelOptInfos we are now trying to join */
MemoryContext planner_cxt; /* context holding PlannerInfo */
@@ -1358,6 +1360,23 @@ typedef struct PlaceHolderInfo
} PlaceHolderInfo;
/*
+ * For each potentially index-optimizable MIN/MAX aggregate function,
+ * root->minmax_aggs stores a MinMaxAggInfo describing it.
+ *
+ * Note: a MIN/MAX agg doesn't really care about the nulls_first property,
+ * so the pathkey's nulls_first flag should be ignored.
+ */
+typedef struct MinMaxAggInfo
+{
+ NodeTag type;
+
+ Oid aggfnoid; /* pg_proc Oid of the aggregate */
+ Oid aggsortop; /* Oid of its sort operator */
+ Expr *target; /* expression we are aggregating on */
+ List *pathkeys; /* pathkeys representing needed sort order */
+} MinMaxAggInfo;
+
+/*
* glob->paramlist keeps track of the PARAM_EXEC slots that we have decided
* we need for the query. At runtime these slots are used to pass values
* around from one plan node to another. They can be used to pass values
diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h
index 6bce53cce57..c0ff0144fa1 100644
--- a/src/include/optimizer/paths.h
+++ b/src/include/optimizer/paths.h
@@ -173,6 +173,9 @@ extern List *make_pathkeys_for_sortclauses(PlannerInfo *root,
List *sortclauses,
List *tlist,
bool canonicalize);
+extern List *make_pathkeys_for_aggregate(PlannerInfo *root,
+ Expr *aggtarget,
+ Oid aggsortop);
extern void initialize_mergeclause_eclasses(PlannerInfo *root,
RestrictInfo *restrictinfo);
extern void update_mergeclause_eclasses(PlannerInfo *root,
@@ -187,10 +190,6 @@ extern List *select_outer_pathkeys_for_merge(PlannerInfo *root,
extern List *make_inner_pathkeys_for_merge(PlannerInfo *root,
List *mergeclauses,
List *outer_pathkeys);
-extern int pathkeys_useful_for_merging(PlannerInfo *root,
- RelOptInfo *rel,
- List *pathkeys);
-extern int pathkeys_useful_for_ordering(PlannerInfo *root, List *pathkeys);
extern List *truncate_useless_pathkeys(PlannerInfo *root,
RelOptInfo *rel,
List *pathkeys);
diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h
index 5bb0e094e5b..919449b4e38 100644
--- a/src/include/optimizer/planmain.h
+++ b/src/include/optimizer/planmain.h
@@ -32,6 +32,7 @@ extern void query_planner(PlannerInfo *root, List *tlist,
/*
* prototypes for plan/planagg.c
*/
+extern void preprocess_minmax_aggregates(PlannerInfo *root, List *tlist);
extern Plan *optimize_minmax_aggregates(PlannerInfo *root, List *tlist,
Path *best_path);
@@ -39,7 +40,6 @@ extern Plan *optimize_minmax_aggregates(PlannerInfo *root, List *tlist,
* prototypes for plan/createplan.c
*/
extern Plan *create_plan(PlannerInfo *root, Path *best_path);
-extern Node *fix_indexqual_operand(Node *node, IndexOptInfo *index);
extern SubqueryScan *make_subqueryscan(List *qptlist, List *qpqual,
Index scanrelid, Plan *subplan,
List *subrtable, List *subrowmark);