pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Kazutaka Onishi <onishi@heterodb.com>
To: Amit Langote <amitlangote09@gmail.com>
Cc: Ibrar Ahmed <ibrar.ahmad@gmail.com>
Cc: Kohei KaiGai <kaigai@heterodb.com>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Zhihong Yu <zyu@yugabyte.com>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Cc: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Subject: Re: TRUNCATE on foreign table
Date: Thu, 25 Mar 2021 03:47:03 +0900
Message-ID: <66da56a4-ed5a-a18f-0f5e-b4d21cda71af@oss.nttdata.com> (raw)
In-Reply-To: <CAJuF6cMxN=3myt3Uf3hhpwrXy4kFsDbdq9O_9NOJgNU5AB-AUw@mail.gmail.com>
References: <CAJuF6cMWDDqU-vn_knZgma+2GMaout68YUgn1uyDnexRhqqM5Q@mail.gmail.com>
	<CALNJ-vSDcJhqQ1Wq8dq+gdtesfuyc++eC7rNZFvKfB003q2Qhg@mail.gmail.com>
	<CAJuF6cP+c2UW8uyofoyh7JeWSj5GuMPfXTy1DF-uK6HLSe=-3g@mail.gmail.com>
	<CAExHW5uWU85myXdgO_okW=Ab3+JLXOO1hbAb_Y1rdRZo5q+tQg@mail.gmail.com>
	<CALj2ACUryBiJvdrEnghnygPaaniyobjZxzK96h-xwah9LWpX3w@mail.gmail.com>
	<CAExHW5sb6jFFB4MBw+fHkSs0pKzD6=Ux=08kfiPN1_gEh4QSKg@mail.gmail.com>
	<CAJuF6cNVJC5+C2ci0FCgJBpSX8NZF+eaMTbcboDRtTPyagUttA@mail.gmail.com>
	<CAExHW5uk+J61fVgcf+HYNZTuY9UnFnLhr34wMYU26mCtpf8i5w@mail.gmail.com>
	<CAJuF6cPwm13tnfRUAcy2CpncEvrGUOaJPuz4rWVFixL28zTA1g@mail.gmail.com>
	<CAExHW5tceUdJSYMy6R8uYzJ2upKfKdJdWPyUmM16-_xEdFGL0g@mail.gmail.com>
	<CALtqXTdRzbnDqYv-bA3N83+C6+=NkWa=R69sSk=-PZgHdBY0Bg@mail.gmail.com>
	<CA+HiwqFVecXnLUtTv6J2hTyEdkVtkTae3QNfOKRobu+L_1=9QA@mail.gmail.com>
	<CAJuF6cN4oU==vATJ7AgSqxCzV6X7j95O97LtKJcwddVcAcEx1w@mail.gmail.com>
	<CAJuF6cMxN=3myt3Uf3hhpwrXy4kFsDbdq9O_9NOJgNU5AB-AUw@mail.gmail.com>



On 2021/03/13 18:57, Kazutaka Onishi wrote:
> I have fixed the patch to pass check-world test. :D

Thanks for updating the patch! Here are some review comments from me.


       By default all foreign tables using <filename>postgres_fdw</filename> are assumed
       to be updatable.  This may be overridden using the following option:

In postgres-fdw.sgml, "and truncatable" should be appended into
the above first description? Also "option" in the second description
should be a plural form "options"?


      <command>TRUNCATE</command> is not currently supported for foreign tables.
      This implies that if a specified table has any descendant tables that are
      foreign, the command will fail.

truncate.sgml should be updated because, for example, it contains
the above descriptions.


+     <literal>frels_extra</literal> is same length with
+     <literal>frels_list</literal>, that delivers extra information of
+     the context where the foreign-tables are truncated.
+    </para>

Don't we need to document the detail information about frels_extra?
Otherwise the developers of FDW would fail to understand how to
handle the frels_extra when trying to make their FDWs support TRUNCATE.


