RE: row filtering for logical replication

From: "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Ajin Cherian <itsajin(at)gmail(dot)com>, Euler Taveira <euler(at)eulerto(dot)com>, Greg Nancarrow <gregn4422(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Rahila Syed <rahilasyed90(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Önder Kalacı <onderkalaci(at)gmail(dot)com>, japin <japinli(at)hotmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, David Steele <david(at)pgmasters(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: RE: row filtering for logical replication
Date: 2021-12-20 03:10:58
Message-ID: OS0PR01MB5716BBB443019ED97FC48A0C947B9@OS0PR01MB5716.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 17, 2021 6:09 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> On Fri, Dec 17, 2021 at 4:11 AM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
> >
> > PSA the v47* patch set.
> >
>
> Few comments on v47-0002:
> =======================
> 1. The handling to find rowfilter for ancestors in
> RelationGetInvalidRowFilterCol seems complex. It seems you are
> accumulating non-partition relations as well in toprelid_in_pub. Can
> we simplify such that we find the ancestor only for 'pubviaroot'
> publications?
>
> 2. I think the name RelationGetInvalidRowFilterCol is confusing
> because the same function is also used to get publication actions. Can
> we name it as GetRelationPublicationInfo() and pass a bool parameter
> to indicate whether row_filter info needs to be built. We can get the
> invalid_row_filter column as output from that function.
>
> 3.
> +GetRelationPublicationActions(Relation relation)
> {
> ..
> + if (!relation->rd_pubactions)
> + (void) RelationGetInvalidRowFilterCol(relation);
> +
> + return memcpy(pubactions, relation->rd_pubactions,
> + sizeof(PublicationActions));
> ..
> ..
> }
>
> I think here we can reverse the check such that if actions are set
> just do memcpy and return otherwise get the relationpublicationactions
> info.
>
> 4.
> invalid_rowfilter_column_walker
> {
> ..
>
> /*
> * If pubviaroot is true, we need to convert the column number of
> * parent to the column number of child relation first.
> */
> if (context->pubviaroot)
> {
> char *colname = get_attname(context->parentid, attnum, false);
> attnum = get_attnum(context->relid, colname);
> }
>
> Here, in the comments, you can tell why you need this conversion. Can
> we name this function as rowfilter_column_walker()?
>
> 5.
> +/* For invalid_rowfilter_column_walker. */
> +typedef struct {
> + AttrNumber invalid_rfcolnum; /* invalid column number */
> + Bitmapset *bms_replident; /* bitset of replica identity col indexes */
> + bool pubviaroot; /* true if we are validating the parent
> + * relation's row filter */
> + Oid relid; /* relid of the relation */
> + Oid parentid; /* relid of the parent relation */
> +} rf_context;
>
> Normally, we declare structs at the beginning of the file and for the
> formatting of struct declarations, see other nearby structs like
> RelIdCacheEnt.
>
> 6. Can we name IsRowFilterSimpleNode() as IsRowFilterSimpleExpr()?

Thanks for the comments, I agree with all the comments.
Attach the V49 patch set, which addressed all the above comments on the 0002
patch.

Best regards,
Hou zj

Attachment Content-Type Size
v49-0001-Row-filter-for-logical-replication.patch application/octet-stream 91.2 KB
v49-0003-Row-filter-updates-based-on-old-new-tuples.patch application/octet-stream 21.5 KB
v49-0004-Row-filter-tab-auto-complete-and-pgdump.patch application/octet-stream 5.6 KB
v49-0005-Row-filter-handle-FOR-ALL-TABLES.patch application/octet-stream 14.1 KB
v49-0002-Row-filter-validation.patch application/octet-stream 63.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message kuroda.hayato@fujitsu.com 2021-12-20 03:20:55 RE: [PATCH] pg_stat_toast
Previous Message Masahiko Sawada 2021-12-20 03:03:01 Re: parallel vacuum comments