Re: Column Filtering in Logical Replication

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Cc: Rahila Syed <rahilasyed90(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Column Filtering in Logical Replication
Date: 2021-12-16 20:10:58
Message-ID: 202112162010.ymgkkpxxurvo@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2021-12-16 20:11:18 Re: row filtering for logical replication
Previous Message Jacob Champion 2021-12-16 19:56:25 Re: Support for NSS as a libpq TLS backend