Re: row filtering for logical replication - Mailing list pgsql-hackers
From | Amit Kapila |
---|---|
Subject | Re: row filtering for logical replication |
Date | |
Msg-id | CAA4eK1+3Fc8F0e1GANKU7AHMDa1W+D1Ug7RBCdDhBr2wZcmPvg@mail.gmail.com Whole thread Raw |
In response to | Re: row filtering for logical replication ("Euler Taveira" <euler@eulerto.com>) |
List | pgsql-hackers |
On Wed, Mar 31, 2021 at 7:17 AM Euler Taveira <euler@eulerto.com> wrote: > > On Tue, Mar 30, 2021, at 8:23 AM, Amit Kapila wrote: > > On Mon, Mar 29, 2021 at 6:47 PM Euler Taveira <euler@eulerto.com> wrote: > > > Few comments: > ============== > 1. How can we specify row filters for multiple tables for a > publication? Consider a case as below: > > It is not possible. Row filter is a per table option. Isn't it clear from the > synopsis? > Sorry, it seems I didn't read it properly earlier, now I got it. > > 2. > + /* > + * Although ALTER PUBLICATION grammar allows WHERE clause to be specified > + * for DROP TABLE action, it doesn't make sense to allow it. We implement > + * this restriction here, instead of complicating the grammar to enforce > + * it. > + */ > + if (stmt->tableAction == DEFELEM_DROP) > + { > + ListCell *lc; > + > + foreach(lc, stmt->tables) > + { > + PublicationTable *t = lfirst(lc); > + > + if (t->whereClause) > + ereport(ERROR, > + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), > + errmsg("cannot use a WHERE clause when removing table from > publication \"%s\"", > + NameStr(pubform->pubname)))); > + } > + } > > Is there a reason to deal with this here separately rather than in the > ALTER PUBLICATION grammar? > > Good question. IIRC the issue is that AlterPublicationStmt->tables has a list > element that was a relation_expr_list and was converted to > publication_table_list. If we share 'tables' with relation_expr_list (for ALTER > PUBLICATION ... DROP TABLE) and publication_table_list (for the other ALTER > PUBLICATION ... ADD|SET TABLE), the OpenTableList() has to know what list > element it is dealing with. I think I came to the conclusion that it is less > uglier to avoid changing OpenTableList() and CloseTableList(). > > [Doing some experimentation...] > > Here is a patch that remove the referred code. > Thanks, few more comments: 1. In pgoutput_change, we are always sending schema even though we don't send actual data because of row filters. It may not be a problem in many cases but I guess for some odd cases we can avoid sending extra information. 2. In get_rel_sync_entry(), we are caching the qual for rel_sync_entry even though we won't publish it which seems unnecessary? 3. @@ -1193,5 +1365,11 @@ rel_sync_cache_publication_cb(Datum arg, int cacheid, uint32 hashvalue) entry->pubactions.pubupdate = false; entry->pubactions.pubdelete = false; entry->pubactions.pubtruncate = false; + + if (entry->qual != NIL) + list_free_deep(entry->qual); Seeing one previous comment in this thread [1], I am wondering if list_free_deep is enough here? 4. Can we write explicitly in the docs that row filters won't apply for Truncate operation? 5. Getting some whitespace errors: git am /d/PostgreSQL/Patches/logical_replication/row_filter/v14-0001-Row-filter-for-logical-replication.patch .git/rebase-apply/patch:487: trailing whitespace. warning: 1 line adds whitespace errors. Applying: Row filter for logical replication [1] - https://www.postgresql.org/message-id/20181123161933.jpepibtyayflz2xg%40alvherre.pgsql -- With Regards, Amit Kapila.
pgsql-hackers by date: