mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
Fix pushing of index-expression qualifications through UNION ALL.
In commit 57664ed25e
, I made the planner
wrap non-simple-variable outputs of appendrel children (IOW, child SELECTs
of UNION ALL subqueries) inside PlaceHolderVars, in order to solve some
issues with EquivalenceClass processing. However, this means that any
upper-level WHERE clauses mentioning such outputs will now contain
PlaceHolderVars after they're pushed down into the appendrel child,
and that prevents indxpath.c from recognizing that they could be matched
to index expressions. To fix, add explicit stripping of PlaceHolderVars
from index operands, same as we have long done for RelabelType nodes.
Add a regression test covering both this and the plain-UNION case (which
is a totally different code path, but should also be able to do it).
Per bug #6416 from Matteo Beccati. Back-patch to 9.1, same as the
previous change.
This commit is contained in:
@ -2673,8 +2673,11 @@ fix_indexqual_operand(Node *node, IndexOptInfo *index, int indexcol)
|
||||
ListCell *indexpr_item;
|
||||
|
||||
/*
|
||||
* Remove any binary-compatible relabeling of the indexkey
|
||||
* Remove any PlaceHolderVars or binary-compatible relabeling of the
|
||||
* indexkey (this must match logic in match_index_to_operand()).
|
||||
*/
|
||||
while (IsA(node, PlaceHolderVar))
|
||||
node = (Node *) ((PlaceHolderVar *) node)->phexpr;
|
||||
if (IsA(node, RelabelType))
|
||||
node = (Node *) ((RelabelType *) node)->arg;
|
||||
|
||||
|
Reference in New Issue
Block a user