mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
Refactor pull_var_clause's API to make it less tedious to extend.
In commit1d97c19a0f
and laterc1d9579dd8
, we extended pull_var_clause's API by adding enum-type arguments. That's sort of a pain to maintain, though, because it means every time we add a new behavior we must touch every last one of the call sites, even if there's a reasonable default behavior that most of them could use. Let's switch over to using a bitmask of flags, instead; that seems more maintainable and might save a nanosecond or two as well. This commit changes no behavior in itself, though I'm going to follow it up with one that does add a new behavior. In passing, remove flatten_tlist(), which has not been used since 9.1 and would otherwise need the same API changes. Removing these enums means that optimizer/tlist.h no longer needs to depend on optimizer/var.h. Changing that caused a number of C files to need addition of #include "optimizer/var.h" (probably we can thank old runs of pgrminclude for that); but on balance it seems like a good change anyway.
This commit is contained in:
@ -1641,12 +1641,12 @@ set_join_references(PlannerInfo *root, Join *join, int rtoffset)
|
||||
*
|
||||
* In most cases, we have to match up individual Vars in the tlist and
|
||||
* qual expressions with elements of the subplan's tlist (which was
|
||||
* generated by flatten_tlist() from these selfsame expressions, so it
|
||||
* should have all the required variables). There is an important exception,
|
||||
* however: GROUP BY and ORDER BY expressions will have been pushed into the
|
||||
* subplan tlist unflattened. If these values are also needed in the output
|
||||
* then we want to reference the subplan tlist element rather than recomputing
|
||||
* the expression.
|
||||
* generated by flattening these selfsame expressions, so it should have all
|
||||
* the required variables). There is an important exception, however:
|
||||
* depending on where we are in the plan tree, sort/group columns may have
|
||||
* been pushed into the subplan tlist unflattened. If these values are also
|
||||
* needed in the output then we want to reference the subplan tlist element
|
||||
* rather than recomputing the expression.
|
||||
*/
|
||||
static void
|
||||
set_upper_references(PlannerInfo *root, Plan *plan, int rtoffset)
|
||||
@ -2129,7 +2129,8 @@ fix_join_expr_mutator(Node *node, fix_join_expr_context *context)
|
||||
*
|
||||
* An error is raised if no matching var can be found in the subplan tlist
|
||||
* --- so this routine should only be applied to nodes whose subplans'
|
||||
* targetlists were generated via flatten_tlist() or some such method.
|
||||
* targetlists were generated by flattening the expressions used in the
|
||||
* parent node.
|
||||
*
|
||||
* If itlist->has_non_vars is true, then we try to match whole subexpressions
|
||||
* against elements of the subplan tlist, so that we can avoid recomputing
|
||||
|
Reference in New Issue
Block a user