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: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Peter Smith <smithpb2250(at)gmail(dot)com>, "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>, Euler Taveira <euler(at)eulerto(dot)com>, Greg Nancarrow <gregn4422(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Ajin Cherian <itsajin(at)gmail(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: 2022-01-20 01:12:48
Message-ID: OS0PR01MB57166208727538BFAE8D10BB945A9@OS0PR01MB5716.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wednesday, January 19, 2022 5:56 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Wed, Jan 19, 2022 at 7:45 AM houzj(dot)fnst(at)fujitsu(dot)com
> <houzj(dot)fnst(at)fujitsu(dot)com> wrote:
> >
> > On Tues, Jan 18, 2022 8:35 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
> wrote:
> >
> > Attach the V67 patch set which address the above comments.
> >
>
> Some more comments and suggestions:
> =================================
> 1. Can we do slot initialization in maybe_send_schema() instead of
> introducing a new flag for it?
>
> 2.
> + * For updates if no old tuple, it means none of the replica identity
> + * columns changed and this would reduce to a simple update. We only need
> + * to evaluate the row filter for the new tuple.
>
> Is it possible with the current version of the patch? I am asking
> because, for updates, we now allow only RI columns in row filter, so
> do we need to evaluate the row filter in this case? I think ideally,
> we don't need to evaluate the row filter in this case as for updates
> only replica identity columns are allowed but users can use constant
> expressions in the row filter. So, we need to evaluate the row filter
> in this case as well. Is my understanding correct?
>
> 3. + /* If no filter found, clean up the memory and return */
> + if (!has_filter)
> + {
> + if (entry->cache_expr_cxt != NULL)
> + MemoryContextDelete(entry->cache_expr_cxt);
>
> I think this clean-up needs to be performed when we set
> exprstate_valid to false. I have changed accordingly in the attached
> patch.
>
> Apart from the above, I have made quite a few changes in the code
> comments in the attached top-up patch, kindly review those and merge
> them into the main patch, if you are okay with it.

Thanks for the comments and changes.
Attach the V68 patch set which addressed the above comments and changes.
The version patch also fix the error message mentioned by Greg[1]

[1] https://www.postgresql.org/message-id/CAJcOf-f9DBXMvutsxW_DBLu7bepKP1e4BGw4bwiC%2BzwsK4Q0Wg%40mail.gmail.com

Best regards,
Hou zj

Attachment Content-Type Size
v68-0001-Allow-specifying-row-filter-for-logical-replication-.patch application/octet-stream 150.3 KB
v68-0002-Row-filter-tab-auto-complete-and-pgdump.patch application/octet-stream 6.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message James Coleman 2022-01-20 01:14:10 Re: Document atthasmissing default optimization avoids verification table scan
Previous Message Japin Li 2022-01-20 00:55:45 Re: Remove redundant MemoryContextSwith in BeginCopyFrom