1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-08 11:42:09 +03:00

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
This commit is contained in:
Tom Lane
2023-03-02 12:01:47 -05:00
parent 00b41463c2
commit 6b661b01f4
9 changed files with 9 additions and 64 deletions

View File

@ -1247,16 +1247,11 @@ remove_nulling_relids_mutator(Node *node,
!bms_is_member(var->varno, context->except_relids) &&
bms_overlap(var->varnullingrels, context->removable_relids))
{
Relids newnullingrels = bms_difference(var->varnullingrels,
context->removable_relids);
/* Micro-optimization: ensure nullingrels is NULL if empty */
if (bms_is_empty(newnullingrels))
newnullingrels = NULL;
/* Copy the Var ... */
var = copyObject(var);
/* ... and replace the copy's varnullingrels field */
var->varnullingrels = newnullingrels;
var->varnullingrels = bms_difference(var->varnullingrels,
context->removable_relids);
return (Node *) var;
}
/* Otherwise fall through to copy the Var normally */
@ -1268,26 +1263,20 @@ remove_nulling_relids_mutator(Node *node,
if (phv->phlevelsup == context->sublevels_up &&
!bms_overlap(phv->phrels, context->except_relids))
{
Relids newnullingrels = bms_difference(phv->phnullingrels,
context->removable_relids);
/*
* Micro-optimization: ensure nullingrels is NULL if empty.
*
* Note: it might seem desirable to remove the PHV altogether if
* phnullingrels goes to empty. Currently we dare not do that
* because we use PHVs in some cases to enforce separate identity
* of subexpressions; see wrap_non_vars usages in prepjointree.c.
*/
if (bms_is_empty(newnullingrels))
newnullingrels = NULL;
/* Copy the PlaceHolderVar and mutate what's below ... */
phv = (PlaceHolderVar *)
expression_tree_mutator(node,
remove_nulling_relids_mutator,
(void *) context);
/* ... and replace the copy's phnullingrels field */
phv->phnullingrels = newnullingrels;
phv->phnullingrels = bms_difference(phv->phnullingrels,
context->removable_relids);
/* We must also update phrels, if it contains a removable RTI */
phv->phrels = bms_difference(phv->phrels,
context->removable_relids);