Re: TRUNCATE on foreign tables - Mailing list pgsql-hackers

From Kohei KaiGai
Subject Re: TRUNCATE on foreign tables
Date
Msg-id CAOP8fzbky0ygWNb5+_My7efTLerc1rJOUyB=-xXu0_Ztw8VU8g@mail.gmail.com
Whole thread Raw
In response to Re: TRUNCATE on foreign tables  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: TRUNCATE on foreign tables
List pgsql-hackers
2020年1月2日(木) 12:16 Alvaro Herrera <alvherre@2ndquadrant.com>:
>
> On 2020-Jan-01, Kohei KaiGai wrote:
>
> > Hello,
> >
> > The attached patch adds TRUNCATE support on foreign table.
> >
> > This patch adds an optional callback ExecForeignTruncate(Relation rel)
> > to FdwRoutine.
> > It is invoked during ExecuteTruncateGuts, then FDW driver hands over
> > the jobs related to complete "truncate on the foreign table".
>
> I think this would need to preserve the notion of multi-table truncates.
> Otherwise it won't be possible to truncate tables linked by FKs.  I
> think this means the new entrypoint needs to receive a list of rels to
> truncate, not just one.  (Maybe an alternative is to make it "please
> truncate rel X, and be aware that relations Y,Z are also being
> truncated at the same time".)
>
Please check at ExecuteTruncateGuts(). It makes a list of relations to be
truncated, including the relations that references the specified table by FK,
prior to invocation of the new FDW callback.
So, if multiple foreign tables are involved in a single TRUNCATE command,
this callback can be invoked multiple times.

> Looking at apache arrow documentation, it doesn't appear that it has
> anything like FK constraints.
>
Yes. It is just a bunch of columnar data.
In Apache Arrow, no constraint are defined except for "NOT NULL".
(In case when Field::nullable == false, all the values are considered
valid date.)

Thanks,
--
HeteroDB, Inc / The PG-Strom Project
KaiGai Kohei <kaigai@heterodb.com>



pgsql-hackers by date:

Previous
From: Dilip Kumar
Date:
Subject: Re: PATCH: logical_work_mem and logical streaming of largein-progress transactions
Next
From: Noah Misch
Date:
Subject: Re: mdclose() does not cope w/ FileClose() failure