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 1mxx5u-0001kx-5f for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Dec 2021 20:11:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mxx5r-0005hU-MG for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Dec 2021 20:11:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxx5r-0005dQ-CE for pgsql-hackers@lists.postgresql.org; Thu, 16 Dec 2021 20:11:11 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxx5n-0006Jt-G5 for pgsql-hackers@postgresql.org; Thu, 16 Dec 2021 20:11:10 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id BCC8732009BD; Thu, 16 Dec 2021 15:11:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 16 Dec 2021 15:11:04 -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:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=Rp/+JTN70BU38GXxKV1MbDXaxGMZfSeisLLO+rkjU90=; b=RmymXmVF XO4QrpUwq4uHVbv/OzMiZHBM2Qcm3IIhfHVjkjzODjThkssJireC+wzKcQWolCBP i3ZWkyaBtenwL8JuQNjzWOoayJweXKzfkMom6Z5KIfH5FFQeAVJx61/7jDlawG+w /MnlPJQ63bbThgy/0jmc17MoNrjEYBWBW1p05+vjRTz/kx6AEYtYV8Ppx04CJtHA Iro84SSUDyQ1ENqLoEOdNxf6BK+JGUHtXhF7MvR+OCwJMBHcAMkJCNZY59sjYo8I N6zShzNdYwX+D7YOHjn9afla+iEHSePNVspDqmFk2WZ2exR5Jknwvr5sFtYbTFTw 78v0J+yVtSFk1Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrleeggddufeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedujeevjeffjeevuddutedvkeeiueeitddvieelfeekveej udefgeeuvdejhfeuleenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 16 Dec 2021 15:11:01 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id D9BA72A07D0; Thu, 16 Dec 2021 17:10:58 -0300 (-03) Date: Thu, 16 Dec 2021 17:10:58 -0300 From: Alvaro Herrera To: Tomas Vondra Cc: Rahila Syed , Amit Kapila , Peter Smith , PostgreSQL-development Subject: Re: Column Filtering in Logical Replication Message-ID: <202112162010.ymgkkpxxurvo@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <09c9824d-e533-098f-6c2e-3712619531e2@enterprisedb.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Dec-14, Tomas Vondra wrote: > 7) There's a couple places doing this > > if (att_map != NULL && > !bms_is_member(att->attnum - FirstLowInvalidHeapAttributeNumber, > att_map) && > !bms_is_member(att->attnum - FirstLowInvalidHeapAttributeNumber, > idattrs) && > !replidentfull) > > which is really hard to understand (even if we get rid of the offset), so > maybe let's move that to a function with sensible name. Also, some places > don't check indattrs - seems a bit suspicious. It is indeed pretty hard to read ... but I think this is completely unnecessary. Any column that is part of the identity should have been included in the column filter, so there is no need to check for the identity attributes separately. Testing just for the columns in the filter ought to be sufficient; and the cases "if att_map NULL" and "is replica identity FULL" are also equivalent, because in the case of FULL, you're disallowed from setting a column list. So this whole thing can be reduced to just this: if (att_map != NULL && !bms_is_member(att->attnum, att_map)) continue; /* that is, don't send this attribute */ so I don't think this merits a separate function. [ says he, after already trying to write said function ] -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "Before you were born your parents weren't as boring as they are now. They got that way paying your bills, cleaning up your room and listening to you tell them how idealistic you are." -- Charles J. Sykes' advice to teenagers