Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6b661b0

Browse files
committed
Remove local optimizations of empty Bitmapsets into null pointers.
These are all dead code now that it's done centrally.Patch by me; thanks to Nathan Bossart and Richard Guo for review.Discussion:https://postgr.es/m/1159933.1677621588@sss.pgh.pa.us
1 parent00b4146 commit6b661b0

File tree

9 files changed

+9
-64
lines changed

9 files changed

+9
-64
lines changed

‎src/backend/executor/execUtils.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -877,15 +877,7 @@ UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)
877877
* include anything else into its chgParam set.
878878
*/
879879
parmset=bms_intersect(node->plan->allParam,newchg);
880-
881-
/*
882-
* Keep node->chgParam == NULL if there's not actually any members; this
883-
* allows the simplest possible tests in executor node files.
884-
*/
885-
if (!bms_is_empty(parmset))
886-
node->chgParam=bms_join(node->chgParam,parmset);
887-
else
888-
bms_free(parmset);
880+
node->chgParam=bms_join(node->chgParam,parmset);
889881
}
890882

891883
/*

‎src/backend/optimizer/path/indxpath.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -949,9 +949,6 @@ build_index_paths(PlannerInfo *root, RelOptInfo *rel,
949949

950950
/* We do not want the index's rel itself listed in outer_relids */
951951
outer_relids=bms_del_member(outer_relids,rel->relid);
952-
/* Enforce convention that outer_relids is exactly NULL if empty */
953-
if (bms_is_empty(outer_relids))
954-
outer_relids=NULL;
955952

956953
/* Compute loop_count for cost estimation purposes */
957954
loop_count=get_loop_count(root,rel->relid,outer_relids);

‎src/backend/optimizer/plan/initsplan.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -679,16 +679,10 @@ create_lateral_join_info(PlannerInfo *root)
679679

680680
/* Nothing to do at rels with no lateral refs */
681681
lateral_relids=brel->lateral_relids;
682-
if (lateral_relids==NULL)
682+
if (bms_is_empty(lateral_relids))
683683
continue;
684684

685-
/*
686-
* We should not have broken the invariant that lateral_relids is
687-
* exactly NULL if empty.
688-
*/
689-
Assert(!bms_is_empty(lateral_relids));
690-
691-
/* Also, no rel should have a lateral dependency on itself */
685+
/* No rel should have a lateral dependency on itself */
692686
Assert(!bms_is_member(rti,lateral_relids));
693687

694688
/* Mark this rel's referencees */

‎src/backend/optimizer/plan/subselect.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2825,15 +2825,6 @@ finalize_plan(PlannerInfo *root, Plan *plan,
28252825
/* but not any initplan setParams */
28262826
plan->extParam=bms_del_members(plan->extParam,initSetParam);
28272827

2828-
/*
2829-
* For speed at execution time, make sure extParam/allParam are actually
2830-
* NULL if they are empty sets.
2831-
*/
2832-
if (bms_is_empty(plan->extParam))
2833-
plan->extParam=NULL;
2834-
if (bms_is_empty(plan->allParam))
2835-
plan->allParam=NULL;
2836-
28372828
returnplan->allParam;
28382829
}
28392830

‎src/backend/optimizer/util/pathnode.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,12 +2372,6 @@ calc_nestloop_required_outer(Relids outerrelids,
23722372
/* ... and remove any mention of now-satisfied outer rels */
23732373
required_outer=bms_del_members(required_outer,
23742374
outerrelids);
2375-
/* maintain invariant that required_outer is exactly NULL if empty */
2376-
if (bms_is_empty(required_outer))
2377-
{
2378-
bms_free(required_outer);
2379-
required_outer=NULL;
2380-
}
23812375
returnrequired_outer;
23822376
}
23832377

‎src/backend/optimizer/util/placeholder.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ find_placeholder_info(PlannerInfo *root, PlaceHolderVar *phv)
125125
*/
126126
rels_used=pull_varnos(root, (Node*)phv->phexpr);
127127
phinfo->ph_lateral=bms_difference(rels_used,phv->phrels);
128-
if (bms_is_empty(phinfo->ph_lateral))
129-
phinfo->ph_lateral=NULL;/* make it exactly NULL if empty */
130128
phinfo->ph_eval_at=bms_int_members(rels_used,phv->phrels);
131129
/* If no contained vars, force evaluation at syntactic location */
132130
if (bms_is_empty(phinfo->ph_eval_at))

