Re: pgsql: Allow insert and update tuple routing and COPY for foreign table

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Robert Haas <rhaas(at)postgresql(dot)org>, pgsql-committers(at)lists(dot)postgresql(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Allow insert and update tuple routing and COPY for foreign table
Date: 2019-04-22 05:51:16
Message-ID: d76c786b-8d10-f776-527e-2997ccbe0bee@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

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

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Etsuro Fujita 2019-04-22 12:45:36 Re: pgsql: Allow insert and update tuple routing and COPY for foreign table
Previous Message Etsuro Fujita 2019-04-22 05:50:20 Re: pgsql: Allow insert and update tuple routing and COPY for foreign table

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2019-04-22 07:04:08 Re: [PATCH v1] Add \echo_stderr to psql
Previous Message Etsuro Fujita 2019-04-22 05:50:20 Re: pgsql: Allow insert and update tuple routing and COPY for foreign table