1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

Suppress subquery pullup/pushdown when a subquery contains volatile

functions in its targetlist, to avoid introducing multiple evaluations
of volatile functions that textually appear only once.  This is a
slightly tighter version of Jaime Casanova's recent patch.
This commit is contained in:
Tom Lane
2006-08-19 02:48:53 +00:00
parent 9bf760f7de
commit fb9e56eea1
2 changed files with 22 additions and 2 deletions

View File

@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.42 2006/08/12 20:05:55 tgl Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.43 2006/08/19 02:48:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -656,6 +656,15 @@ is_simple_subquery(Query *subquery)
if (expression_returns_set((Node *) subquery->targetList))
return false;
/*
* Don't pull up a subquery that has any volatile functions in its
* targetlist. Otherwise we might introduce multiple evaluations of
* these functions, if they get copied to multiple places in the upper
* query, leading to surprising results.
*/
if (contain_volatile_functions((Node *) subquery->targetList))
return false;
/*
* Hack: don't try to pull up a subquery with an empty jointree.
* query_planner() will correctly generate a Result plan for a jointree