diff options
Diffstat (limited to 'src/backend/optimizer/plan')
-rw-r--r-- | src/backend/optimizer/plan/analyzejoins.c | 8 | ||||
-rw-r--r-- | src/backend/optimizer/plan/createplan.c | 36 | ||||
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 3 | ||||
-rw-r--r-- | src/backend/optimizer/plan/setrefs.c | 4 | ||||
-rw-r--r-- | src/backend/optimizer/plan/subselect.c | 17 |
5 files changed, 28 insertions, 40 deletions
diff --git a/src/backend/optimizer/plan/analyzejoins.c b/src/backend/optimizer/plan/analyzejoins.c index 438baf1e61f..ac63f7572b6 100644 --- a/src/backend/optimizer/plan/analyzejoins.c +++ b/src/backend/optimizer/plan/analyzejoins.c @@ -596,7 +596,7 @@ rel_is_distinct_for(PlannerInfo *root, RelOptInfo *rel, List *clause_list) */ foreach(l, clause_list) { - RestrictInfo *rinfo = (RestrictInfo *) lfirst(l); + RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(l)); Oid op; Var *var; @@ -608,8 +608,7 @@ rel_is_distinct_for(PlannerInfo *root, RelOptInfo *rel, List *clause_list) * caller's mergejoinability test should have selected only * OpExprs. */ - Assert(IsA(rinfo->clause, OpExpr)); - op = ((OpExpr *) rinfo->clause)->opno; + op = castNode(OpExpr, rinfo->clause)->opno; /* caller identified the inner side for us */ if (rinfo->outer_is_left) @@ -782,9 +781,8 @@ query_is_distinct_for(Query *query, List *colnos, List *opids) */ if (query->setOperations) { - SetOperationStmt *topop = (SetOperationStmt *) query->setOperations; + SetOperationStmt *topop = castNode(SetOperationStmt, query->setOperations); - Assert(IsA(topop, SetOperationStmt)); Assert(topop->op != SETOP_NONE); if (!topop->all) diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 997bdcff2ea..1e953b40d6f 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -508,8 +508,7 @@ create_scan_plan(PlannerInfo *root, Path *best_path, int flags) { case T_IndexScan: case T_IndexOnlyScan: - Assert(IsA(best_path, IndexPath)); - scan_clauses = ((IndexPath *) best_path)->indexinfo->indrestrictinfo; + scan_clauses = castNode(IndexPath, best_path)->indexinfo->indrestrictinfo; break; default: scan_clauses = rel->baserestrictinfo; @@ -2450,9 +2449,8 @@ create_indexscan_plan(PlannerInfo *root, qpqual = NIL; foreach(l, scan_clauses) { - RestrictInfo *rinfo = (RestrictInfo *) lfirst(l); + RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(l)); - Assert(IsA(rinfo, RestrictInfo)); if (rinfo->pseudoconstant) continue; /* we may drop pseudoconstants here */ if (list_member_ptr(indexquals, rinfo)) @@ -2608,10 +2606,9 @@ create_bitmap_scan_plan(PlannerInfo *root, qpqual = NIL; foreach(l, scan_clauses) { - RestrictInfo *rinfo = (RestrictInfo *) lfirst(l); + RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(l)); Node *clause = (Node *) rinfo->clause; - Assert(IsA(rinfo, RestrictInfo)); if (rinfo->pseudoconstant) continue; /* we may drop pseudoconstants here */ if (list_member(indexquals, clause)) @@ -2820,9 +2817,9 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual, ListCell *l; /* Use the regular indexscan plan build machinery... */ - iscan = (IndexScan *) create_indexscan_plan(root, ipath, - NIL, NIL, false); - Assert(IsA(iscan, IndexScan)); + iscan = castNode(IndexScan, + create_indexscan_plan(root, ipath, + NIL, NIL, false)); /* then convert to a bitmap indexscan */ plan = (Plan *) make_bitmap_indexscan(iscan->scan.scanrelid, iscan->indexid, @@ -3391,13 +3388,13 @@ create_customscan_plan(PlannerInfo *root, CustomPath *best_path, * Invoke custom plan provider to create the Plan node represented by the * CustomPath. */ - cplan = (CustomScan *) best_path->methods->PlanCustomPath(root, - rel, - best_path, - tlist, - scan_clauses, - custom_plans); - Assert(IsA(cplan, CustomScan)); + cplan = castNode(CustomScan, + best_path->methods->PlanCustomPath(root, + rel, + best_path, + tlist, + scan_clauses, + custom_plans)); /* * Copy cost data from Path to Plan; no need to make custom-plan providers @@ -3683,7 +3680,7 @@ create_mergejoin_plan(PlannerInfo *root, i = 0; foreach(lc, best_path->path_mergeclauses) { - RestrictInfo *rinfo = (RestrictInfo *) lfirst(lc); + RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(lc)); EquivalenceClass *oeclass; EquivalenceClass *ieclass; PathKey *opathkey; @@ -3693,7 +3690,6 @@ create_mergejoin_plan(PlannerInfo *root, ListCell *l2; /* fetch outer/inner eclass from mergeclause */ - Assert(IsA(rinfo, RestrictInfo)); if (rinfo->outer_is_left) { oeclass = rinfo->left_ec; @@ -4228,12 +4224,10 @@ fix_indexqual_references(PlannerInfo *root, IndexPath *index_path) forboth(lcc, index_path->indexquals, lci, index_path->indexqualcols) { - RestrictInfo *rinfo = (RestrictInfo *) lfirst(lcc); + RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(lcc)); int indexcol = lfirst_int(lci); Node *clause; - Assert(IsA(rinfo, RestrictInfo)); - /* * Replace any outer-relation variables with nestloop params. * diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 3d33d469713..ca0ae7883e7 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -3963,9 +3963,8 @@ create_one_window_path(PlannerInfo *root, window_target = copy_pathtarget(window_target); foreach(lc2, wflists->windowFuncs[wc->winref]) { - WindowFunc *wfunc = (WindowFunc *) lfirst(lc2); + WindowFunc *wfunc = castNode(WindowFunc, lfirst(lc2)); - Assert(IsA(wfunc, WindowFunc)); add_column_to_pathtarget(window_target, (Expr *) wfunc, 0); window_target->width += get_typavgwidth(wfunc->wintype, -1); } diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index be267b9da74..07ddbcf37e9 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -224,11 +224,9 @@ set_plan_references(PlannerInfo *root, Plan *plan) */ foreach(lc, root->rowMarks) { - PlanRowMark *rc = (PlanRowMark *) lfirst(lc); + PlanRowMark *rc = castNode(PlanRowMark, lfirst(lc)); PlanRowMark *newrc; - Assert(IsA(rc, PlanRowMark)); - /* flat copy is enough since all fields are scalars */ newrc = (PlanRowMark *) palloc(sizeof(PlanRowMark)); memcpy(newrc, rc, sizeof(PlanRowMark)); diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c index 7954c445dd9..3eb2bb749e4 100644 --- a/src/backend/optimizer/plan/subselect.c +++ b/src/backend/optimizer/plan/subselect.c @@ -433,9 +433,8 @@ get_first_col_type(Plan *plan, Oid *coltype, int32 *coltypmod, /* In cases such as EXISTS, tlist might be empty; arbitrarily use VOID */ if (plan->targetlist) { - TargetEntry *tent = (TargetEntry *) linitial(plan->targetlist); + TargetEntry *tent = castNode(TargetEntry, linitial(plan->targetlist)); - Assert(IsA(tent, TargetEntry)); if (!tent->resjunk) { *coltype = exprType((Node *) tent->expr); @@ -601,14 +600,14 @@ make_subplan(PlannerInfo *root, Query *orig_subquery, AlternativeSubPlan *asplan; /* OK, convert to SubPlan format. */ - hashplan = (SubPlan *) build_subplan(root, plan, subroot, - plan_params, - ANY_SUBLINK, 0, - newtestexpr, - false, true, - best_path->parallel_safe); + hashplan = castNode(SubPlan, + build_subplan(root, plan, subroot, + plan_params, + ANY_SUBLINK, 0, + newtestexpr, + false, true, + best_path->parallel_safe)); /* Check we got what we expected */ - Assert(IsA(hashplan, SubPlan)); Assert(hashplan->parParam == NIL); Assert(hashplan->useHashTable); /* build_subplan won't have filled in paramIds */ |