Skip to content

Commit b166a71

Browse files
author
Richard Guo
committed
Fix comments for ChangeVarNodes() and related functions
The comment for ChangeVarNodes() refers to a parameter named change_RangeTblRef, which does not exist in the code. The comment for ChangeVarNodesExtended() contains an extra space, while the comment for replace_relid_callback() has an awkward line break and a typo. This patch fixes these issues and revises some sentences for smoother wording. Oversights in commits ab42d64 and fc069a3. Author: Richard Guo <guofenglinux@gmail.com> Discussion: https://postgr.es/m/CAMbWs480j16HC1JtjKCgj5WshivT8ZJYkOfTyZAM0POjFomJkg@mail.gmail.com Backpatch-through: 18
1 parent 19e391e commit b166a71

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

src/backend/optimizer/plan/analyzejoins.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,14 +1687,14 @@ add_non_redundant_clauses(PlannerInfo *root,
16871687
}
16881688

16891689
/*
1690-
* A custom callback for ChangeVarNodesExtended() providing
1691-
* Self-join elimination (SJE) related functionality
1690+
* A custom callback for ChangeVarNodesExtended() providing Self-join
1691+
* elimination (SJE) related functionality
16921692
*
1693-
* SJE needs to skip the RangeTblRef node
1694-
* type. During SJE's last step, remove_rel_from_joinlist() removes
1695-
* remaining RangeTblRefs with target relid. If ChangeVarNodes() replaces
1696-
* the target relid before, remove_rel_from_joinlist() fails to identify
1697-
* the nodes to delete.
1693+
* SJE needs to skip the RangeTblRef node type. During SJE's last
1694+
* step, remove_rel_from_joinlist() removes remaining RangeTblRefs
1695+
* with target relid. If ChangeVarNodes() replaces the target relid
1696+
* before, remove_rel_from_joinlist() would fail to identify the nodes
1697+
* to delete.
16981698
*
16991699
* SJE also needs to change the relids within RestrictInfo's.
17001700
*/
@@ -1773,8 +1773,8 @@ replace_relid_callback(Node *node, ChangeVarNodes_context *context)
17731773
/*
17741774
* For self-join elimination, changing varnos could transform
17751775
* "t1.a = t2.a" into "t1.a = t1.a". That is always true as long
1776-
* as "t1.a" is not null. We use qual() to check for such a case,
1777-
* and then we replace the qual for a check for not null
1776+
* as "t1.a" is not null. We use equal() to check for such a
1777+
* case, and then we replace the qual with a check for not null
17781778
* (NullTest).
17791779
*/
17801780
if (leftOp != NULL && equal(leftOp, rightOp))

src/backend/rewrite/rewriteManip.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,6 @@ offset_relid_set(Relids relids, int offset)
542542
* (identified by sublevels_up and rt_index), and change their varno fields
543543
* to 'new_index'. The varnosyn fields are changed too. Also, adjust other
544544
* nodes that contain rangetable indexes, such as RangeTblRef and JoinExpr.
545-
* Specifying 'change_RangeTblRef' to false allows skipping RangeTblRef.
546-
* See ChangeVarNodesExtended for details.
547545
*
548546
* NOTE: although this has the form of a walker, we cheat and modify the
549547
* nodes in-place. The given expression tree should have been copied
@@ -664,17 +662,16 @@ ChangeVarNodes_walker(Node *node, ChangeVarNodes_context *context)
664662
}
665663

666664
/*
667-
* ChangeVarNodesExtended - similar to ChangeVarNodes, but with an additional
665+
* ChangeVarNodesExtended - similar to ChangeVarNodes, but with an additional
668666
* 'callback' param
669667
*
670-
* ChangeVarNodes changes a given node and all of its underlying nodes.
671-
* This version of function additionally takes a callback, which has a
672-
* chance to process a node before ChangeVarNodes_walker. A callback
673-
* returns a boolean value indicating if given node should be skipped from
674-
* further processing by ChangeVarNodes_walker. The callback is called
675-
* only for expressions and other children nodes of a Query processed by
676-
* a walker. Initial processing of the root Query doesn't involve the
677-
* callback.
668+
* ChangeVarNodes changes a given node and all of its underlying nodes. This
669+
* version of function additionally takes a callback, which has a chance to
670+
* process a node before ChangeVarNodes_walker. A callback returns a boolean
671+
* value indicating if the given node should be skipped from further processing
672+
* by ChangeVarNodes_walker. The callback is called only for expressions and
673+
* other children nodes of a Query processed by a walker. Initial processing
674+
* of the root Query doesn't involve the callback.
678675
*/
679676
void
680677
ChangeVarNodesExtended(Node *node, int rt_index, int new_index,

0 commit comments

Comments
 (0)