Skip to content

Commit 11f6d4a

Browse files
committed
introduce convenience macro list_make1_irange_full()
1 parent d640ff1 commit 11f6d4a

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

src/hooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
337337
rte->inh = true;
338338

339339
children = PrelGetChildrenArray(prel);
340-
ranges = list_make1_irange(make_irange(0, PrelLastChild(prel), IR_COMPLETE));
340+
ranges = list_make1_irange_full(prel, IR_COMPLETE);
341341

342342
/* Make wrappers over restrictions and collect final rangeset */
343343
InitWalkerContext(&context, rti, prel, NULL, false);

src/include/rangeset.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ typedef struct {
5050
#define linitial_irange(list) ( lfirst_irange(list_head(list)) )
5151

5252

53+
/* convenience macro (requires relation_info.h) */
54+
#define list_make1_irange_full(prel, lossy) \
55+
( list_make1_irange(make_irange(0, PrelLastChild(prel), (lossy))) )
56+
57+
5358
inline static IndexRange
5459
make_irange(uint32 lower, uint32 upper, bool lossy)
5560
{
@@ -141,5 +146,4 @@ List *irange_list_intersection(List *a, List *b);
141146
int irange_list_length(List *rangeset);
142147
bool irange_list_find(List *rangeset, int index, bool *lossy);
143148

144-
145149
#endif /* PATHMAN_RANGESET_H */

src/nodes_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ rescan_append_common(CustomScanState *node)
656656
Assert(prel);
657657

658658
/* First we select all available partitions... */
659-
ranges = list_make1_irange(make_irange(0, PrelLastChild(prel), IR_COMPLETE));
659+
ranges = list_make1_irange_full(prel, IR_COMPLETE);
660660

661661
InitWalkerContext(&wcxt, INDEX_VAR, prel, econtext, false);
662662
foreach (lc, scan_state->custom_exprs)

src/pg_pathman.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,7 @@ walk_expr_tree(Expr *expr, WalkerContext *context)
622622
result->args = NIL;
623623
result->paramsel = 1.0;
624624

625-
result->rangeset = list_make1_irange(
626-
make_irange(0, PrelLastChild(context->prel), IR_LOSSY));
625+
result->rangeset = list_make1_irange_full(context->prel, IR_LOSSY);
627626

628627
return result;
629628
}
@@ -804,9 +803,7 @@ handle_boolexpr(const BoolExpr *expr, WalkerContext *context)
804803
result->paramsel = 1.0;
805804

806805
if (expr->boolop == AND_EXPR)
807-
result->rangeset = list_make1_irange(make_irange(0,
808-
PrelLastChild(prel),
809-
IR_COMPLETE));
806+
result->rangeset = list_make1_irange_full(prel, IR_COMPLETE);
810807
else
811808
result->rangeset = NIL;
812809

@@ -831,9 +828,7 @@ handle_boolexpr(const BoolExpr *expr, WalkerContext *context)
831828
break;
832829

833830
default:
834-
result->rangeset = list_make1_irange(make_irange(0,
835-
PrelLastChild(prel),
836-
IR_LOSSY));
831+
result->rangeset = list_make1_irange_full(prel, IR_LOSSY);
837832
break;
838833
}
839834
}
@@ -1003,7 +998,7 @@ handle_arrexpr(const ScalarArrayOpExpr *expr, WalkerContext *context)
1003998
result->paramsel = DEFAULT_INEQ_SEL;
1004999

10051000
handle_arrexpr_return:
1006-
result->rangeset = list_make1_irange(make_irange(0, PrelLastChild(prel), IR_LOSSY));
1001+
result->rangeset = list_make1_irange_full(prel, IR_LOSSY);
10071002
result->paramsel = 1.0;
10081003
return result;
10091004
}
@@ -1036,7 +1031,7 @@ handle_opexpr(const OpExpr *expr, WalkerContext *context)
10361031
}
10371032
}
10381033

1039-
result->rangeset = list_make1_irange(make_irange(0, PrelLastChild(prel), IR_LOSSY));
1034+
result->rangeset = list_make1_irange_full(prel, IR_LOSSY);
10401035
result->paramsel = 1.0;
10411036
return result;
10421037
}
@@ -1131,7 +1126,7 @@ handle_binary_opexpr(WalkerContext *context, WrapperNode *result,
11311126
}
11321127

11331128
binary_opexpr_return:
1134-
result->rangeset = list_make1_irange(make_irange(0, PrelLastChild(prel), IR_LOSSY));
1129+
result->rangeset = list_make1_irange_full(prel, IR_LOSSY);
11351130
result->paramsel = 1.0;
11361131
}
11371132

@@ -1155,7 +1150,7 @@ handle_binary_opexpr_param(const PartRelationInfo *prel,
11551150
tce = lookup_type_cache(vartype, TYPECACHE_BTREE_OPFAMILY);
11561151
strategy = get_op_opfamily_strategy(expr->opno, tce->btree_opf);
11571152

1158-
result->rangeset = list_make1_irange(make_irange(0, PrelLastChild(prel), IR_LOSSY));
1153+
result->rangeset = list_make1_irange_full(prel, IR_LOSSY);
11591154
result->paramsel = estimate_paramsel_using_prel(prel, strategy);
11601155
}
11611156

src/planner_tree_modification.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ handle_modification_query(Query *parse)
268268
if (prel->enable_parent) return;
269269

270270
/* Parse syntax tree and extract partition ranges */
271-
ranges = list_make1_irange(make_irange(0, PrelLastChild(prel), false));
271+
ranges = list_make1_irange_full(prel, IR_COMPLETE);
272272
expr = (Expr *) eval_const_expressions(NULL, parse->jointree->quals);
273273

274274
/* Exit if there's no expr (no use) */

0 commit comments

Comments
 (0)