generic way of matching fields for Var/Const

moonshot/custom-path
Nils Dijk 2021-01-21 13:52:21 +01:00
parent 2b4072ebe8
commit 4362502bb5
No known key found for this signature in database
GPG Key ID: CA1177EF9434F241
2 changed files with 25 additions and 15 deletions

View File

@ -791,7 +791,7 @@ GeoOverlapJoin(PlannerInfo *root, Path *originalPath)
MatchVar(NoCapture),
MatchConst(
&match.stdwithinDistanceConst,
MatchConstType(FLOAT8OID))))),
MatchConstFields(consttype == FLOAT8OID))))),
/* match inner path in join */
SkipReadThrough(
NoCapture,

View File

@ -14,8 +14,8 @@
#define CONCATENATE1(arg1, arg2) CONCATENATE2(arg1, arg2)
#define CONCATENATE2(arg1, arg2) arg1##arg2
#define FOR_EACH_0(what, index) (void);
#define FOR_EACH_1(what, index, x) what((index), x);
#define FOR_EACH_0(what, index, x) ;
#define FOR_EACH_1(what, index, x) what((index), x); FOR_EACH_0(what, index+1, __VA_ARGS__);
#define FOR_EACH_2(what, index, x, ...) what((index), x); FOR_EACH_1(what, index+1, __VA_ARGS__);
#define FOR_EACH_3(what, index, x, ...) what((index), x); FOR_EACH_2(what, index+1, __VA_ARGS__);
#define FOR_EACH_4(what, index, x, ...) what((index), x); FOR_EACH_3(what, index+1, __VA_ARGS__);
@ -71,7 +71,6 @@
\
{ \
bool skipped = true; \
int skipCount = 0; \
while (skipped) { \
switch(pathToMatch->type) \
{ \
@ -87,12 +86,7 @@
break; \
} \
} \
if (skipped) \
{ \
skipCount++; \
} \
} \
ereport(DEBUG1, (errmsg("skipped %d read through nodes", skipCount))); \
} \
\
matcher; \
@ -102,7 +96,6 @@
#define MatchJoin(capture, joinType, conditionMatcher, innerMatcher, outerMatcher) \
{ \
ereport(DEBUG1, (errmsg("initiate join matcher"))); \
{ \
bool m = false; \
switch (pathToMatch->type) \
@ -196,11 +189,9 @@ do \
MakeStack(Path, pathToMatch, path); \
InitializeCapture; \
\
ereport(DEBUG1, (errmsg("initiate matcher DSL"))); \
matcher; \
\
VerifyStack(pathToMatch); \
ereport(DEBUG1, (errmsg("pattern matched"))); \
matched = true; \
break; \
} \
@ -310,6 +301,19 @@ if (matched)
}
#define MatchVarValuesInternal(index, check) \
{ \
if (!(castNode(Var, clause)->check)) \
{ \
MatchFailed; \
} \
}
#define MatchVarFields(...) \
FOR_EACH(MatchVarValuesInternal, __VA_ARGS__);
#define MatchVar(capture, ...) \
{ \
if (!IsA(clause, Var)) \
@ -321,13 +325,19 @@ if (matched)
}
#define MatchConstType(constType) \
if (!(castNode(Const, clause)->consttype == constType)) \
#define MatchConstValuesInternal(index, check) \
{ \
MatchFailed; \
if (!(castNode(Const, clause)->check)) \
{ \
MatchFailed; \
} \
}
#define MatchConstFields(...) \
FOR_EACH(MatchConstValuesInternal, __VA_ARGS__);
#define MatchConst(capture, ...) \
{ \
if (!IsA(clause, Const)) \