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 1if4E5-0004Ek-Lo for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Dec 2019 15:48:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1if4E4-0003Wj-ED for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Dec 2019 15:48:32 +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 1if4E4-0003Wc-1H for pgsql-hackers@lists.postgresql.org; Wed, 11 Dec 2019 15:48:32 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1if4E1-0004bh-BE for pgsql-hackers@postgresql.org; Wed, 11 Dec 2019 15:48:30 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id A3EB8B3B; Wed, 11 Dec 2019 10:48:27 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Wed, 11 Dec 2019 10:48:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=llqadmJvuaXnJwk3YIYD7VADuyQojV8sUx5Qyhz8l co=; b=RFSCiXdsDNR1VYAv6p75daB8Zg2BwWkpiuz0MFAOptaXfbdl+Q8neNccP MCXwcPm3REL2AiO3bttZokpFYb8a/OXCWFQ9NTE//1e5VdWEQ6ZCAYHJeTXJbCED zEBSbyy6KxJadMylMNZza0I9XGH5B6+HtZaGWzC8ZRTf3Ovxczk5SBkD2b6lpzLJ fIYfp/qJI6MqOpN849OVc61IKLaHmaBbiekKwKzcqqnw3/c2HYeAUhHorQw1Xokw Eb26GmFkcHMXlbaWhOApj2K7/uua03ryaSQy69DN8chYdZBUWSgOd0eYrjbeb0JB CjJvaBrv7nUyoLGyJ5ZonSexIJeyQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudelhedgjeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhohfkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpefrvght vghrucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvdhnug hquhgrughrrghnthdrtghomheqnecuffhomhgrihhnpedvnhguqhhurggurhgrnhhtrdgt ohhmnecukfhppeelfedrvdegfedrfeegrdelleenucfrrghrrghmpehmrghilhhfrhhomh epphgvthgvrhdrvghishgvnhhtrhgruhhtsedvnhguqhhurggurhgrnhhtrdgtohhmnecu vehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from april.pezone.net (p5df32263.dip0.t-ipconnect.de [93.243.34.99]) by mail.messagingengine.com (Postfix) with ESMTPA id E9A7880059; Wed, 11 Dec 2019 10:48:25 -0500 (EST) Subject: Re: adding partitioned tables to publications To: Amit Langote References: <037d3133-1689-108c-360d-b782e3209cfb@2ndquadrant.com> <7a23e60b-ffe8-bce1-5c44-db48d3bc163e@2ndquadrant.com> Cc: Rafia Sabih , PostgreSQL-development From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Wed, 11 Dec 2019 16:48:25 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-12-06 08:48, Amit Langote wrote: > 0001: Adding a partitioned table to a publication implicitly adds all > its partitions. The receiving side must have tables matching the > published partitions, which is typically the case, because the same > partition tree is defined on both nodes. This looks pretty good to me now. But you need to make all the changed queries version-aware so that you can still replicate from and to older versions. (For example, pg_partition_tree is not very old.) This part looks a bit fishy: + /* + * If either table is partitioned, skip copying. Individual partitions + * will be copied instead. + */ + if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE || + remote_relkind == RELKIND_PARTITIONED_TABLE) + { + logicalrep_rel_close(relmapentry, NoLock); + return; + } I don't think you want to filter out a partitioned table on the local side, since (a) COPY can handle that, and (b) it's (as of this patch) an error to have a partitioned table in the subscription table set. I'm not a fan of the new ValidateSubscriptionRel() function. It's too obscure, especially the return value. Doesn't seem worth it. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services