Re: [BUGS] BUG #14890: Error grouping by same column twice using FDW

Jeevan Chalke <jeevan.chalke@enterprisedb.com>

From: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
To: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, sean.johnston@edgeintelligence.com, Postgres-Bugs <pgsql-bugs@postgresql.org>, Robert Haas <robertmhaas@gmail.com>
Date: 2017-11-15T08:51:33Z
Lists: pgsql-bugs
On Fri, Nov 10, 2017 at 6:14 PM, Ashutosh Bapat <
ashutosh.bapat@enterprisedb.com> wrote:

>
> +            /*
> +             * 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

Commits

  1. Fix postgres_fdw to cope with duplicate GROUP BY entries.

  2. postgres_fdw: Push down aggregates to remote servers.