Re: [HACKERS] Design for In-Core Logical Replication

From: Dmitriy Sarafannikov <d(dot)sarafannikov(at)bk(dot)ru>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Design for In-Core Logical Replication
Date: 2016-07-22 08:54:28
Message-ID: 1469177668.702647656@f413.i.mail.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


><programlisting>
>CREATE PUBLICATION mypub;
>ALTER PUBLICATION mypub ADD TABLE users, departments;

>CREATE SUBSCRIPTION mysub WITH CONNECTION <quote>dbname=foo host=bar user=repuser</quote> PUBLICATION mypub;

>    The above will start the replication process which synchronizes the
>    initial table contents of <literal>users</literal> and
>    <literal>departments</literal> tables and then starts replicating
>    incremental changes to those tables.

Hi, hackers.

it is very good to have logical replication in core. Also i have some proposal. What if we would have ability to execute custom trigger functions on events on particular table? Also it would be useful if would have ability to ignore some tables in publication or replicatie with some WHERE condition. For example, we want replicate table "users" as is (maybe with some WHERE conditions), but on events on table "departments" we want execute trigger function departments_event_handler(). And we don't want handle events on third table which was added to publication.

Something like this:

CREATE PUBLICATION mypub;
ALTER PUBLICATION mypub ADD TABLE users, departments, unnecessary_tbl;

CREATE SUBSCRIPTION mysub WITH CONNECTION <quote>dbname=foo host=bar user=repuser</quote> PUBLICATION mypub;
ALTER SUBSCRIPTION mysub ADD TABLE users REPLICATE TO LOCAL TABLE my_users INSERT WHERE new.id_user > 1000 UPDATE WHERE old.id_user < 1000; -- we don't want replicate deletes, for example.
ALTER SUBSCRIPTION mysub ADD TABLE departments ON INSERT WHEN (new.id_user > 1000) EXECUTE PROCEDURE departments_event_handler(); -- just like trigger

Regards,
Dmitriy Sarafannikov

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2016-07-22 09:01:25 Re: freeze map open item
Previous Message Amit Langote 2016-07-22 08:35:48 Re: Constraint merge and not valid status