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 1nj0wu-0006T0-Cs for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Apr 2022 15:48:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nj0ws-00047O-5t for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Apr 2022 15:48:26 +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 1nj0wr-00047F-Su for pgsql-hackers@lists.postgresql.org; Mon, 25 Apr 2022 15:48:25 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nj0wp-0005nw-Bk for pgsql-hackers@lists.postgresql.org; Mon, 25 Apr 2022 15:48:24 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 30ADC3201E3E for ; Mon, 25 Apr 2022 11:48:22 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 25 Apr 2022 11:48:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1650901701; x= 1650988101; bh=nQzscR94blhwLX4sE0CkczTCM72Zd+Fkxah/cs+LwAI=; b=k yLblH5sCtLFQZjs259XZ56YYxBqgK2vIBCF1+13RcBbymhxGJtP2teSnU9oIvM2Q OtmiY9gC0+SCnK2yk13jHvYYIk1cnX9oQSrrJkx7OqtRTot1HgwJvpnxF4Kp+HuU B7mCKCDUBbRfsGfrRjnsb/q9JLsvbvxgCBEi0wzirAqtbZhNjiliVcGs66VZIdFS NHLqxxS7qkxioHoYdCFpFSTpzHvZghOFfv/YvGDLGSEpbbU5WRSOmr7M2XTZJpSw 24+dEBaWkH60An0qVn4AkpWRLCbzw0lbKcNUDRkpnRpuZk0pp57vh4hFr47Vc97r +kMyldUwZkvFbCUxhvvOQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedruddugdelvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkgggtugfgsehtkeertddttdejnecuhfhrohhmpeetlhhvrghrohcu jfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqeenuc ggtffrrghtthgvrhhnpefhjeehvdeghfdufeeigfdttdduteduvdegvefhvdeufedvtefg hfehffduhffgjeenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghr rhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Mon, 25 Apr 2022 11:48:21 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id C45952A1510; Mon, 25 Apr 2022 17:48:18 +0200 (CEST) Date: Mon, 25 Apr 2022 17:48:18 +0200 From: Alvaro Herrera To: Pg Hackers Subject: bogus: logical replication rows/cols combinations Message-ID: <202204251548.mudq7jbqnh7r@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I just noticed that publishing tables on multiple publications with different row filters and column lists has somewhat surprising behavior. To wit: if a column is published in any row-filtered publication, then the values for that column are sent to the subscriber even for rows that don't match the row filter, as long as the row matches the row filter for any other publication, even if that other publication doesn't include the column. Here's an example. Publisher: create table uno (a int primary key, b int, c int); create publication uno for table uno (a, b) where (a > 0); create publication dos for table uno (a, c) where (a < 0); Here, we specify: publish columns a,b for rows with positive a, and publish columns a,c for rows with negative a. What happened next will surprise you! Well, maybe not. On subscriber: create table uno (a int primary key, b int, c int); create subscription sub_uno connection 'port=55432 dbname=alvherre' publication uno,dos; Publisher: insert into uno values (1, 2, 3), (-1, 3, 4); Publication 'uno' only has columns a and b, so row with a=1 should not have value c=3. And publication 'dos' only has columns a and c, so row with a=-1 should not have value b=3. But, on subscriber: table uno; a │ b │ c ────┼───┼─── 1 │ 2 │ 3 -1 │ 3 │ 4 q.e.d. I think results from a too simplistic view on how to mix multiple publications with row filters and column lists. IIRC we are saying "if column X appears in *any* publication, then the value is published", period, and don't stop to evaluate the row filter corresponding to each of those publications. The desired result on subscriber is: table uno; a │ b │ c ────┼───┼─── 1 │ 2 │ -1 │ │ 4 Thoughts? -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/