mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Suppress subquery pullup and pushdown when the subquery has any
set-returning functions in its target list. This ensures that we won't rewrite the query in a way that places set-returning functions into quals (WHERE clauses). Cf. bug reports from Joe Conway.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.82 2001/11/05 17:46:25 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.83 2001/12/10 22:54:12 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -305,7 +305,14 @@ set_subquery_pathlist(Query *root, RelOptInfo *rel,
|
||||
* checking that seems more work than it's worth. In any case, a
|
||||
* plain DISTINCT is safe to push down past.)
|
||||
*
|
||||
* 3. We do not push down clauses that contain subselects, mainly because
|
||||
* 3. If the subquery has any ITER nodes (ie, functions returning sets)
|
||||
* in its target list, we do not push down any quals, since the quals
|
||||
* might refer to those tlist items, which would mean we'd introduce
|
||||
* functions-returning-sets into the subquery's WHERE/HAVING quals.
|
||||
* (It'd be sufficient to not push down quals that refer to those
|
||||
* particular tlist items, but that's much clumsier to check.)
|
||||
*
|
||||
* 4. We do not push down clauses that contain subselects, mainly because
|
||||
* I'm not sure it will work correctly (the subplan hasn't yet
|
||||
* transformed sublinks to subselects).
|
||||
*
|
||||
@ -318,7 +325,8 @@ set_subquery_pathlist(Query *root, RelOptInfo *rel,
|
||||
if (subquery->setOperations == NULL &&
|
||||
subquery->limitOffset == NULL &&
|
||||
subquery->limitCount == NULL &&
|
||||
!has_distinct_on_clause(subquery))
|
||||
!has_distinct_on_clause(subquery) &&
|
||||
!contain_iter_clause((Node *) subquery->targetList))
|
||||
{
|
||||
/* OK to consider pushing down individual quals */
|
||||
List *upperrestrictlist = NIL;
|
||||
|
Reference in New Issue
Block a user