aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-01-25 17:09:45 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2019-01-25 17:09:45 -0500
commit18c0da88a5d9da566c3bfac444366b73bd0b57da (patch)
tree9ee280a42d3aa696c896eb3b82c7818578362ff6 /src/backend/nodes
parentff750ce2d82979e9588c629955e161a9379b05f3 (diff)
downloadpostgresql-18c0da88a5d9da566c3bfac444366b73bd0b57da.tar.gz
postgresql-18c0da88a5d9da566c3bfac444366b73bd0b57da.zip
Split QTW_EXAMINE_RTES flag into QTW_EXAMINE_RTES_BEFORE/_AFTER.
This change allows callers of query_tree_walker() to choose whether to visit an RTE before or after visiting the contents of the RTE (i.e., prefix or postfix tree order). All existing users of QTW_EXAMINE_RTES want the QTW_EXAMINE_RTES_BEFORE behavior, but an upcoming patch will want QTW_EXAMINE_RTES_AFTER, and it seems like a potentially useful change on its own. Andreas Karlsson (extracted from CTE inlining patch) Discussion: https://postgr.es/m/8810.1542402910@sss.pgh.pa.us
Diffstat (limited to 'src/backend/nodes')
-rw-r--r--src/backend/nodes/nodeFuncs.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c
index 19b65f681d1..a806d51edcd 100644
--- a/src/backend/nodes/nodeFuncs.c
+++ b/src/backend/nodes/nodeFuncs.c
@@ -2255,7 +2255,7 @@ expression_tree_walker(Node *node,
* Some callers want to suppress visitation of certain items in the sub-Query,
* typically because they need to process them specially, or don't actually
* want to recurse into subqueries. This is supported by the flags argument,
- * which is the bitwise OR of flag values to suppress visitation of
+ * which is the bitwise OR of flag values to add or suppress visitation of
* indicated items. (More flag bits may be added as needed.)
*/
bool
@@ -2314,8 +2314,12 @@ range_table_walker(List *rtable,
{
RangeTblEntry *rte = (RangeTblEntry *) lfirst(rt);
- /* For historical reasons, visiting RTEs is not the default */
- if (flags & QTW_EXAMINE_RTES)
+ /*
+ * Walkers might need to examine the RTE node itself either before or
+ * after visiting its contents (or, conceivably, both). Note that if
+ * you specify neither flag, the walker won't visit the RTE at all.
+ */
+ if (flags & QTW_EXAMINE_RTES_BEFORE)
if (walker(rte, context))
return true;
@@ -2355,6 +2359,10 @@ range_table_walker(List *rtable,
if (walker(rte->securityQuals, context))
return true;
+
+ if (flags & QTW_EXAMINE_RTES_AFTER)
+ if (walker(rte, context))
+ return true;
}
return false;
}