Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hIRrc-0006aO-BD for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Apr 2019 05:51:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hIRrb-0007UJ-2y for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Apr 2019 05:51:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hIRra-0007RH-LQ; Mon, 22 Apr 2019 05:51:34 +0000 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hIRrX-0005SE-TD; Mon, 22 Apr 2019 05:51:33 +0000 Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id x3M5pPJb026377; Mon, 22 Apr 2019 14:51:25 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 8F66EEA7D41; Mon, 22 Apr 2019 14:51:25 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 7D297EA7D1C; Mon, 22 Apr 2019 14:51:25 +0900 (JST) Received: from [127.0.0.1] (unknown [129.60.241.61]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 65AF340075C; Mon, 22 Apr 2019 14:51:25 +0900 (JST) Subject: Re: pgsql: Allow insert and update tuple routing and COPY for foreign table References: From: Amit Langote Message-ID: Date: Mon, 22 Apr 2019 14:51:16 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-CC-Mail-RelayStamp: 1 To: Laurenz Albe , Robert Haas , pgsql-committers@lists.postgresql.org, pgsql-hackers@lists.postgresql.org X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2019/04/20 20:53, Laurenz Albe wrote: > On Fri, 2018-04-06 at 23:24 +0000, Robert Haas wrote: >> Allow insert and update tuple routing and COPY for foreign tables. >> >> Also enable this for postgres_fdw. >> >> Etsuro Fujita, based on an earlier patch by Amit Langote. The larger >> patch series of which this is a part has been reviewed by Amit >> Langote, David Fetter, Maksim Milyutin, Álvaro Herrera, Stephen Frost, >> and me. Minor documentation changes to the final version by me. >> >> Discussion: http://postgr.es/m/29906a26-da12-8c86-4fb9-d8f88442f2b9@lab.ntt.co.jp > > This commit makes life hard for foreign data wrappers that support > data modifications. > > If a FDW implements ExecForeignInsert, this commit automatically assumes > that it also supports COPY FROM. It will call ExecForeignInsert without > calling PlanForeignModify and BeginForeignModify, and a FDW that does not > expect that will probably fail. > > So this commit silently turns a functioning FDW into a broken FDW. > That is not nice. Probably not every FDW is aware of this change, and > maybe there are FDWs that support INSERT but don't want to support COPY > for some reason. That seems like an oversight to me. I agree that we had better checked that a table's FDW provides BeginForeignInsert() before proceeding with copying into the table, as your patch teaches CopyFrom() to do. > I propose that PostgreSQL only allows COPY FROM on a foreign table if the FDW > implements BeginForeignInsert. The attached patch implements that. Looks good to me, including the documentation change. > I think this should be backpatched to v11. Agreed. Thanks, Amit