Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fueu6-00036s-8y for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Aug 2018 14:23:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fueu3-00056P-Rn for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Aug 2018 14:23:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fueu3-00056I-M0 for pgsql-bugs@lists.postgresql.org; Tue, 28 Aug 2018 14:23:31 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fuetw-0004FW-8Y; Tue, 28 Aug 2018 14:23:30 +0000 Received: from [192.168.127.1] (port=57624 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1fuett-0008ae-8d; Tue, 28 Aug 2018 14:23:21 +0000 Received: from [127.0.0.1] (port=60495 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1fuets-000CW5-GS; Tue, 28 Aug 2018 14:23:20 +0000 From: Andrew Gierth To: pgsql-bugs@lists.postgresql.org Cc: maxim.boguk@gmail.com, rhaas@postgresql.org, Ashutosh Bapat Subject: Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list" In-Reply-To: <87a7paz8b1.fsf@news-spur.riddles.org.uk> (Andrew Gierth's message of "Sat, 25 Aug 2018 18:12:58 +0100") Message-ID: <87r2iiy3if.fsf@news-spur.riddles.org.uk> References: <153518420278.1478.14875560810251994661@wrigleys.postgresql.org> <87efemzw0v.fsf@news-spur.riddles.org.uk> <87a7paz8b1.fsf@news-spur.riddles.org.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Tue, 28 Aug 2018 15:23:20 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Andrew" == Andrew Gierth writes: Andrew> It seems obviously wrong that a constant pathkey with no actual Andrew> reference to the foreign table should be being pushed down, so Andrew> so far I suspect that get_useful_pathkeys_for_relation isn't Andrew> being selective enough about what is "useful". In this context Andrew> I find it suspicious that find_em_expr_for_rel will return an Andrew> expr with no vars as being "for" every rel, since it's just Andrew> looking for a subset. Andrew> So this looks to me like an oversight in aa09cd242 (CCing rhaas Andrew> and Ashutosh accordingly), which changed find_em_expr_for_rel Andrew> from using bms_equal to bms_is_subset without considering the Andrew> degenerate case of members with no relids at all. I propose to Andrew> simply add a !bms_is_empty condition there; anyone have any Andrew> better idea? Pushed this. -- Andrew (irc:RhodiumToad)