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 1hJHaB-0005Ub-D6 for pgsql-committers@arkaria.postgresql.org; Wed, 24 Apr 2019 13:05:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hJHa9-0005iB-Ne for pgsql-committers@arkaria.postgresql.org; Wed, 24 Apr 2019 13:05:01 +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 1hJHa9-0005i1-7S; Wed, 24 Apr 2019 13:05:01 +0000 Received: from mx1.mailbox.org ([80.241.60.212]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hJHa5-0003wf-Au; Wed, 24 Apr 2019 13:04:59 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 1D3584D87E; Wed, 24 Apr 2019 15:04:53 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id u7DXLQb0vVSI; Wed, 24 Apr 2019 15:04:50 +0200 (CEST) Message-ID: Subject: Re: pgsql: Allow insert and update tuple routing and COPY for foreign table From: Laurenz Albe To: Etsuro Fujita Cc: Robert Haas , pgsql-committers@lists.postgresql.org, pgsql-hackers@lists.postgresql.org Date: Wed, 24 Apr 2019 15:04:47 +0200 In-Reply-To: <5CC04E72.90405@lab.ntt.co.jp> References: <5CBDB770.2060602@lab.ntt.co.jp> <5CC04E72.90405@lab.ntt.co.jp> Organization: Cybertec Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, 2019-04-24 at 20:54 +0900, Etsuro Fujita wrote: > How about adding to the documentation for BeginForeignInsert a mention > that if an FDW doesn't support COPY FROM and/or routable foreign tables, > it must throw an error in BeginForeignInsert accordingly. Sure, some more documentation would be good. The documentation of ExecForeignInsert should mention something like: ExecForeignInsert is called for INSERT statements as well as for COPY FROM and tuples that are inserted into a foreign table because it is a partition of a partitioned table. In the case of a normal INSERT, BeginForeignModify will be called before ExecForeignInsert to perform any necessary setup. In the other cases, this setup has to happen in BeginForeignInsert. Before PostgreSQL v11, a foreign data wrapper could be certain that BeginForeignModify is always called before ExecForeignInsert. This is no longer true. > > On the other hand, if a FDW wants to support COPY in v11 and has no > > need for BeginForeignInsert to support that, it is a simple exercise > > for it to provide an empty BeginForeignInsert just to signal that it > > wants to support COPY. > > That seems to me inconsistent with the concept of the existing APIs for > updating foreign tables, because for an FDW that wants to support > INSERT/UPDATE/DELETE and has no need for > PlanForeignModify/BeginForeignModify, those APIs don't require the FDW > to provide empty PlanForeignModify/BeginForeignModify to tell the core > that it wants to support INSERT/UPDATE/DELETE. That is true, but so far there hasn't been a change to the FDW API that caused a callback to be invoked in a different fashion than it used to be. Perhaps it would have been better to create a new callback like ExecForeignCopy with the same signature as ExecForeignInsert so that you can use the same callback function for both if you want. That would also have avoided the breakage. But, of course it is too late for that now. Note that postgres_fdw would have been broken by that API change as well if it hasn't been patched. At the very least, this should have been mentioned in the list of incompatible changes for v11. Yours, Laurenz Albe