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

Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>

From: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Jeevan Chalke <jeevan.chalke@enterprisedb.com>, sean.johnston@edgeintelligence.com, Postgres-Bugs <pgsql-bugs@postgresql.org>, Robert Haas <robertmhaas@gmail.com>
Date: 2017-11-17T12:09:32Z
Lists: pgsql-bugs
On Sat, Nov 11, 2017 at 12:14 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> As you say, we can probably get away without that as long as we don't push
> mutable grouping expressions ... but just because we think a grouping
> expression is immutable at our end doesn't necessarily mean that it is at
> the far end.

Well, I thought of that case but then we may have problems without
GROUP BY. use_physical_tlist() doesn't list ForeignScan as an
exception. deparseTargetList() constructs the tlist based on
attrs_used, which doesn't know if the same column was repeated in the
SELECT clause. build_tlist_to_deparse() flattens the tlist to be
deparsed. I think the assumption is that the user won't use immutable
expression as a column.

-- 
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company


Commits

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

  2. postgres_fdw: Push down aggregates to remote servers.