Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lZE33-0004sr-Iq for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Apr 2021 14:41:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lZE32-0001WO-1v for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Apr 2021 14:41:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lZE31-0001WH-RS for pgsql-hackers@lists.postgresql.org; Wed, 21 Apr 2021 14:41:47 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lZE2w-0001VJ-KZ for pgsql-hackers@lists.postgresql.org; Wed, 21 Apr 2021 14:41:46 +0000 Received: from hnk.local (p2043043-ipbf1801funabasi.chiba.ocn.ne.jp [221.185.194.43]) by oss.nttdata.com (Postfix) with ESMTPSA id 3CC1D6286B; Wed, 21 Apr 2021 23:41:39 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at oss.nttdata.com Subject: Re: TRUNCATE on foreign table To: Kyotaro Horiguchi Cc: bharath.rupireddyforpostgres@gmail.com, kaigai@heterodb.com, onishi@heterodb.com, zyu@yugabyte.com, amitlangote09@gmail.com, ibrar.ahmad@gmail.com, pgsql-hackers@lists.postgresql.org, ashutosh.bapat.oss@gmail.com References: <2ec345ad-9a7b-a21f-8a1b-04c0537ea9b8@oss.nttdata.com> <20210416.142038.1014060495853980509.horikyota.ntt@gmail.com> From: Fujii Masao Message-ID: <8516f26c-79e3-a461-32b6-30995fde008f@oss.nttdata.com> Date: Wed, 21 Apr 2021 23:41:38 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <20210416.142038.1014060495853980509.horikyota.ntt@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021/04/16 14:20, Kyotaro Horiguchi wrote: > At Fri, 16 Apr 2021 11:54:16 +0900, Fujii Masao wrote in >> On 2021/04/16 9:15, Bharath Rupireddy wrote: >>> On Thu, Apr 15, 2021 at 8:19 PM Fujii Masao >>> wrote: >>>> On 2021/04/14 12:54, Bharath Rupireddy wrote: >>>>> IMHO, we can push all the TRUNCATE options (ONLY, RESTRICTED, CASCADE, >>>>> RESTART/CONTINUE IDENTITY), because it doesn't have any major >>>>> challenge(implementation wise) unlike pushing some clauses in >>>>> SELECT/UPDATE/DELETE and we already do this on the master. It doesn't >>>>> look good and may confuse users, if we push some options and restrict >>>>> others. We should have an explicit note in the documentation saying we >>>>> push all these options to the remote server. We can leave it to the >>>>> user to write TRUNCATE for foreign tables with the appropriate >>>>> options. If somebody complains about a problem that they will face >>>>> with this behavior, we can revisit. >>>> >>>> That's one of the options. But I'm afraid it's hard to drop (revisit) >>>> the feature once it has been released. So if there is no explicit >>>> use case for that, basically I'd like to drop that before release >>>> like we agree to drop unused TRUNCATE_REL_CONTEXT_CASCADING. >>> Thanks. Looks like the decision is going in the direction of >>> restricting those options, I will withdraw my point. >> >> We are still discussing whether RESTRICT option should be pushed down to >> a foreign data wrapper. But ISTM at least we could reach the consensus about >> the drop of extra information for each foreign table. So what about applying >> the attached patch and remove the extra information at first? > > I'm fine with that direction. Thanks for the patch. > > The change is straight-forward and looks fine, except the following > part. > > ==== contrib/postgres_fdw/sql/postgres_fdw.sql: 2436 -- after patching > 2436> -- in case when remote table has inherited children > 2437> CREATE TABLE tru_rtable0_child () INHERITS (tru_rtable0); > 2438> INSERT INTO tru_rtable0 (SELECT x FROM generate_series(5,9) x); > 2439> INSERT INTO tru_rtable0_child (SELECT x FROM generate_series(10,14) x); > 2440> SELECT sum(id) FROM tru_ftable; -- 95 > 2441> > 2442> TRUNCATE ONLY tru_ftable; -- truncate both parent and child > 2443> SELECT count(*) FROM tru_ftable; -- 0 > 2444> > 2445> INSERT INTO tru_rtable0 (SELECT x FROM generate_series(21,25) x); > 2446> SELECT sum(id) FROM tru_ftable; -- 115 > 2447> TRUNCATE tru_ftable; -- truncate both of parent and child > 2448> SELECT count(*) FROM tru_ftable; -- 0 > > L2445-L2448 doesn't work as described since L2445 inserts tuples only > to the parent. > > And there's a slight difference for no reason between the comment at > 2442 and 2447. Agreed. Thanks! > (The attached is a fix on top of the proposed patch.) I will include this patch into the main patch. Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION