summaryrefslogtreecommitdiff
path: root/src/include/optimizer
diff options
context:
space:
mode:
authorTom Lane2016-03-10 20:52:58 +0000
committerTom Lane2016-03-10 20:53:07 +0000
commit364a9f47ab363250f62dd2c381c4da435283725a (patch)
tree47e0cd694ab7d5e4ea61ae8b2a5fda55b2a97a73 /src/include/optimizer
parent37c54863cf71a4a1126d21db8eb68974bef34374 (diff)
Refactor pull_var_clause's API to make it less tedious to extend.
In commit 1d97c19a0f748e94 and later c1d9579dd8bf3c92, we extended pull_var_clause's API by adding enum-type arguments. That's sort of a pain to maintain, though, because it means every time we add a new behavior we must touch every last one of the call sites, even if there's a reasonable default behavior that most of them could use. Let's switch over to using a bitmask of flags, instead; that seems more maintainable and might save a nanosecond or two as well. This commit changes no behavior in itself, though I'm going to follow it up with one that does add a new behavior. In passing, remove flatten_tlist(), which has not been used since 9.1 and would otherwise need the same API changes. Removing these enums means that optimizer/tlist.h no longer needs to depend on optimizer/var.h. Changing that caused a number of C files to need addition of #include "optimizer/var.h" (probably we can thank old runs of pgrminclude for that); but on balance it seems like a good change anyway.
Diffstat (limited to 'src/include/optimizer')
-rw-r--r--src/include/optimizer/tlist.h4
-rw-r--r--src/include/optimizer/var.h22
2 files changed, 9 insertions, 17 deletions
diff --git a/src/include/optimizer/tlist.h b/src/include/optimizer/tlist.h
index a60e10278c..2c79a80391 100644
--- a/src/include/optimizer/tlist.h
+++ b/src/include/optimizer/tlist.h
@@ -14,14 +14,12 @@
#ifndef TLIST_H
#define TLIST_H
-#include "optimizer/var.h"
+#include "nodes/relation.h"
extern TargetEntry *tlist_member(Node *node, List *targetlist);
extern TargetEntry *tlist_member_ignore_relabel(Node *node, List *targetlist);
-extern List *flatten_tlist(List *tlist, PVCAggregateBehavior aggbehavior,
- PVCPlaceHolderBehavior phbehavior);
extern List *add_to_flat_tlist(List *tlist, List *exprs);
extern List *get_tlist_exprs(List *tlist, bool includeJunk);
diff --git a/src/include/optimizer/var.h b/src/include/optimizer/var.h
index aded1fe4df..d1b0978b97 100644
--- a/src/include/optimizer/var.h
+++ b/src/include/optimizer/var.h
@@ -16,19 +16,14 @@
#include "nodes/relation.h"
-typedef enum
-{
- PVC_REJECT_AGGREGATES, /* throw error if Aggref found */
- PVC_INCLUDE_AGGREGATES, /* include Aggrefs in output list */
- PVC_RECURSE_AGGREGATES /* recurse into Aggref arguments */
-} PVCAggregateBehavior;
+/* Bits that can be OR'd into the flags argument of pull_var_clause() */
+#define PVC_INCLUDE_AGGREGATES 0x0001 /* include Aggrefs in output list */
+#define PVC_RECURSE_AGGREGATES 0x0002 /* recurse into Aggref arguments */
+#define PVC_INCLUDE_PLACEHOLDERS 0x0004 /* include PlaceHolderVars in
+ * output list */
+#define PVC_RECURSE_PLACEHOLDERS 0x0008 /* recurse into PlaceHolderVar
+ * arguments */
-typedef enum
-{
- PVC_REJECT_PLACEHOLDERS, /* throw error if PlaceHolderVar found */
- PVC_INCLUDE_PLACEHOLDERS, /* include PlaceHolderVars in output list */
- PVC_RECURSE_PLACEHOLDERS /* recurse into PlaceHolderVar arguments */
-} PVCPlaceHolderBehavior;
extern Relids pull_varnos(Node *node);
extern Relids pull_varnos_of_level(Node *node, int levelsup);
@@ -37,8 +32,7 @@ extern List *pull_vars_of_level(Node *node, int levelsup);
extern bool contain_var_clause(Node *node);
extern bool contain_vars_of_level(Node *node, int levelsup);
extern int locate_var_of_level(Node *node, int levelsup);
-extern List *pull_var_clause(Node *node, PVCAggregateBehavior aggbehavior,
- PVCPlaceHolderBehavior phbehavior);
+extern List *pull_var_clause(Node *node, int flags);
extern Node *flatten_join_alias_vars(PlannerInfo *root, Node *node);
#endif /* VAR_H */