-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery.h
97 lines (84 loc) · 2.32 KB
/
query.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*-------------------------------------------------------------------------
*
* query.h
*
* Ulities for parsing out qualifications from the query.
*
* Copyright (c) 2015 Golden Helix, Inc.
*
* Heavily based on the excellent Multicorn libary by Kozea (see LICENSE_Kozea)
*
* https://github.com/Kozea/Multicorn/
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "nodes/pg_list.h"
#include "catalog/pg_foreign_server.h"
#include "catalog/pg_foreign_table.h"
#include "commands/defrem.h"
#include "foreign/fdwapi.h"
#include "foreign/foreign.h"
#include "funcapi.h"
#include "lib/stringinfo.h"
#include "nodes/relation.h"
#include "utils/builtins.h"
#include "catalog/pg_type.h"
#include "utils/syscache.h"
#include "access/relscan.h"
#include "nodes/makefuncs.h"
#include "nodes/bitmapset.h"
#ifndef PG_QUERY_H
#define PG_QUERY_H
/* Data structures */
typedef struct ConversionInfo {
char *attrname;
FmgrInfo *attinfunc;
FmgrInfo *attoutfunc;
Oid atttypoid;
Oid attioparam;
int32 atttypmod;
int attnum;
bool is_array;
int attndims;
bool need_quote;
} ConversionInfo;
typedef struct MulticornPlanState {
Oid foreigntableid;
AttrNumber numattrs;
List *target_list;
List *qual_list;
int startupCost;
ConversionInfo **cinfos;
} MulticornPlanState;
typedef struct MulticornBaseQual {
AttrNumber varattno;
NodeTag right_type;
Oid typeoid;
char *opname;
bool isArray;
bool useOr; // ANY on array operators
bool includeMissing;
bool inverted;
} MulticornBaseQual;
typedef struct MulticornConstQual {
MulticornBaseQual base;
Datum value;
bool isnull;
} MulticornConstQual;
typedef struct MulticornVarQual {
MulticornBaseQual base;
AttrNumber rightvarattno;
} MulticornVarQual;
typedef struct MulticornParamQual {
MulticornBaseQual base;
Expr *expr;
} MulticornParamQual;
/* query.c */
void extractRestrictions(Oid foreignTableId, Relids base_relids, Expr *node, List **quals);
void collapseNullQuals(List **quals);
List *extractColumns(List *reltargetlist, List *restrictinfolist);
void initConversioninfo(ConversionInfo **cinfo, AttInMetadata *attinmeta);
Value *colnameFromVar(Var *var, PlannerInfo *root, MulticornPlanState *state);
void findPaths(PlannerInfo *root, RelOptInfo *baserel, List *possiblePaths, int startupCost);
#endif