Re: TRUNCATE on foreign table

Fujii Masao <masao.fujii@oss.nttdata.com>

From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Kazutaka Onishi <onishi@heterodb.com>
Cc: Amit Langote <amitlangote09@gmail.com>, Ibrar Ahmed <ibrar.ahmad@gmail.com>, Kohei KaiGai <kaigai@heterodb.com>, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>, Zhihong Yu <zyu@yugabyte.com>, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Date: 2021-03-29T17:53:57Z
Lists: pgsql-hackers

On 2021/03/28 2:37, Kazutaka Onishi wrote:
> Fujii-san,
> 
> Thank you for your review!
> Now I prepare v5 patch and I'll answer to your each comment. please
> check this again.

Thanks a lot!

> 5. For example, we can easily do that by truncate foreign tables
> before local ones. Thought?
> 
> Umm... yeah, I feel it's better procedure, but not so required because
> TRUNCATE is NOT called frequently.
> Certainly, we already have postgresIsForeignUpdatable() to check
> whether the foreign table is updatable or not.
> Following this way, we have to add postgresIsForeignTruncatable() to check.
> However, Unlike UPDATE, TRUNCATE is NOT called frequently. Current
> procedure is inefficient but works correctly.
> Thus, I feel postgresIsForeignTruncatable() is not needed.

I'm concerned about the case where permission errors at the remote servers
rather than that truncatable option is disabled. The comments of
ExecuteTruncate() explains its design as follows. But the patch seems to break
this because it truncates the local tables before checking the permission on
foreign tables (i.e., the local tables in remote servers)... No?

     We first open and grab exclusive
     lock on all relations involved, checking permissions and otherwise
     verifying that the relation is OK for truncation
     Finally all the relations are truncated and reindexed.

Regards,

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



Commits

  1. doc: Review for "Allow TRUNCATE command to truncate foreign tables".

  2. Don't pass "ONLY" options specified in TRUNCATE to foreign data wrapper.

  3. Support tab-complete for TRUNCATE on foreign tables.

  4. Allow TRUNCATE command to truncate foreign tables.

  5. Add support for asynchronous execution.