+		relids_extra = lappend_int(relids_extra, (recurse ? 0 : 1));
+				relids_extra = lappend_int(relids_extra, -1);

postgres_fdw determines whether to specify ONLY or not by checking
whether the passed extra value is zero or not. That is, for example,
using only 0 and 1 for extra values is enough for the purpose. But
ExecuteTruncate() sets three values 0, -1 and 1 as extra ones. Why are
these three values necessary?


With the patch, if both local and foreign tables are specified as
the target tables to truncate, TRUNCATE command tries to truncate
foreign tables after truncating local ones. That is, if "truncatable"
option is set to false or enough permission to truncate is not granted
yet in the foreign server, an error will be thrown after the local tables
are truncated. I don't think this is good order of processings. IMO,
instead, we should check whether foreign tables can be truncated
before any actual truncation operations. For example, we can easily
do that by truncate foreign tables before local ones. Thought?


XLOG_HEAP_TRUNCATE record is written even for the truncation of
a foreign table. Why is this necessary?

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION





view thread (117+ messages)  latest in thread

Message-ID: <66da56a4-ed5a-a18f-0f5e-b4d21cda71af@oss.nttdata.com>
Permalink:  ../66da56a4-ed5a-a18f-0f5e-b4d21cda71af@oss.nttdata.com/
Also on:    postgresql.org/message-id/66da56a4-ed5a-a18f-0f5e-b4d21cda71af@oss.nttdata.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: masao.fujii@oss.nttdata.com, onishi@heterodb.com, amitlangote09@gmail.com, ibrar.ahmad@gmail.com, kaigai@heterodb.com, bharath.rupireddyforpostgres@gmail.com, zyu@yugabyte.com, ashutosh.bapat.oss@gmail.com
  Subject: Re: TRUNCATE on foreign table
  In-Reply-To: <66da56a4-ed5a-a18f-0f5e-b4d21cda71af@oss.nttdata.com>
  References: <CAJuF6cMWDDqU-vn_knZgma+2GMaout68YUgn1uyDnexRhqqM5Q@mail.gmail.com> <CAJuF6cP+c2UW8uyofoyh7JeWSj5GuMPfXTy1DF-uK6HLSe=-3g@mail.gmail.com> <CAExHW5uWU85myXdgO_okW=Ab3+JLXOO1hbAb_Y1rdRZo5q+tQg@mail.gmail.com> <CALj2ACUryBiJvdrEnghnygPaaniyobjZxzK96h-xwah9LWpX3w@mail.gmail.com> <CAExHW5sb6jFFB4MBw+fHkSs0pKzD6=Ux=08kfiPN1_gEh4QSKg@mail.gmail.com> <CAJuF6cNVJC5+C2ci0FCgJBpSX8NZF+eaMTbcboDRtTPyagUttA@mail.gmail.com> <CAExHW5uk+J61fVgcf+HYNZTuY9UnFnLhr34wMYU26mCtpf8i5w@mail.gmail.com> <CAJuF6cPwm13tnfRUAcy2CpncEvrGUOaJPuz4rWVFixL28zTA1g@mail.gmail.com> <CAExHW5tceUdJSYMy6R8uYzJ2upKfKdJdWPyUmM16-_xEdFGL0g@mail.gmail.com> <CALtqXTdRzbnDqYv-bA3N83+C6+=NkWa=R69sSk=-PZgHdBY0Bg@mail.gmail.com> <CA+HiwqFVecXnLUtTv6J2hTyEdkVtkTae3QNfOKRobu+L_1=9QA@mail.gmail.com> <CAJuF6cN4oU==vATJ7AgSqxCzV6X7j95O97LtKJcwddVcAcEx1w@mail.gmail.com> <CAJuF6cMxN=3myt3Uf3hhpwrXy4kFsDbdq9O_9NOJgNU5AB-AUw@mail.gmail.com> <66da56a4-ed5a-a18f-0f5e-b4d21cda71af@oss.nttdata.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox