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 1iJYjr-00057E-33 for pgsql-hackers@arkaria.postgresql.org; Sun, 13 Oct 2019 07:56:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iJYiq-00073z-Kl for pgsql-hackers@arkaria.postgresql.org; Sun, 13 Oct 2019 07:55:24 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iJYiq-00073H-7N for pgsql-hackers@lists.postgresql.org; Sun, 13 Oct 2019 07:55:24 +0000 Received: from xvm-110-146.dc2.ghst.net ([46.226.110.146] helo=fetter.org) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1iJYil-0008Mt-H7 for pgsql-hackers@postgresql.org; Sun, 13 Oct 2019 07:55:22 +0000 Received: by fetter.org (Postfix, from userid 1001) id 6A6BD40B14; Sun, 13 Oct 2019 09:55:17 +0200 (CEST) Date: Sun, 13 Oct 2019 09:55:17 +0200 From: David Fetter To: Amit Langote Cc: PostgreSQL-development Subject: Re: adding partitioned tables to publications Message-ID: <20191013075516.GG22891@fetter.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Oct 07, 2019 at 09:55:23AM +0900, Amit Langote wrote: > One cannot currently add partitioned tables to a publication. > > create table p (a int, b int) partition by hash (a); > create table p1 partition of p for values with (modulus 3, remainder 0); > create table p2 partition of p for values with (modulus 3, remainder 1); > create table p3 partition of p for values with (modulus 3, remainder 2); > > create publication publish_p for table p; > ERROR: "p" is a partitioned table > DETAIL: Adding partitioned tables to publications is not supported. > HINT: You can add the table partitions individually. > > One can do this instead: > > create publication publish_p1 for table p1; > create publication publish_p2 for table p2; > create publication publish_p3 for table p3; > > but maybe that's too much code to maintain for users. > > I propose that we make this command: > > create publication publish_p for table p; > > automatically add all the partitions to the publication. Also, any > future partitions should also be automatically added to the > publication. So, publishing a partitioned table automatically > publishes all of its existing and future partitions. Attached patch > implements that. > > What doesn't change with this patch is that the partitions on the > subscription side still have to match one-to-one with the partitions > on the publication side, because the changes are still replicated as > being made to the individual partitions, not as the changes to the > root partitioned table. It might be useful to implement that > functionality on the publication side, because it allows users to > define the replication target any way they need to, but this patch > doesn't implement that. With this patch, is it possible to remove a partition manually from a subscription, or will it just get automatically re-added at some point? Best, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate