@@ -243,7 +243,7 @@ is_foreign_expr(PlannerInfo *root,
243243 * because the upperrel's own relids currently aren't set to anything
244244 * meaningful by the core code. For other relation, use their own relids.
245245 */
246- if (baserel -> reloptkind == RELOPT_UPPER_REL )
246+ if (IS_UPPER_REL ( baserel ) )
247247glob_cxt .relids = fpinfo -> outerrel -> relids ;
248248else
249249glob_cxt .relids = baserel -> relids ;
@@ -677,7 +677,7 @@ foreign_expr_walker(Node *node,
677677ListCell * lc ;
678678
679679/* Not safe to pushdown when not in grouping context */
680- if (glob_cxt -> foreignrel -> reloptkind != RELOPT_UPPER_REL )
680+ if (! IS_UPPER_REL ( glob_cxt -> foreignrel ) )
681681return false;
682682
683683/* Only non-split aggregates are pushable. */
@@ -874,7 +874,7 @@ build_tlist_to_deparse(RelOptInfo *foreignrel)
874874 * For an upper relation, we have already built the target list while
875875 * checking shippability, so just return that.
876876 */
877- if (foreignrel -> reloptkind == RELOPT_UPPER_REL )
877+ if (IS_UPPER_REL ( foreignrel ) )
878878return fpinfo -> grouped_tlist ;
879879
880880/*
@@ -929,17 +929,13 @@ deparseSelectStmtForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *rel,
929929 * We handle relations for foreign tables, joins between those and upper
930930 * relations.
931931 */
932- Assert (rel -> reloptkind == RELOPT_JOINREL ||
933- rel -> reloptkind == RELOPT_BASEREL ||
934- rel -> reloptkind == RELOPT_OTHER_MEMBER_REL ||
935- rel -> reloptkind == RELOPT_UPPER_REL );
932+ Assert (IS_JOIN_REL (rel )|| IS_SIMPLE_REL (rel )|| IS_UPPER_REL (rel ));
936933
937934/* Fill portions of context common to upper, join and base relation */
938935context .buf = buf ;
939936context .root = root ;
940937context .foreignrel = rel ;
941- context .scanrel = (rel -> reloptkind == RELOPT_UPPER_REL ) ?
942- fpinfo -> outerrel :rel ;
938+ context .scanrel = IS_UPPER_REL (rel ) ?fpinfo -> outerrel :rel ;
943939context .params_list = params_list ;
944940
945941/* Construct SELECT clause */
@@ -950,7 +946,7 @@ deparseSelectStmtForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *rel,
950946 * conditions of the underlying scan relation; otherwise, we can use the
951947 * supplied list of remote conditions directly.
952948 */
953- if (rel -> reloptkind == RELOPT_UPPER_REL )
949+ if (IS_UPPER_REL ( rel ) )
954950{
955951PgFdwRelationInfo * ofpinfo ;
956952
@@ -963,7 +959,7 @@ deparseSelectStmtForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *rel,
963959/* Construct FROM and WHERE clauses */
964960deparseFromExpr (quals ,& context );
965961
966- if (rel -> reloptkind == RELOPT_UPPER_REL )
962+ if (IS_UPPER_REL ( rel ) )
967963{
968964/* Append GROUP BY clause */
969965appendGroupByClause (tlist ,& context );
@@ -1020,8 +1016,7 @@ deparseSelectSql(List *tlist, bool is_subquery, List **retrieved_attrs,
10201016 */
10211017deparseSubqueryTargetList (context );
10221018}
1023- else if (foreignrel -> reloptkind == RELOPT_JOINREL ||
1024- foreignrel -> reloptkind == RELOPT_UPPER_REL )
1019+ else if (IS_JOIN_REL (foreignrel )|| IS_UPPER_REL (foreignrel ))
10251020{
10261021/*
10271022 * For a join or upper relation the input tlist gives the list of
@@ -1062,9 +1057,8 @@ deparseFromExpr(List *quals, deparse_expr_cxt *context)
10621057RelOptInfo * scanrel = context -> scanrel ;
10631058
10641059/* For upper relations, scanrel must be either a joinrel or a baserel */
1065- Assert (context -> foreignrel -> reloptkind != RELOPT_UPPER_REL ||
1066- scanrel -> reloptkind == RELOPT_JOINREL ||
1067- scanrel -> reloptkind == RELOPT_BASEREL );
1060+ Assert (!IS_UPPER_REL (context -> foreignrel )||
1061+ IS_JOIN_REL (scanrel )|| IS_SIMPLE_REL (scanrel ));
10681062
10691063/* Construct FROM clause */
10701064appendStringInfoString (buf ," FROM " );
@@ -1219,7 +1213,7 @@ deparseLockingClause(deparse_expr_cxt *context)
12191213appendStringInfoString (buf ," FOR UPDATE" );
12201214
12211215/* Add the relation alias if we are here for a join relation */
1222- if (rel -> reloptkind == RELOPT_JOINREL )
1216+ if (IS_JOIN_REL ( rel ) )
12231217appendStringInfo (buf ," OF %s%d" ,REL_ALIAS_PREFIX ,relid );
12241218}
12251219else
@@ -1384,8 +1378,7 @@ deparseSubqueryTargetList(deparse_expr_cxt *context)
13841378ListCell * lc ;
13851379
13861380/* Should only be called in these cases. */
1387- Assert (foreignrel -> reloptkind == RELOPT_BASEREL ||
1388- foreignrel -> reloptkind == RELOPT_JOINREL );
1381+ Assert (IS_SIMPLE_REL (foreignrel )|| IS_JOIN_REL (foreignrel ));
13891382
13901383first = true;
13911384foreach (lc ,foreignrel -> reltarget -> exprs )
@@ -1417,7 +1410,7 @@ deparseFromExprForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel,
14171410{
14181411PgFdwRelationInfo * fpinfo = (PgFdwRelationInfo * )foreignrel -> fdw_private ;
14191412
1420- if (foreignrel -> reloptkind == RELOPT_JOINREL )
1413+ if (IS_JOIN_REL ( foreignrel ) )
14211414{
14221415StringInfoData join_sql_o ;
14231416StringInfoData join_sql_i ;
@@ -1495,8 +1488,7 @@ deparseRangeTblRef(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel,
14951488PgFdwRelationInfo * fpinfo = (PgFdwRelationInfo * )foreignrel -> fdw_private ;
14961489
14971490/* Should only be called in these cases. */
1498- Assert (foreignrel -> reloptkind == RELOPT_BASEREL ||
1499- foreignrel -> reloptkind == RELOPT_JOINREL );
1491+ Assert (IS_SIMPLE_REL (foreignrel )|| IS_JOIN_REL (foreignrel ));
15001492
15011493Assert (fpinfo -> local_conds == NIL );
15021494
@@ -3097,15 +3089,13 @@ is_subquery_var(Var *node, RelOptInfo *foreignrel, int *relno, int *colno)
30973089RelOptInfo * innerrel = fpinfo -> innerrel ;
30983090
30993091/* Should only be called in these cases. */
3100- Assert (foreignrel -> reloptkind == RELOPT_BASEREL ||
3101- foreignrel -> reloptkind == RELOPT_JOINREL ||
3102- foreignrel -> reloptkind == RELOPT_OTHER_MEMBER_REL );
3092+ Assert (IS_SIMPLE_REL (foreignrel )|| IS_JOIN_REL (foreignrel ));
31033093
31043094/*
31053095 * If the given relation isn't a join relation, it doesn't have any lower
31063096 * subqueries, so the Var isn't a subquery output column.
31073097 */
3108- if (foreignrel -> reloptkind != RELOPT_JOINREL )
3098+ if (! IS_JOIN_REL ( foreignrel ) )
31093099return false;
31103100
31113101/*