aboutsummaryrefslogtreecommitdiff
path: root/src/include/postgres.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2013-11-07 13:13:47 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2013-11-07 13:13:47 -0500
commit6e2c7624806f6cbbbfcc6fa0de0f2c11da6c0e03 (patch)
tree49d47c4c64753ff5513638f4601926992d8a163a /src/include/postgres.h
parentaad87e3f25ad751a3d021c139fd3adbbe1d19fce (diff)
downloadpostgresql-6e2c7624806f6cbbbfcc6fa0de0f2c11da6c0e03.tar.gz
postgresql-6e2c7624806f6cbbbfcc6fa0de0f2c11da6c0e03.zip
Fix generation of MergeAppend plans for optimized min/max on expressions.
Before jamming a desired targetlist into a plan node, one really ought to make sure the plan node can handle projections, and insert a buffering Result plan node if not. planagg.c forgot to do this, which is a hangover from the days when it only dealt with IndexScan plan types. MergeAppend doesn't project though, not to mention that it gets unhappy if you remove its possibly-resjunk sort columns. The code accidentally failed to fail for cases in which the min/max argument was a simple Var, because the new targetlist would be equivalent to the original "flat" tlist anyway. For any more complex case, it's been broken since 9.1 where we introduced the ability to optimize min/max using MergeAppend, as reported by Raphael Bauduin. Fix by duplicating the logic from grouping_planner that decides whether we need a Result node. In 9.2 and 9.1, this requires back-porting the tlist_same_exprs() function introduced in commit 4387cf956b9eb13aad569634e0c4df081d76e2e3, else we'd uselessly add a Result node in cases that worked before. It's rather tempting to back-patch that whole commit so that we can avoid extra Result nodes in mainline cases too; but I'll refrain, since that code hasn't really seen all that much field testing yet.
Diffstat (limited to 'src/include/postgres.h')
0 files changed, 0 insertions, 0 deletions