‎src/backend/optimizer/util/relnode.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,6 @@ build_join_rel(PlannerInfo *root,
772772
*/
773773
joinrel->direct_lateral_relids=
774774
bms_del_members(joinrel->direct_lateral_relids,joinrel->relids);
775-
if (bms_is_empty(joinrel->direct_lateral_relids))
776-
joinrel->direct_lateral_relids=NULL;
777775

778776
/*
779777
* Construct restrict and join clause lists for the new joinrel. (The
@@ -1024,11 +1022,6 @@ min_join_parameterization(PlannerInfo *root,
10241022
*/
10251023
result=bms_union(outer_rel->lateral_relids,inner_rel->lateral_relids);
10261024
result=bms_del_members(result,joinrelids);
1027-
1028-
/* Maintain invariant that result is exactly NULL if empty */
1029-
if (bms_is_empty(result))
1030-
result=NULL;
1031-
10321025
returnresult;
10331026
}
10341027

‎src/backend/rewrite/rewriteManip.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,16 +1247,11 @@ remove_nulling_relids_mutator(Node *node,
12471247
!bms_is_member(var->varno,context->except_relids)&&
12481248
bms_overlap(var->varnullingrels,context->removable_relids))
12491249
{
1250-
Relidsnewnullingrels=bms_difference(var->varnullingrels,
1251-
context->removable_relids);
1252-
1253-
/* Micro-optimization: ensure nullingrels is NULL if empty */
1254-
if (bms_is_empty(newnullingrels))
1255-
newnullingrels=NULL;
12561250
/* Copy the Var ... */
12571251
var=copyObject(var);
12581252
/* ... and replace the copy's varnullingrels field */
1259-
var->varnullingrels=newnullingrels;
1253+
var->varnullingrels=bms_difference(var->varnullingrels,
1254+
context->removable_relids);
12601255
return (Node*)var;
12611256
}
12621257
/* Otherwise fall through to copy the Var normally */
@@ -1268,26 +1263,20 @@ remove_nulling_relids_mutator(Node *node,
12681263
if (phv->phlevelsup==context->sublevels_up&&
12691264
!bms_overlap(phv->phrels,context->except_relids))
12701265
{
1271-
Relidsnewnullingrels=bms_difference(phv->phnullingrels,
1272-
context->removable_relids);
1273-
12741266
/*
1275-
* Micro-optimization: ensure nullingrels is NULL if empty.
1276-
*
12771267
* Note: it might seem desirable to remove the PHV altogether if
12781268
* phnullingrels goes to empty. Currently we dare not do that
12791269
* because we use PHVs in some cases to enforce separate identity
12801270
* of subexpressions; see wrap_non_vars usages in prepjointree.c.
12811271
*/
1282-
if (bms_is_empty(newnullingrels))
1283-
newnullingrels=NULL;
12841272
/* Copy the PlaceHolderVar and mutate what's below ... */
12851273
phv= (PlaceHolderVar*)
12861274
expression_tree_mutator(node,
12871275
remove_nulling_relids_mutator,
12881276
(void*)context);
12891277
/* ... and replace the copy's phnullingrels field */
1290-
phv->phnullingrels=newnullingrels;
1278+
phv->phnullingrels=bms_difference(phv->phnullingrels,
1279+
context->removable_relids);
12911280
/* We must also update phrels, if it contains a removable RTI */
12921281
phv->phrels=bms_difference(phv->phrels,
12931282
context->removable_relids);

‎src/pl/plpgsql/src/pl_exec.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6240,12 +6240,9 @@ setup_param_list(PLpgSQL_execstate *estate, PLpgSQL_expr *expr)
62406240
Assert(expr->plan!=NULL);
62416241

62426242
/*
6243-
* We only need a ParamListInfo if the expression has parameters. In
6244-
* principle we should test with bms_is_empty(), but we use a not-null
6245-
* test because it's faster. In current usage bits are never removed from
6246-
* expr->paramnos, only added, so this test is correct anyway.
6243+
* We only need a ParamListInfo if the expression has parameters.
62476244
*/
6248-
if (expr->paramnos)
6245+
if (!bms_is_empty(expr->paramnos))
62496246
{
62506247
/* Use the common ParamListInfo */
62516248
paramLI=estate->paramLI;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp