diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-08-19 02:48:53 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-08-19 02:48:53 +0000 |
| commit | fb9e56eea11a970e574260b82d6b05b4fe5a4308 (patch) | |
| tree | 7121fa2a8dc512d9679f4ac3a029f06618f203c5 /src/backend/optimizer/prep/prepjointree.c | |
| parent | 9bf760f7dec703aa34d9bd68aaa982943d24411e (diff) | |
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.
Diffstat (limited to 'src/backend/optimizer/prep/prepjointree.c')
| -rw-r--r-- | src/backend/optimizer/prep/prepjointree.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c index ef92d9d3c9f..bea7c03a739 100644 --- a/src/backend/optimizer/prep/prepjointree.c +++ b/src/backend/optimizer/prep/prepjointree.c @@ -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 $ * *------------------------------------------------------------------------- */ @@ -657,6 +657,15 @@ is_simple_subquery(Query *subquery) 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 * that's totally empty, but I don't think the right things happen if an |
