Re: Support logical replication of DDLs

From: Zheng Li <zhengli10(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Peter Smith <smithpb2250(at)gmail(dot)com>, Ajin Cherian <itsajin(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, li jie <ggysxcq(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>, Japin Li <japinli(at)hotmail(dot)com>, rajesh singarapu <rajesh(dot)rs0541(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Support logical replication of DDLs
Date: 2023-02-22 23:01:19
Message-ID: CAAD30UKUZA3Ky77yhozPJMQCjOjAvBq4EA+Q6J0figs98GaByg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

> > From the user perspective, I expect that the replicated objects are
> > created on the subscriber by the same owner as the publisher, by
> > default.
>
> OK, I agree. I think the use cases for matching the owner are likely
> more than the other way around. I can make the subscription option
> "match_ddl_owner" on by default in the next version.

> > > > Now, coming to implementation, won't it be better if we avoid sending
> > > > the owner to the subscriber unless it is changed for the replicated
> > > > command? Consider the current case of tables where we send schema only
> > > > if it is changed. This is not a direct mapping but it would be better
> > > > to avoid sending additional information and then process it on the
> > > > subscriber for each command.
> > >
> > > Right, we can do some optimization here: only send the owner for
> > > commands that create objects (CREATE TABLE/FUNCTION/INDEX etc.) Note
> > > that ALTER TABLE/OBJECT OWNER TO is replicated so we don't need to
> > > worry about owner change.
> >
> > What role will be used for executing ALTER and DROP commands on the
> > subscriber? the subscription owner?
>
> Yes, I think DROP and ALTER commands (and other non-CREATE commands)
> can be executed by the subscription owner (superuser).

Attached please find the new patch set with the following changes:
1. Changed the default value of the subscription option "match_ddl_owner" to on.
2. Changed deparser logic to only include the owner for commands that
create objects.
3. Addressed a merge conflict with a recent commit in pg_proc.dat.

Regards,
Zane

Attachment Content-Type Size
v72-0001-Infrastructure-to-support-DDL-deparsing.patch application/octet-stream 44.3 KB
v72-0003-Support-DDL-deparse-of-the-rest-commands.patch application/octet-stream 201.2 KB
v72-0005-DDL-messaging-infrastructure-for-DDL-replication.patch application/octet-stream 41.5 KB
v72-0004-Introduce-the-test_ddl_deparse_regress-test-module.patch application/octet-stream 47.3 KB
v72-0002-Functions-to-deparse-Table-DDL-commands.patch application/octet-stream 131.2 KB
v72-0007-Document-DDL-replication-and-DDL-deparser.patch application/octet-stream 40.6 KB
v72-0006-Support-DDL-replication.patch application/octet-stream 213.1 KB
v72-0008-Allow-replicated-objects-to-have-the-same-owner-from.patch application/octet-stream 59.0 KB

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Neethu P 2023-02-23 04:10:19 Re: Event Triggers unable to capture the DDL script executed
Previous Message Adrian Klaver 2023-02-22 17:21:23 Re: Debugging postgres on Windows - could not open directory "/lib"

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2023-02-22 23:23:44 buildfarm + meson
Previous Message Andres Freund 2023-02-22 22:47:13 Re: PG 15 (and to a smaller degree 14) regression due to ExprEvalStep size