mirror of
https://github.com/postgres/postgres.git
synced 2025-06-08 22:02:03 +03:00
Fix inappropriate attempt to push down qual clauses into a view that
has UNION/INTERSECT/EXCEPT operations. Per bug report from Ferrier.
This commit is contained in:
parent
67849c84d6
commit
503f042cd7
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.70 2001/01/24 19:42:57 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.71 2001/02/03 21:17:52 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -101,8 +101,6 @@ set_base_rel_pathlists(Query *root)
|
|||||||
if (rel->issubquery)
|
if (rel->issubquery)
|
||||||
{
|
{
|
||||||
/* Subquery --- generate a separate plan for it */
|
/* Subquery --- generate a separate plan for it */
|
||||||
List *upperrestrictlist;
|
|
||||||
List *lst;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there are any restriction clauses that have been attached
|
* If there are any restriction clauses that have been attached
|
||||||
@ -118,6 +116,11 @@ set_base_rel_pathlists(Query *root)
|
|||||||
* Currently, we do not push down clauses that contain subselects,
|
* Currently, we do not push down clauses that contain subselects,
|
||||||
* mainly because I'm not sure it will work correctly (the
|
* mainly because I'm not sure it will work correctly (the
|
||||||
* subplan hasn't yet transformed sublinks to subselects).
|
* subplan hasn't yet transformed sublinks to subselects).
|
||||||
|
* Also, if the subquery contains set ops (UNION/INTERSECT/EXCEPT)
|
||||||
|
* we do not push down any qual clauses, since the planner doesn't
|
||||||
|
* support quals at the top level of a setop. (With suitable
|
||||||
|
* analysis we could try to push the quals down into the component
|
||||||
|
* queries of the setop, but getting it right is not trivial.)
|
||||||
* Non-pushed-down clauses will get evaluated as qpquals of
|
* Non-pushed-down clauses will get evaluated as qpquals of
|
||||||
* the SubqueryScan node.
|
* the SubqueryScan node.
|
||||||
*
|
*
|
||||||
@ -125,7 +128,12 @@ set_base_rel_pathlists(Query *root)
|
|||||||
* decision not to push down, because it'd result in a worse
|
* decision not to push down, because it'd result in a worse
|
||||||
* plan?
|
* plan?
|
||||||
*/
|
*/
|
||||||
upperrestrictlist = NIL;
|
if (rte->subquery->setOperations == NULL)
|
||||||
|
{
|
||||||
|
/* OK to consider pushing down individual quals */
|
||||||
|
List *upperrestrictlist = NIL;
|
||||||
|
List *lst;
|
||||||
|
|
||||||
foreach(lst, rel->baserestrictinfo)
|
foreach(lst, rel->baserestrictinfo)
|
||||||
{
|
{
|
||||||
RestrictInfo *rinfo = (RestrictInfo *) lfirst(lst);
|
RestrictInfo *rinfo = (RestrictInfo *) lfirst(lst);
|
||||||
@ -140,10 +148,11 @@ set_base_rel_pathlists(Query *root)
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We need to replace Vars in the clause (which must
|
* We need to replace Vars in the clause (which must
|
||||||
* refer to outputs of the subquery) with copies of the
|
* refer to outputs of the subquery) with copies of
|
||||||
* subquery's targetlist expressions. Note that at this
|
* the subquery's targetlist expressions. Note that
|
||||||
* point, any uplevel Vars in the clause should have been
|
* at this point, any uplevel Vars in the clause
|
||||||
* replaced with Params, so they need no work.
|
* should have been replaced with Params, so they
|
||||||
|
* need no work.
|
||||||
*/
|
*/
|
||||||
clause = ResolveNew(clause, rti, 0,
|
clause = ResolveNew(clause, rti, 0,
|
||||||
rte->subquery->targetList,
|
rte->subquery->targetList,
|
||||||
@ -160,6 +169,7 @@ set_base_rel_pathlists(Query *root)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
rel->baserestrictinfo = upperrestrictlist;
|
rel->baserestrictinfo = upperrestrictlist;
|
||||||
|
}
|
||||||
|
|
||||||
/* Generate the plan for the subquery */
|
/* Generate the plan for the subquery */
|
||||||
rel->subplan = subquery_planner(rte->subquery,
|
rel->subplan = subquery_planner(rte->subquery,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user