postgresql/src/backend/utils/adt
Tom Lane c1d9579dd8 Avoid listing ungrouped Vars in the targetlist of Agg-underneath-Window.
Regular aggregate functions in combination with, or within the arguments
of, window functions are OK per spec; they have the semantics that the
aggregate output rows are computed and then we run the window functions
over that row set.  (Thus, this combination is not really useful unless
there's a GROUP BY so that more than one aggregate output row is possible.)
The case without GROUP BY could fail, as recently reported by Jeff Davis,
because sloppy construction of the Agg node's targetlist resulted in extra
references to possibly-ungrouped Vars appearing outside the aggregate
function calls themselves.  See the added regression test case for an
example.

Fixing this requires modifying the API of flatten_tlist and its underlying
function pull_var_clause.  I chose to make pull_var_clause's API for
aggregates identical to what it was already doing for placeholders, since
the useful behaviors turn out to be the same (error, report node as-is, or
recurse into it).  I also tightened the error checking in this area a bit:
if it was ever valid to see an uplevel Var, Aggref, or PlaceHolderVar here,
that was a long time ago, so complain instead of ignoring them.

Backpatch into 9.1.  The failure exists in 8.4 and 9.0 as well, but seeing
that it only occurs in a basically-useless corner case, it doesn't seem
worth the risks of changing a function API in a minor release.  There might
be third-party code using pull_var_clause.
2011-07-12 18:24:39 -04:00
..
acl.c Try to acquire relation locks in RangeVarGetRelid. 2011-07-08 22:19:30 -04:00
array_userfuncs.c Fix array- and path-creating functions to ensure padding bytes are zeroes. 2011-04-27 13:58:36 -04:00
arrayfuncs.c Improve hash_array() logic for combining hash values. 2011-05-23 15:17:18 -04:00
arrayutils.c Use array_contains_nulls instead of ARR_HASNULL on user-supplied arrays. 2011-01-09 13:09:07 -05:00
ascii.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
bool.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
cash.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
char.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
date.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
datetime.c Pgindent run before 9.1 beta2. 2011-06-09 14:32:50 -04:00
datum.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
dbsize.c Rewrite pg_size_pretty() to avoid compiler bug. 2011-04-29 01:45:58 -04:00
domains.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
encode.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
enum.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
float.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
format_type.c Use a macro variable PG_PRINTF_ATTRIBUTE for the style used for checking printf type functions. 2011-04-28 10:56:14 -04:00
formatting.c Fix char2wchar/wchar2char to support collations properly. 2011-04-23 12:35:41 -04:00
genfile.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
geo_ops.c Fix array- and path-creating functions to ensure padding bytes are zeroes. 2011-04-27 13:58:36 -04:00
geo_selfuncs.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
inet_cidr_ntop.c When reporting the server as not responding, if the hostname was 2010-11-24 17:04:19 -05:00
inet_net_pton.c Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
int8.c Add overflow checks to int4 and int8 versions of generate_series(). 2011-06-17 14:28:45 -04:00
int.c Add overflow checks to int4 and int8 versions of generate_series(). 2011-06-17 14:28:45 -04:00
like_match.c Fix ILIKE to honor collation when working in single-byte encodings. 2011-04-09 17:12:39 -04:00
like.c Pass collations to functions in FunctionCallInfoData, not FmgrInfo. 2011-04-12 19:19:24 -04:00
lockfuncs.c Include pid in pg_lock_status() results even for SIREAD locks. 2011-04-04 13:23:43 -04:00
mac.c Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
Makefile When reporting the server as not responding, if the hostname was 2010-11-24 17:04:19 -05:00
misc.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
nabstime.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
name.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
network.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
numeric.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
numutils.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
oid.c Pass collations to functions in FunctionCallInfoData, not FmgrInfo. 2011-04-12 19:19:24 -04:00
oracle_compat.c Per-column collation support 2011-02-08 23:04:18 +02:00
pg_locale.c Pgindent run before 9.1 beta2. 2011-06-09 14:32:50 -04:00
pg_lzcompress.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
pgstatfuncs.c Mark pg_stat_reset_shared as strict 2011-07-03 13:15:58 +02:00
pseudotypes.c Allow binary I/O of type "void". 2011-02-22 13:08:22 -05:00
quote.c Add PL/Python functions for quoting strings 2011-02-22 23:41:23 +02:00
regexp.c Teach regular expression operators to honor collations. 2011-04-10 18:03:09 -04:00
regproc.c Try to acquire relation locks in RangeVarGetRelid. 2011-07-08 22:19:30 -04:00
ri_triggers.c Move Trigger and TriggerDesc structs out of rel.h into a new reltrigger.h 2011-07-04 14:35:58 -04:00
rowtypes.c Pass collations to functions in FunctionCallInfoData, not FmgrInfo. 2011-04-12 19:19:24 -04:00
ruleutils.c Try to acquire relation locks in RangeVarGetRelid. 2011-07-08 22:19:30 -04:00
selfuncs.c Avoid listing ungrouped Vars in the targetlist of Agg-underneath-Window. 2011-07-12 18:24:39 -04:00
tid.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
timestamp.c Use macros for time-based constants, rather than constants. 2011-03-12 09:35:56 -05:00
trigfuncs.c Move Trigger and TriggerDesc structs out of rel.h into a new reltrigger.h 2011-07-04 14:35:58 -04:00
tsginidx.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
tsgistidx.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
tsquery_cleanup.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
tsquery_gist.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
tsquery_op.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
tsquery_rewrite.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
tsquery_util.c Avoid uninitialized bits in the result of QTN2QT(). 2011-05-24 14:20:08 -04:00
tsquery.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
tsrank.c Use array_contains_nulls instead of ARR_HASNULL on user-supplied arrays. 2011-01-09 13:09:07 -05:00
tsvector_op.c Move Trigger and TriggerDesc structs out of rel.h into a new reltrigger.h 2011-07-04 14:35:58 -04:00
tsvector_parser.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
tsvector.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
txid.c Add C comment that txid_current() assigns an XID if one is not already 2011-07-11 20:33:07 -04:00
uuid.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
varbit.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
varchar.c Add notion of a "transform function" that can simplify function calls. 2011-06-21 22:21:24 -04:00
varlena.c Message style improvements 2011-07-08 07:37:04 +03:00
version.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
windowfuncs.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
xid.c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
xml.c Move Trigger and TriggerDesc structs out of rel.h into a new reltrigger.h 2011-07-04 14:35:58 -04:00