+ /* + * Pushable, add to tlist. We need to create a tle for this + * expression and need to transfer the sortgroupref too. We cannot + * use add_to_flat_tlist() here as it avoids the duplicate entries + * in the targetlist but here we want those duplicate entries as + * there can be multiple GROUP BY expressions pointing to the same + * column at different positions. + */ + tle = makeTargetEntry((Expr *) expr, list_length(tlist) + 1, NULL, + false); + tle->ressortgroupref = sgref; + tlist = lappend(tlist, tle);
May be we want to use add_flat_to_tlist() when sgref is not present to avoid duplicate entries.
These code changes are already inside sgref check. And for other places we do use add_to_flat_tlist().
-- Best Wishes, Ashutosh Bapat EnterpriseDB Corporation The Postgres Database Company
--
Jeevan Chalke Technical Architect, Product Development EnterpriseDB Corporation The Enterprise PostgreSQL Company