Fix oversight in planning of GROUP queries: when an expression is used
Tom Lane <tgl@sss.pgh.pa.us>
Fix oversight in planning of GROUP queries: when an expression is used as both a GROUP BY item and an output expression, the top-level Group node should just copy up the evaluated expression value from its input, rather than re-evaluating the expression. Aside from any performance benefit this might offer, this avoids a crash when there is a sub-SELECT in said expression.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/optimizer/plan/setrefs.c | modified | +60 −6 |
| src/backend/optimizer/plan/subselect.c | modified | +3 −2 |
| src/backend/optimizer/util/tlist.c | modified | +2 −3 |
| src/include/optimizer/tlist.h | modified | +2 −1 |