Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agEgv-00062r-Mi for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Mar 2016 16:53:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1agEgv-0001YY-9T for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Mar 2016 16:53:01 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1agEgt-0001Xu-V2 for pgsql-hackers@postgresql.org; Wed, 16 Mar 2016 16:53:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1agEgr-0003Nj-Ck for pgsql-hackers@postgresql.org; Wed, 16 Mar 2016 16:52:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u2GGqnfg019868; Wed, 16 Mar 2016 12:52:49 -0400 From: Tom Lane To: Robert Haas cc: Ashutosh Bapat , Etsuro Fujita , Andres Freund , "pgsql-hackers@postgresql.org" Subject: Re: Re: [COMMITTERS] pgsql: Only try to push down foreign joins if the user mapping OIDs mat In-reply-to: References: <20160312031502.lqtbqnqor4vji62k@alap3.anarazel.de> <20160312194625.txlzu22xykgpu66n@alap3.anarazel.de> <56E6240E.5090301@lab.ntt.co.jp> <18299.1457923919@sss.pgh.pa.us> <3221.1457975148@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Wed, 16 Mar 2016 12:12:45 -0400" Date: Wed, 16 Mar 2016 12:52:49 -0400 Message-ID: <19867.1458147169@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Robert Haas writes: > On Wed, Mar 16, 2016 at 4:10 AM, Ashutosh Bapat < > ashutosh.bapat@enterprisedb.com> wrote: >> In 9.5, postgres_fdw allowed to prepare statements involving foreign >> tables without an associated user mapping as long as planning did not >> require the user mapping. Remember, planner would require user mapping in >> case use_remote_estimate is ON for that foreign table. The user mapping >> would be certainly required at the time of execution. So executing such a >> prepared statement would throw error. If somebody created a user mapping >> between prepare and execute, execute would not throw an error. A join can >> be pushed down only when user mappings associated with the joining >> relations are known and they match. But given the behavior of 9.5 we should >> let the prepare succeed, even if the join can not be pushed down because of >> unknown user mapping. Before this fix, the test was not letting the prepare >> succeed, which is not compliant with 9.5. > If a query against a single table with no user mapping is legal, I don't > see why pushing down a join between two tables neither of which has a user > mapping shouldn't also be legal. The key point here is that Ashutosh is arguing on the basis of the behavior of postgres_fdw, which is not representative of all FDWs. The core code has no business assuming that all FDWs require user mappings; file_fdw is a counterexample. I think the behavior Robert suggests is just fine. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers