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 1fvIZG-0000Rt-RK for pgsql-bugs@arkaria.postgresql.org; Thu, 30 Aug 2018 08:44:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fvIZF-0005Xz-7s for pgsql-bugs@arkaria.postgresql.org; Thu, 30 Aug 2018 08:44:41 +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 1fvIZF-0005Xp-1v for pgsql-bugs@lists.postgresql.org; Thu, 30 Aug 2018 08:44:41 +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 1fvIZC-0001il-PL; Thu, 30 Aug 2018 08:44:40 +0000 Received: from [192.168.127.1] (port=30609 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 1fvIZA-000Byd-Fw; Thu, 30 Aug 2018 08:44:36 +0000 Received: from [127.0.0.1] (port=47356 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1fvIZ9-00030K-Jo; Thu, 30 Aug 2018 08:44:35 +0000 From: Andrew Gierth To: Ashutosh Bapat Cc: pgsql-bugs@lists.postgresql.org, rhaas@postgresql.org Subject: Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list" In-Reply-To: (Ashutosh Bapat's message of "Thu, 30 Aug 2018 11:07:28 +0530") Message-ID: <87efegxn6b.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> <87r2iiy3if.fsf@news-spur.riddles.org.uk> <87mut5xye8.fsf@news-spur.riddles.org.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Thu, 30 Aug 2018 09:44:34 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk [removing the OP from CC list] >>>>> "Ashutosh" == Ashutosh Bapat writes: >> Well, it's certainly pointless. >> >> But the failure in this case is specifically about pushing down an >> _integer_ constant, because the deparse code for pushing down an >> ORDER BY does not understand that integer literals in ORDER BY >> clauses are a special case. Ashutosh> Deparser needs to be fixed then, irrespective of whether or Ashutosh> not we fix the costant pathkey problem. Since we have no business sending sort expressions to the remote that do not include remote vars, this seems superfluous. Any such expression is either mutable (and hence not pushable anyway) or known locally to be constant (in which case we never legitimately see it in a pathkey). (Maybe Asserting it or throwing an error might be appropriate.) >> I'm pretty sure that constant (hence redundant) clauses have been >> removed from pathkeys before postgres_fdw will see them. The problem >> only occurs because postgres_fdw tries inventing _new_ pathkeys for >> possible orderings from eclasses (in order to try for mergejoin >> opportunities) in addition to using the requested pathkeys, and it's >> clearly pointless to do that with constants. Ashutosh> Yes, I forgot about that. But even in that case, we should Ashutosh> consider the case when the constant pathkey is just one in Ashutosh> the bunch and we are trying to push the whole bunch. How do you think that could happen, given that redundant pathkeys are already removed? -- Andrew (irc:RhodiumToad)