-
Notifications
You must be signed in to change notification settings - Fork 5
/
pgspider_ext.h
81 lines (72 loc) · 2.47 KB
/
pgspider_ext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*-------------------------------------------------------------------------
*
* pgspider_ext.c
* contrib/pgspider_ext/pgspider_ext.h
*
* Portions Copyright (c) 2020, TOSHIBA CORPORATION
*
*-------------------------------------------------------------------------
*/
#ifndef SPD_FDW_H
#define SPD_FDW_H
#include "nodes/pathnodes.h"
#include "nodes/pg_list.h"
#define CODE_VERSION 10300
/*
* Options structure to store information.
*/
typedef struct SpdOpt
{
char *child_name;
} SpdOpt;
/*
* Argument used for extract_var_walker.
*/
typedef struct PartkeyWalkerContext
{
AttrNumber partkey_attno;
List *exprs;
} PartkeyWalkerContext;
typedef enum
{
AGG_SPLIT_WALK_CHANGE,
AGG_SPLIT_WALK_REVERT,
} AggSplitWalkMode;
/*
* Argument used for foreign_expr_walker_aggsplit_change.
*/
typedef struct AggSplitChangeWalkerContext
{
AggSplitWalkMode walk_mode;
HTAB *history;
AggSplit new_aggsplit;
} AggSplitChangeWalkerContext;
typedef struct AggShippabilityContext
{
bool shippable; /* this flag determine that the expression can
* be shipped or not */
bool hasAggref; /* this flag marks that we are checking the
* Aggref. It will be used to detect if
* partition key is inside Aggref function */
AttrNumber partkey_attno; /* column number of partition key */
} AggShippabilityContext;
/* In pgspider_ext_option.c */
extern SpdOpt * spd_get_options(Oid userid, Oid foreignoid);
/* In pgspider_ext_deparse.c */
extern HTAB *aggsplit_history_create(void);
extern bool foreign_expr_walker_aggsplit_change(Node *node, AggSplitChangeWalkerContext * context);
extern bool foreign_expr_walker_agg_shippability(Node *node, AggShippabilityContext * ctx);
extern void createVarAttrnoMapping(Oid parent_tableid, Oid child_tableid,
AttrNumber partkey_attno,
AttrNumber **attrno_to_child,
AttrNumber **attrno_to_parent);
extern Node *mapVarAttnos(Node *node, AttrNumber *attrno_shift);
extern List *mapVarAttnosInList(List *exprs, AttrNumber *attrno_shift);
extern List *removePartkeyFromTargets(List *exprs, AttrNumber partkey_attno,
List **partkey_idxes);
extern bool var_is_partkey(Var *var, AttrNumber partkey_attno);
extern bool hasPartKeyExpr(Node *node, AttrNumber partkey_attno);
extern bool extract_var_walker(Node *node, PartkeyWalkerContext * context);
extern Expr *exprlist_member(Expr *node, List *exprs);
extern Expr *getExprInPathKey(PathKey *pathkey, RelOptInfo *baserel);
#endif /* SPD_FDW_H */