From: | Craig Ringer <craig(at)2ndquadrant(dot)com> |
---|---|
To: | Euler Taveira <euler(at)timbira(dot)com(dot)br> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: row filtering for logical replication |
Date: | 2018-03-01 00:54:58 |
Message-ID: | CAMsr+YHhMuHn-buDW2FiEw7xZibJjXpTQybZFKfbwLcBNaNAdg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 1 March 2018 at 07:03, Euler Taveira <euler(at)timbira(dot)com(dot)br> wrote:
> Hi,
>
> The attached patches add support for filtering rows in the publisher.
> The output plugin will do the work if a filter was defined in CREATE
> PUBLICATION command. An optional WHERE clause can be added after the
> table name in the CREATE PUBLICATION such as:
>
> CREATE PUBLICATION foo FOR TABLE departments WHERE (id > 2000 AND id <=
> 3000);
>
> Row that doesn't match the WHERE clause will not be sent to the
> subscribers.
>
> Patches 0001 and 0002 are only refactors and can be applied
> independently. 0003 doesn't include row filtering on initial
> synchronization.
>
Good idea. I haven't read this yet, but one thing to make sure you've
handled is limiting the clause to referencing only the current tuple and
the catalogs. user-catalog tables are OK, too, anything that is
RelationIsAccessibleInLogicalDecoding().
This means only immutable functions may be invoked, since a stable or
volatile function might attempt to access a table. And views must be
prohibited or recursively checked. (We have tree walkers that would help
with this).
It might be worth looking at the current logic for CHECK expressions, since
the requirements are similar. In my opinion you could safely not bother
with allowing access to user catalog tables in the filter expressions and
limit them strictly to immutable functions and the tuple its self.
--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Langote | 2018-03-01 00:57:47 | Re: ON CONFLICT DO UPDATE for partitioned tables |
Previous Message | Andrew Dunstan | 2018-03-01 00:49:52 | Re: VPATH build from a tarball fails with some gmake versions |