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

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: sean.johnston@edgeintelligence.com
Cc: pgsql-bugs@postgresql.org, Robert Haas <robertmhaas@gmail.com>, Jeevan Chalke <jeevan.chalke@enterprisedb.com>, Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
Date: 2017-11-07T22:29:41Z
Lists: pgsql-bugs
sean.johnston@edgeintelligence.com writes:
> select col1, col1 from loop_tbl group by 1, 2;
> psql:t.sql:7: ERROR:  targetlist item has multiple sortgroupref labels

This is the fault of commit 7012b132d ("Push down aggregates to remote
servers"), which imagined that postgres_fdw can use
apply_pathtarget_labeling_to_tlist() for situations well beyond that
function's limited abilities.  I kinda suspect that foreign_grouping_ok()
has got more bugs than this with complicated sortgroupref situations, too;
its willingness to scribble on the sortgrouprefs doesn't look like a great
idea to me.

			regards, tom lane


Commits

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

  2. postgres_fdw: Push down aggregates to remote servers.