mirror of
https://github.com/postgres/postgres.git
synced 2025-11-18 02:02:55 +03:00
Refactor pull_var_clause's API to make it less tedious to extend.
In commit1d97c19a0fand laterc1d9579dd8, 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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user