diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-04-19 19:46:33 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-04-19 19:46:33 +0000 |
commit | 1d97c19a0f748e94b9582dcbaec33ad74be062f9 (patch) | |
tree | dc701c3e1de608b76284d5ac34e7566c4b7a8b56 /src/backend/utils/adt/selfuncs.c | |
parent | 3a624e9200bbd8b88d7724e1448fe530f32e2c3c (diff) | |
download | postgresql-1d97c19a0f748e94b9582dcbaec33ad74be062f9.tar.gz postgresql-1d97c19a0f748e94b9582dcbaec33ad74be062f9.zip |
Fix estimate_num_groups() to not fail on PlaceHolderVars, per report from
Stefan Kaltenbrunner. The most reasonable behavior (at least for the near
term) seems to be to ignore the PlaceHolderVar and examine its argument
instead. In support of this, change the API of pull_var_clause() to allow
callers to request recursion into PlaceHolderVars. Currently
estimate_num_groups() is the only customer for that behavior, but where
there's one there may be others.
Diffstat (limited to 'src/backend/utils/adt/selfuncs.c')
-rw-r--r-- | src/backend/utils/adt/selfuncs.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index e4b1acb1f83..3f07db6857f 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.259 2009/02/15 20:16:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.260 2009/04/19 19:46:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -2984,9 +2984,12 @@ estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows) ReleaseVariableStats(vardata); /* - * Else pull out the component Vars + * Else pull out the component Vars. Handle PlaceHolderVars by + * recursing into their arguments (effectively assuming that the + * PlaceHolderVar doesn't change the number of groups, which boils + * down to ignoring the possible addition of nulls to the result set). */ - varshere = pull_var_clause(groupexpr, true); + varshere = pull_var_clause(groupexpr, PVC_RECURSE_PLACEHOLDERS); /* * If we find any variable-free GROUP BY item, then either it is a |