Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h2DOD-0001ZM-NS for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Mar 2019 11:10:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h2DOC-0002RD-Au for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Mar 2019 11:10:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h2DOC-0002R6-3o for pgsql-hackers@lists.postgresql.org; Fri, 08 Mar 2019 11:10:08 +0000 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h2DO5-0004q0-Go for pgsql-hackers@lists.postgresql.org; Fri, 08 Mar 2019 11:10:07 +0000 Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id x28B9uYc004646; Fri, 8 Mar 2019 20:09:56 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id B88A0639105; Fri, 8 Mar 2019 20:09:56 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id A33E8638E82; Fri, 8 Mar 2019 20:09:56 +0900 (JST) Received: from [IPv6:::1] (unknown [129.60.241.75]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 9CA0A400B07; Fri, 8 Mar 2019 20:09:56 +0900 (JST) Message-ID: <5C824D63.4040601@lab.ntt.co.jp> Date: Fri, 08 Mar 2019 20:09:23 +0900 From: Etsuro Fujita User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 Subject: Re: Update does not move row across foreign partitions in v11 References: <20190227193114.GA19279@alvherre.pgsql> <14069ba3-20bb-529b-f104-4e282dc3e322@lab.ntt.co.jp> <5C7F46CC.6010801@lab.ntt.co.jp> <396fc4ca-eeba-e8af-cd72-90861469d3da@lab.ntt.co.jp> <5C7F645E.2080805@lab.ntt.co.jp> <16381946-c020-7099-f8fc-f5a8e11d6fb5@lab.ntt.co.jp> <5C810FF7.8010802@lab.ntt.co.jp> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CC-Mail-RelayStamp: 1 To: David Rowley Cc: Amit Langote , PostgreSQL Hackers , Robert Haas , Alvaro Herrera , Derek Hans X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk (2019/03/08 19:29), David Rowley wrote: > On Fri, 8 Mar 2019 at 15:07, Amit Langote wrote: >> David, can you confirm if the rewritten text reads unambiguous or perhaps >> suggest a better wording? > > So this is the text: > > + Currently, rows cannot be moved from a foreign-table partition to some > + other partition, but they can be moved into a foreign-table partition if > + the foreign data wrapper supports tuple routing. > > I read this to mean that rows cannot normally be moved out of a > foreign-table partition unless the new partition is a foreign one that > uses an FDW that supports tuple routing. > > So let's test that: > > create extension postgres_fdw ; > do $$ begin execute 'create server loopback foreign data wrapper > postgres_fdw options (dbname ''' || current_database() || ''');'; end; > $$; > create user mapping for current_user server loopback; > > create table listp (a int) partition by list (a); > create table listp1 (a int, check (a = 1)); > create table listp2 (a int, check (a = 2)); > > create foreign table listpf1 partition of listp for values in (1) > server loopback options (table_name 'listp1'); > create foreign table listpf2 partition of listp for values in (2) > server loopback options (table_name 'listp2'); > > insert into listp values (1); > > update listp set a = 2 where a = 1; > ERROR: new row for relation "listp1" violates check constraint "listp1_a_check" > DETAIL: Failing row contains (2). > CONTEXT: remote SQL command: UPDATE public.listp1 SET a = 2 WHERE ((a = 1)) > > I'd be filing a bug report for that as I'm moving a row into a foreign > table with an FDW that supports tuple routing. Fair enough. > Where I think you're going wrong is, in one part of the sentence > you're talking about UPDATE, then in the next part you seem to > magically jump to talking about INSERT. Since the entire paragraph is > talking about UPDATE, why is it relevant to talk about INSERT? > > I thought my doc_confirm_foreign_partition_limitations.patch had this > pretty clear with: > > + > + > + Currently, anUPDATE of a partitioned table cannot > + move rows out of a foreign partition into another partition. > + > + > > Or is my understanding of this incorrect? IMO I think it's better that we also mention that the UPDATE can move rows into a foreign partition if the FDW supports it. No? > I also think the new > paragraph is a good move as it's a pretty restrictive limitation for > anyone that wants to set up a partition hierarchy with foreign > partitions. +1 Best regards, Etsuro Fujita