@@ -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- Relids newnullingrels = 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- Relids newnullingrels = 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 );
0 commit comments