Re: Support logical replication of DDLs

2022-07-31 Thread Peter Smith
FYI, I found that the v14-0001 patch does not currently apply [1]. Can you please rebase it? -- [1] http://cfbot.cputube.org/patch_38_3595.log Kind Regards, Peter Smith. Fujitsu Australia

Re: Support logical replication of DDLs

2022-07-25 Thread Amit Kapila
On Sat, Jul 23, 2022 at 2:49 AM Zheng Li wrote: > > Hello, > > Here is a patch that supports replication of global object commands, > these include ROLE statements, database statements and tablespace statements. > The patch should be applied on top of the v13 DDL replication patch set that > ZJ

Re: Support logical replication of DDLs

2022-07-23 Thread Zheng Li
On Sat, Jul 23, 2022 at 11:33 AM Joe Conway wrote: > > On 7/22/22 17:18, Zheng Li wrote: > > Here is a patch that supports replication of global object commands, > > these include ROLE statements, database statements and tablespace > > statements. > > The patch should be applied on top of the

Re: Support logical replication of DDLs

2022-07-23 Thread Joe Conway
On 7/22/22 17:18, Zheng Li wrote: Here is a patch that supports replication of global object commands, these include ROLE statements, database statements and tablespace statements. The patch should be applied on top of the v13 DDL replication patch set that ZJ Hou sent in the previous email.

Re: Support logical replication of DDLs

2022-07-22 Thread Zheng Li
Hello, Here is a patch that supports replication of global object commands, these include ROLE statements, database statements and tablespace statements. The patch should be applied on top of the v13 DDL replication patch set that ZJ Hou sent in the previous email. Global objects commands are

Re: Support logical replication of DDLs

2022-07-07 Thread Peter Smith
Here are some review comments for the patch v11-0001: == 1. Commit message This provides base for logical replication of DDL statements. Currently, this provides support for: SUGGESTION This provides a base for logical replication of DDL statements. Currently, the patch has support for:

Re: Support logical replication of DDLs

2022-07-02 Thread vignesh C
On Sat, Jul 2, 2022 at 8:51 AM Amit Kapila wrote: > > On Fri, Jul 1, 2022 at 10:22 PM vignesh C wrote: > > > > On Wed, Jun 29, 2022 at 3:25 PM houzj.f...@fujitsu.com > > wrote: > > > > > > > Thanks for the updated patch. > > Few comments on 0002 patch: > > 1) When we create a subscription for a

Re: Support logical replication of DDLs

2022-07-01 Thread Amit Kapila
On Fri, Jul 1, 2022 at 10:22 PM vignesh C wrote: > > On Wed, Jun 29, 2022 at 3:25 PM houzj.f...@fujitsu.com > wrote: > > > > Thanks for the updated patch. > Few comments on 0002 patch: > 1) When we create a subscription for a publication with the existing > default PUBLISH parameter having

Re: Support logical replication of DDLs

2022-07-01 Thread vignesh C
On Wed, Jun 29, 2022 at 3:25 PM houzj.f...@fujitsu.com wrote: > > On Wednesday, June 29, 2022 11:07 AM Amit Kapila > wrote: > > > > On Tue, Jun 28, 2022 at 5:43 PM Amit Kapila > > wrote: > > > > > > 5. > > > +static ObjTree * > > > +deparse_CreateStmt(Oid objectId, Node *parsetree) > > > { > >

Re: Support logical replication of DDLs

2022-06-30 Thread Amit Kapila
On Thu, Jun 30, 2022 at 11:44 AM Amit Kapila wrote: > > On Wed, Jun 29, 2022 at 3:17 PM houzj.f...@fujitsu.com > wrote: > > > > On Tuesday, June 28, 2022 11:27 AM Amit Kapila > > > > > > +1. I think it doesn't make sense to replicate temporary tables. > > > Similarly, we don't need to replicate

Re: Support logical replication of DDLs

2022-06-30 Thread Amit Kapila
On Wed, Jun 29, 2022 at 3:17 PM houzj.f...@fujitsu.com wrote: > > On Tuesday, June 28, 2022 11:27 AM Amit Kapila > > On Sun, Jun 26, 2022 at 11:47 PM Alvaro Herrera > > wrote: > > > > > > However, that would still replicate a command that involves a > > > temporary table, which perhaps should

Re: Support logical replication of DDLs

2022-06-29 Thread Amit Kapila
On Wed, Jun 29, 2022 at 3:24 PM houzj.f...@fujitsu.com wrote: > > On Wednesday, June 29, 2022 11:07 AM Amit Kapila > wrote: > > > > On Tue, Jun 28, 2022 at 5:43 PM Amit Kapila > > wrote: > > > > > > 5. > > > +static ObjTree * > > > +deparse_CreateStmt(Oid objectId, Node *parsetree) > > > { > >

RE: Support logical replication of DDLs

2022-06-29 Thread houzj.f...@fujitsu.com
On Tuesday, June 28, 2022 11:27 AM Amit Kapila > On Sun, Jun 26, 2022 at 11:47 PM Alvaro Herrera > wrote: > > > > On 2022-Jun-22, vignesh C wrote: > > > > > 1) Creation of temporary table fails infinitely in the subscriber. > > > CREATE TEMPORARY TABLE temp1 (a int primary key); > > > > > > The

Re: Support logical replication of DDLs

2022-06-28 Thread Amit Kapila
On Tue, Jun 28, 2022 at 5:43 PM Amit Kapila wrote: > > 5. > +static ObjTree * > +deparse_CreateStmt(Oid objectId, Node *parsetree) > { > ... > + tmp = new_objtree_VA("TABLESPACE %{tablespace}I", 0); > + if (node->tablespacename) > + append_string_object(tmp, "tablespace", node->tablespacename); >

Re: Support logical replication of DDLs

2022-06-28 Thread vignesh C
On Tue, Jun 21, 2022 at 5:49 PM houzj.f...@fujitsu.com wrote: > > On Monday, June 20, 2022 11:32 AM houzj.f...@fujitsu.com > wrote: > > > > On Saturday, June 18, 2022 3:38 AM Zheng Li wrote: > > > On Wed, Jun 15, 2022 at 12:00 AM Amit Kapila > > > wrote: > > > > > > > > On Wed, Jun 15, 2022

Re: Support logical replication of DDLs

2022-06-28 Thread Amit Kapila
On Tue, Jun 21, 2022 at 5:49 PM houzj.f...@fujitsu.com wrote: > > On Monday, June 20, 2022 11:32 AM houzj.f...@fujitsu.com > wrote: > > > > Attach the new version patch set which added support for CREATE/DROP/ATER > Sequence and CREATE/DROP Schema ddl commands which are provided by Ajin >

Re: Support logical replication of DDLs

2022-06-27 Thread Amit Kapila
On Sun, Jun 26, 2022 at 11:47 PM Alvaro Herrera wrote: > > On 2022-Jun-22, vignesh C wrote: > > > 1) Creation of temporary table fails infinitely in the subscriber. > > CREATE TEMPORARY TABLE temp1 (a int primary key); > > > > The above statement is converted to the below format: > > CREATE

Re: Support logical replication of DDLs

2022-06-26 Thread Alvaro Herrera
On 2022-Jun-22, vignesh C wrote: > 1) Creation of temporary table fails infinitely in the subscriber. > CREATE TEMPORARY TABLE temp1 (a int primary key); > > The above statement is converted to the below format: > CREATE TEMPORARY TABLE pg_temp.temp1 (a pg_catalog.int4 , > CONSTRAINT

Re: Support logical replication of DDLs

2022-06-24 Thread Amit Kapila
On Fri, Jun 24, 2022 at 8:10 AM Masahiko Sawada wrote: > > On Thu, Jun 23, 2022 at 7:00 PM Amit Kapila wrote: > > > > On Wed, Jun 22, 2022 at 11:09 AM Masahiko Sawada > > wrote: > > > > > > I've attached a WIP patch for adding regression tests for DDL deparse. > > > The patch can be applied on

Re: Support logical replication of DDLs

2022-06-23 Thread Masahiko Sawada
On Thu, Jun 23, 2022 at 7:00 PM Amit Kapila wrote: > > On Wed, Jun 22, 2022 at 11:09 AM Masahiko Sawada > wrote: > > > > I've attached a WIP patch for adding regression tests for DDL deparse. > > The patch can be applied on > > v9-0001-Functions-to-deparse-DDL-commands.patch Hou recently > >

Re: Support logical replication of DDLs

2022-06-23 Thread Alvaro Herrera
On 2022-Jun-15, houzj.f...@fujitsu.com wrote: > On Wednesday, June 15, 2022 8:14 AM Zheng Li wrote: > > How does the deparser deparses CREATE FUNCTION STATEMENT? Will it > > schema qualify > > objects inside the function definition? > > The current deparser doesn't schema qualify objects

Re: Support logical replication of DDLs

2022-06-23 Thread Amit Kapila
On Wed, Jun 22, 2022 at 11:09 AM Masahiko Sawada wrote: > > I've attached a WIP patch for adding regression tests for DDL deparse. > The patch can be applied on > v9-0001-Functions-to-deparse-DDL-commands.patch Hou recently > submitted[1]. The basic idea is to define the event trigger to deparse

RE: Support logical replication of DDLs

2022-06-23 Thread houzj.f...@fujitsu.com
On Thursday, June 23, 2022 6:22 AM Zheng Li wrote: Hi, > > > Here are some points in my mind about the two approaches discussed here. > > > > 1) search_patch vs schema qualify > > > > Again, I still think it will bring more flexibility and security by > > schema qualify the objects in DDL

Re: Support logical replication of DDLs

2022-06-22 Thread Zheng Li
> Here are some points in my mind about the two approaches discussed here. > > 1) search_patch vs schema qualify > > Again, I still think it will bring more flexibility and security by schema > qualify the > objects in DDL command as mentioned before[1]. I wonder what security concerns you have?

Re: Support logical replication of DDLs

2022-06-22 Thread vignesh C
On Tue, Jun 21, 2022 at 5:49 PM houzj.f...@fujitsu.com wrote: > > On Monday, June 20, 2022 11:32 AM houzj.f...@fujitsu.com > wrote: > > > > On Saturday, June 18, 2022 3:38 AM Zheng Li wrote: > > > On Wed, Jun 15, 2022 at 12:00 AM Amit Kapila > > > wrote: > > > > > > > > On Wed, Jun 15, 2022

Re: Support logical replication of DDLs

2022-06-21 Thread Masahiko Sawada
On Wed, Jun 15, 2022 at 1:00 PM Amit Kapila wrote: > > On Wed, Jun 15, 2022 at 5:44 AM Zheng Li wrote: > > > > > > While I agree that the deparser is needed to handle the potential > > syntax differences between > > the pub/sub, I think it's only relevant for the use cases where only a > >

RE: Support logical replication of DDLs

2022-06-19 Thread houzj.f...@fujitsu.com
On Saturday, June 18, 2022 3:38 AM Zheng Li wrote: > On Wed, Jun 15, 2022 at 12:00 AM Amit Kapila > wrote: > > > > On Wed, Jun 15, 2022 at 5:44 AM Zheng Li wrote: > > > > > > > > > While I agree that the deparser is needed to handle the potential > > > syntax differences between the pub/sub, I

RE: Support logical replication of DDLs

2022-06-15 Thread houzj.f...@fujitsu.com
On Wednesday, June 15, 2022 8:14 AM Zheng Li wrote: > > > Thanks for providing this idea. > > > > I looked at the string that is used for replication: > > > > """ > > {ALTERTABLESTMT :relation {RANGEVAR :schemaname public :relname foo > > :inh true :relpersistence p :alias <> :location 12} :cmds

Re: Support logical replication of DDLs

2022-06-14 Thread Amit Kapila
On Wed, Jun 15, 2022 at 5:44 AM Zheng Li wrote: > > > While I agree that the deparser is needed to handle the potential > syntax differences between > the pub/sub, I think it's only relevant for the use cases where only a > subset of tables in the database > are replicated. For other use cases

Re: Support logical replication of DDLs

2022-06-14 Thread Zheng Li
> Thanks for providing this idea. > > I looked at the string that is used for replication: > > """ > {ALTERTABLESTMT :relation {RANGEVAR :schemaname public :relname foo > :inh true :relpersistence p :alias <> :location 12} :cmds ({ALTERTABLECMD > :subtype 0 :name <> :num 0 :newowner <> :def

RE: Support logical replication of DDLs

2022-06-13 Thread houzj.f...@fujitsu.com
On Sunday, June 12, 2022 2:46 PM Zheng Li wrote: > > > > > > > I've not looked at these patches in-depth yet but with this > > > > > > approach, what do you think we can handle the DDL syntax > > > > > > differences between major versions? DDL syntax or behavior > > > > > > could be changed by

Re: Support logical replication of DDLs

2022-06-10 Thread Amit Kapila
On Thu, Jun 9, 2022 at 5:14 PM houzj.f...@fujitsu.com wrote: > > Hi, > > I did some research for one potential problem[1] mentioned earlier which is > related > to the function execution when replicating DDL. > > [1]> 4. Statements that have nondeterministic side effects (e.g., as caused > > by

Re: Support logical replication of DDLs

2022-06-03 Thread Amit Kapila
On Thu, Jun 2, 2022 at 5:44 PM houzj.f...@fujitsu.com wrote: > > The main idea of replicating the CREATE TABLE AS is that we deprase the CREATE > TABLE AS into a simple CREATE TABLE(without subquery) command and WAL log it > after creating the table and before writing data into the table and

Re: Support logical replication of DDLs

2022-05-30 Thread Masahiko Sawada
On Fri, May 27, 2022 at 11:03 AM Amit Kapila wrote: > > On Fri, May 27, 2022 at 3:49 AM Zheng Li wrote: > > > > Hi Masahiko, > > > > > Thank you for updating the patches! > > > > > > I've not looked at these patches in-depth yet but with this approach, > > > what do you think we can handle the

Re: Support logical replication of DDLs

2022-05-27 Thread Masahiko Sawada
On Fri, May 27, 2022 at 7:19 AM Zheng Li wrote: > > Hi Masahiko, > > > Thank you for updating the patches! > > > > I've not looked at these patches in-depth yet but with this approach, > > what do you think we can handle the DDL syntax differences between > > major versions? DDL syntax or

Re: Support logical replication of DDLs

2022-05-26 Thread Amit Kapila
On Fri, May 27, 2022 at 3:49 AM Zheng Li wrote: > > Hi Masahiko, > > > Thank you for updating the patches! > > > > I've not looked at these patches in-depth yet but with this approach, > > what do you think we can handle the DDL syntax differences between > > major versions? DDL syntax or

Re: Support logical replication of DDLs

2022-05-26 Thread Zheng Li
Hi Masahiko, > Thank you for updating the patches! > > I've not looked at these patches in-depth yet but with this approach, > what do you think we can handle the DDL syntax differences between > major versions? DDL syntax or behavior could be changed by future > changes and I think we need to

Re: Support logical replication of DDLs

2022-05-26 Thread Masahiko Sawada
On Sat, May 14, 2022 at 6:02 AM Zheng Li wrote: > > > > 4. The handling related to partition tables seems missing because, on > > > the subscriber-side, it always creates a relation entry in > > > pg_subscription_rel which won't work. Check its interaction with > > > publish_via_partition_root. >

Re: Support logical replication of DDLs

2022-05-23 Thread Zheng Li
> Now, say, the user has added a bar column with "ALTER TABLE foo ADD > COLUMN bar double precision NOT NULL DEFAULT random();" If we compare > with replication of DMLs like (UPDATE ddl_test SET bar = random();), > the replication won't update rows with values (3 and 4) on subscriber > as they

Re: Support logical replication of DDLs

2022-05-23 Thread Amit Kapila
On Thu, Apr 14, 2022 at 7:45 PM Euler Taveira wrote: > > You should forbid it. Unless you can decompose the command into multiple SQL > commands to make it a safe operation for logical replication. > > Let's say you want to add a column with a volatile default. > > ALTER TABLE foo ADD COLUMN bar

Re: Support logical replication of DDLs

2022-05-11 Thread Amit Kapila
On Wed, May 11, 2022 at 6:25 PM Masahiko Sawada wrote: > > On Wed, May 11, 2022 at 6:15 PM Amit Kapila wrote: > > > > On Wed, May 11, 2022 at 1:09 PM Masahiko Sawada > > wrote: > > > > > > On Mon, May 9, 2022 at 6:05 PM Alvaro Herrera > > > wrote: > > > > > > > > > > > > The code in

Re: Support logical replication of DDLs

2022-05-11 Thread Masahiko Sawada
On Wed, May 11, 2022 at 6:15 PM Amit Kapila wrote: > > On Wed, May 11, 2022 at 1:09 PM Masahiko Sawada wrote: > > > > On Mon, May 9, 2022 at 6:05 PM Alvaro Herrera > > wrote: > > > > > > On 2022-May-08, Dilip Kumar wrote: > > > > > > > > The code in test_ddl_deparse is a pretty lame start, not

Re: Support logical replication of DDLs

2022-05-11 Thread Amit Kapila
On Wed, May 11, 2022 at 1:09 PM Masahiko Sawada wrote: > > On Mon, May 9, 2022 at 6:05 PM Alvaro Herrera wrote: > > > > On 2022-May-08, Dilip Kumar wrote: > > > > > The code in test_ddl_deparse is a pretty lame start, not nearly good > > enough by a thousand miles. My real intention was to have

Re: Support logical replication of DDLs

2022-05-11 Thread Masahiko Sawada
On Mon, May 9, 2022 at 6:05 PM Alvaro Herrera wrote: > > On 2022-May-08, Dilip Kumar wrote: > > > On Sat, May 7, 2022 at 9:38 AM Amit Kapila wrote: > > > > I agree that it adds to our maintainability effort, like every time we > > > enhance any DDL or add a new DDL that needs to be replicated,

Re: Support logical replication of DDLs

2022-05-10 Thread Masahiko Sawada
On Wed, May 11, 2022 at 1:01 AM Zheng Li wrote: > > > > > I agree that it adds to our maintainability effort, like every time we > > > > enhance any DDL or add a new DDL that needs to be replicated, we > > > > probably need to change the deparsing code. But OTOH this approach > > > > seems to

Re: Support logical replication of DDLs

2022-05-10 Thread Zheng Li
> > > I agree that it adds to our maintainability effort, like every time we > > > enhance any DDL or add a new DDL that needs to be replicated, we > > > probably need to change the deparsing code. But OTOH this approach > > > seems to provide better flexibility. So, in the long run, maybe the > >

Re: Support logical replication of DDLs

2022-05-10 Thread Amit Kapila
On Tue, May 10, 2022 at 4:59 PM Ajin Cherian wrote: > > On Fri, May 6, 2022 at 11:24 PM Amit Kapila wrote: > > As we have hacked CreatePublication function for this POC, the > > regression tests are not passing but we can easily change it so that > > we invoke new functionality with the syntax

Re: Support logical replication of DDLs

2022-05-10 Thread Ajin Cherian
On Fri, May 6, 2022 at 11:24 PM Amit Kapila wrote: > As we have hacked CreatePublication function for this POC, the > regression tests are not passing but we can easily change it so that > we invoke new functionality with the syntax proposed in this thread or > with some other syntax and we shall

Re: Support logical replication of DDLs

2022-05-10 Thread Amit Kapila
On Tue, May 10, 2022 at 12:32 PM Masahiko Sawada wrote: > > On Wed, Apr 13, 2022 at 6:50 PM Amit Kapila wrote: > > > > On Wed, Apr 13, 2022 at 2:38 PM Dilip Kumar wrote: > > > > > > On Tue, Apr 12, 2022 at 4:25 PM Amit Kapila > > > wrote: > > > > > > > > > The *initial* DDL replication is a

Re: Support logical replication of DDLs

2022-05-10 Thread Masahiko Sawada
On Wed, Apr 13, 2022 at 6:50 PM Amit Kapila wrote: > > On Wed, Apr 13, 2022 at 2:38 PM Dilip Kumar wrote: > > > > On Tue, Apr 12, 2022 at 4:25 PM Amit Kapila wrote: > > > > > > > The *initial* DDL replication is a different problem than DDL > > > > replication. The > > > > former requires a

Re: Support logical replication of DDLs

2022-05-09 Thread Alvaro Herrera
On 2022-May-08, Dilip Kumar wrote: > On Sat, May 7, 2022 at 9:38 AM Amit Kapila wrote: > > I agree that it adds to our maintainability effort, like every time we > > enhance any DDL or add a new DDL that needs to be replicated, we > > probably need to change the deparsing code. But OTOH this

Re: Support logical replication of DDLs

2022-05-09 Thread Amit Kapila
On Mon, May 9, 2022 at 12:46 PM Bharath Rupireddy wrote: > > On Sun, May 8, 2022 at 12:39 PM Dilip Kumar wrote: > > > > On Sat, May 7, 2022 at 9:38 AM Amit Kapila wrote: > > > > > > On Fri, May 6, 2022 at 10:21 PM Zheng Li wrote: > > > > > > > > > Attached is a set of two patches as an attempt

Re: Support logical replication of DDLs

2022-05-09 Thread Bharath Rupireddy
On Sun, May 8, 2022 at 12:39 PM Dilip Kumar wrote: > > On Sat, May 7, 2022 at 9:38 AM Amit Kapila wrote: > > > > On Fri, May 6, 2022 at 10:21 PM Zheng Li wrote: > > > > > > > Attached is a set of two patches as an attempt to evaluate this > > > > approach. > > > > > > > > > > Thanks for

Re: Support logical replication of DDLs

2022-05-08 Thread Dilip Kumar
On Sat, May 7, 2022 at 9:38 AM Amit Kapila wrote: > > On Fri, May 6, 2022 at 10:21 PM Zheng Li wrote: > > > > > Attached is a set of two patches as an attempt to evaluate this approach. > > > > > > > Thanks for exploring this direction. > > > > I read the deparsing thread and your patch. Here is

Re: Support logical replication of DDLs

2022-05-06 Thread Amit Kapila
On Fri, May 6, 2022 at 10:21 PM Zheng Li wrote: > > > Attached is a set of two patches as an attempt to evaluate this approach. > > > > Thanks for exploring this direction. > > I read the deparsing thread and your patch. Here is my thought: > 1. The main concern on maintainability of the

Re: Support logical replication of DDLs

2022-05-06 Thread Zheng Li
> Attached is a set of two patches as an attempt to evaluate this approach. > > The first patch provides functions to deparse DDL commands. Currently, > it is restricted to just a simple CREATE TABLE statement, the required > code is extracted from one of the patches posted in the thread [1]. > >

Re: Support logical replication of DDLs

2022-05-03 Thread Zheng Li
> > >Another somewhat unrelated problem I see with this work is how to save > > >recursion of the same command between nodes (when the involved nodes > > >replicate DDLs). For DMLs, we can avoid that via replication origins > > >as is being done in the patch proposed [1] but not sure how will we >

Re: Support logical replication of DDLs

2022-04-29 Thread Zheng Li
Hello, > You should forbid it. Unless you can decompose the command into multiple SQL > commands to make it a safe operation for logical replication. > > Let's say you want to add a column with a volatile default. > > ALTER TABLE foo ADD COLUMN bar double precision DEFAULT random(); > > If you

Re: Support logical replication of DDLs

2022-04-14 Thread Zheng Li
> > But then this could be true for DML as well right? Like after > > replicating the function to the subscriber if we are sending the DML > > done by function then what's the problem in DDL. I mean if there is > > no design issue in implementing this then I don't think there is much > > point

Re: Support logical replication of DDLs

2022-04-14 Thread Zheng Li
> You should forbid it. Unless you can decompose the command into multiple SQL > commands to make it a safe operation for logical replication. > > Let's say you want to add a column with a volatile default. > > ALTER TABLE foo ADD COLUMN bar double precision DEFAULT random(); > > If you replicate

Re: Support logical replication of DDLs

2022-04-14 Thread Euler Taveira
On Thu, Apr 14, 2022, at 6:26 AM, Dilip Kumar wrote: > I agree. But here the bigger question is what is the correct behavior > in case of the Alter Table? I mean for example in the publisher the > table gets rewritten due to the Access Method change then what should > be the behavior of the

Re: Support logical replication of DDLs

2022-04-14 Thread Dilip Kumar
On Fri, Apr 8, 2022 at 4:30 PM Amit Kapila wrote: > > On Tue, Mar 29, 2022 at 9:47 AM Dilip Kumar wrote: > > > > > > The idea is to force skipping any direct data population (which can > > > potentially cause data inconsistency on the subscriber) > > > in CREATE AS and SELECT INTO command on the

Re: Support logical replication of DDLs

2022-04-13 Thread Amit Kapila
On Wed, Apr 13, 2022 at 2:38 PM Dilip Kumar wrote: > > On Tue, Apr 12, 2022 at 4:25 PM Amit Kapila wrote: > > > > > The *initial* DDL replication is a different problem than DDL > > > replication. The > > > former requires a snapshot to read the current catalog data and build a > > > CREATE >

Re: Support logical replication of DDLs

2022-04-13 Thread Dilip Kumar
On Tue, Apr 12, 2022 at 4:25 PM Amit Kapila wrote: > > > The *initial* DDL replication is a different problem than DDL replication. > > The > > former requires a snapshot to read the current catalog data and build a > > CREATE > > command as part of the subscription process. The subsequent DDLs

Re: Support logical replication of DDLs

2022-04-12 Thread Amit Kapila
On Wed, Apr 13, 2022 at 5:49 AM Zheng Li wrote: > > Hi, > > Here is the rebased new branch > https://github.com/zli236/postgres/commits/ddl_replication > Thanks, but it would be good if you can share it in the patch form as well unless you need to send patches too frequently. It is easier to

Re: Support logical replication of DDLs

2022-04-12 Thread Zheng Li
Hi, Here is the rebased new branch https://github.com/zli236/postgres/commits/ddl_replication Regards, Zheng

Re: Support logical replication of DDLs

2022-04-12 Thread Amit Kapila
On Mon, Apr 11, 2022 at 11:01 PM Zheng Li wrote: > > >Even if this works, how will we make Alter Table statement work where > >it needs to rewrite the table? There also I think we can face a > >similar problem if we directly send the statement, once the table will > >be updated due to the DDL

Re: Support logical replication of DDLs

2022-04-12 Thread Amit Kapila
On Mon, Apr 11, 2022 at 6:16 PM Euler Taveira wrote: > > On Mon, Apr 11, 2022, at 2:00 AM, Amit Kapila wrote: > > On Thu, Apr 7, 2022 at 3:46 PM Amit Kapila wrote: > > > > On Wed, Mar 23, 2022 at 10:39 AM Japin Li wrote: > > > > 2. For DDL replication, do we need to wait for a consistent point

Re: Support logical replication of DDLs

2022-04-11 Thread Zheng Li
> I'm planning to work on the initial DDL replication. I'll open a new thread as > soon as I write a design for it. Just as an example, the pglogical approach is > to use pg_dump behind the scenes to provide the schema [1]. It is a reasonable > approach but an optimal solution should be an API to

Re: Support logical replication of DDLs

2022-04-11 Thread Zheng Li
Hi Amit, > Some initial comments: > === > 1. > +/* > + * Write logical decoding DDL message into XLog. > + */ > +XLogRecPtr > +LogLogicalDDLMessage(const char *prefix, Oid roleoid, const char *message, > + size_t size, bool transactional) > > I don't see anywhere the patch using a

Re: Support logical replication of DDLs

2022-04-11 Thread Zheng Li
Hi, > > Good catch. The reason for having isTopLevel in the condition is > > because I haven't decided if a DDL statement inside a PL should > > be replicated from the user point of view. For example, if I execute a > > plpgsql function or a stored procedure which creates a table under the hood,

Re: Support logical replication of DDLs

2022-04-11 Thread Euler Taveira
On Mon, Apr 11, 2022, at 2:00 AM, Amit Kapila wrote: > On Thu, Apr 7, 2022 at 3:46 PM Amit Kapila wrote: > > > > On Wed, Mar 23, 2022 at 10:39 AM Japin Li wrote: > > > > 2. For DDL replication, do we need to wait for a consistent point of > > snapshot? For DMLs, that point is a convenient point

Re: Support logical replication of DDLs

2022-04-10 Thread Amit Kapila
On Fri, Apr 8, 2022 at 5:04 PM Alvaro Herrera wrote: > > On 2022-Apr-08, Amit Kapila wrote: > > > > For runtime conditions, one of the things you have mentioned in that > > thread is to add schema name in the statement at the required places > > which this patch deals with in a different way by

Re: Support logical replication of DDLs

2022-04-10 Thread Amit Kapila
On Thu, Apr 7, 2022 at 3:46 PM Amit Kapila wrote: > > On Wed, Mar 23, 2022 at 10:39 AM Japin Li wrote: > > 2. For DDL replication, do we need to wait for a consistent point of > snapshot? For DMLs, that point is a convenient point to initialize > replication from, which is why we export a

Re: Support logical replication of DDLs

2022-04-08 Thread Robert Haas
On Fri, Apr 8, 2022 at 7:34 AM Alvaro Herrera wrote: > > For runtime conditions, one of the things you have mentioned in that > > thread is to add schema name in the statement at the required places > > which this patch deals with in a different way by explicitly sending > > it along with the DDL

Re: Support logical replication of DDLs

2022-04-08 Thread Alvaro Herrera
On 2022-Apr-08, Amit Kapila wrote: > On Thu, Mar 17, 2022 at 3:36 AM Alvaro Herrera > wrote: > > > > Did you see some old code I wrote towards this goal? > > https://www.postgresql.org/message-id/20150215044814.gl3...@alvh.no-ip.org > > The intention was that DDL would produce some JSON blob

Re: Support logical replication of DDLs

2022-04-08 Thread Amit Kapila
On Thu, Mar 17, 2022 at 3:36 AM Alvaro Herrera wrote: > > Did you see some old code I wrote towards this goal? > https://www.postgresql.org/message-id/20150215044814.gl3...@alvh.no-ip.org > The intention was that DDL would produce some JSON blob that accurately > describes the DDL that was run; >

Re: Support logical replication of DDLs

2022-04-08 Thread Amit Kapila
On Tue, Mar 29, 2022 at 9:47 AM Dilip Kumar wrote: > > > > The idea is to force skipping any direct data population (which can > > potentially cause data inconsistency on the subscriber) > > in CREATE AS and SELECT INTO command on the subscriber by forcing the > > skipData flag in the intoClause

Re: Support logical replication of DDLs

2022-04-07 Thread Amit Kapila
On Tue, Mar 29, 2022 at 9:47 AM Dilip Kumar wrote: > > On Thu, Mar 24, 2022 at 11:24 PM Zheng Li wrote: > > > > > > Good catch. The reason for having isTopLevel in the condition is > > because I haven't decided if a DDL statement inside a PL should > > be replicated from the user point of view.

Re: Support logical replication of DDLs

2022-04-07 Thread Amit Kapila
On Wed, Mar 23, 2022 at 10:39 AM Japin Li wrote: > > Thanks for fixing this. I rebase the patchset on current master (383f222119) > and attach here for further review. > Some initial comments: === 1. +/* + * Write logical decoding DDL message into XLog. + */ +XLogRecPtr

Re: Support logical replication of DDLs

2022-04-06 Thread Ajin Cherian
On Wed, Mar 23, 2022 at 4:09 PM Japin Li wrote: > > > On Tue, 22 Mar 2022 at 04:56, Zheng Li wrote: > > Hi Japin, > > > >> You should use a different user that has different length from your > >> current one. > >> For example: > >> > >> px@localhost$ make check-world > > > > This is

Re: Support logical replication of DDLs

2022-03-28 Thread Dilip Kumar
On Thu, Mar 24, 2022 at 11:24 PM Zheng Li wrote: > > Hi Dilip, > > Thanks for the feedback. > > > > > > The table creation WAL and table insert WAL are available. The tricky > > > > > part is how do we break down this command into two parts (a normal > > > > > CREATE TABLE followed by insertions)

Re: Support logical replication of DDLs

2022-03-24 Thread Zheng Li
Hi Dilip, Thanks for the feedback. > > > > The table creation WAL and table insert WAL are available. The tricky > > > > part is how do we break down this command into two parts (a normal > > > > CREATE TABLE followed by insertions) either from the parsetree or the > > > > WALs. I’ll have to dig

Re: Support logical replication of DDLs

2022-03-24 Thread Dilip Kumar
On Thu, Mar 24, 2022 at 3:32 PM Dilip Kumar wrote: > > On Mon, Mar 21, 2022 at 1:43 PM Dilip Kumar wrote: > > > > On Thu, Mar 17, 2022 at 2:47 AM Zheng Li wrote: > > > > > > Hi, > > > > > > >If you don't mind, would you like to share the POC or the branch for > > > >this work? > > > > > > The

Re: Support logical replication of DDLs

2022-03-24 Thread Dilip Kumar
On Mon, Mar 21, 2022 at 1:43 PM Dilip Kumar wrote: > > On Thu, Mar 17, 2022 at 2:47 AM Zheng Li wrote: > > > > Hi, > > > > >If you don't mind, would you like to share the POC or the branch for this > > >work? > > > > The POC patch is attached. It currently supports the following > >

Re: Support logical replication of DDLs

2022-03-21 Thread Zheng Li
Hi Japin, > You should use a different user that has different length from your current > one. > For example: > > px@localhost$ make check-world This is fixed in the latest commit: https://github.com/zli236/postgres/commits/ddl_replication Thanks, Zheng

Re: Support logical replication of DDLs

2022-03-21 Thread Dilip Kumar
On Thu, Mar 17, 2022 at 2:47 AM Zheng Li wrote: > > Hi, > > >If you don't mind, would you like to share the POC or the branch for this > >work? > > The POC patch is attached. It currently supports the following > functionalities: Thanks for sharing, I will look into it. > >In such cases why

Re: Support logical replication of DDLs

2022-03-18 Thread Japin Li
On Sat, 19 Mar 2022 at 01:25, Zheng Li wrote: > Hello, > > Thanks for the quick review! > >> And, when I try to use git am to apply the patch, it complains: >> >> $ git am ~/0001-syntax-pg_publication-pg_dump-ddl_replication.patch >> Patch format detection failed. > > git apply

Re: Support logical replication of DDLs

2022-03-18 Thread Zheng Li
Hello, Thanks for the quick review! > And, when I try to use git am to apply the patch, it complains: > > $ git am ~/0001-syntax-pg_publication-pg_dump-ddl_replication.patch > Patch format detection failed. git apply works for me. I'm not sure why git am complains. I also

Re: Support logical replication of DDLs

2022-03-18 Thread Japin Li
On Fri, 18 Mar 2022 at 08:18, Zheng Li wrote: > Hello, > > Attached please find the broken down patch set. Also fixed the failing > TAP tests Japin reported. > Here are some comments for the new patches: Seems like you forget initializing the *ddl_level_given after entering the

Re: Support logical replication of DDLs

2022-03-17 Thread Japin Li
On Fri, 18 Mar 2022 at 08:22, Japin Li wrote: > On Fri, 18 Mar 2022 at 00:22, Zheng Li wrote: >> Hello Japin, >>>The new patch change the behavior of publication, when we drop a table >>>on publisher, the table also be dropped on subscriber, and this made the >>>regression testa failed, since

Re: Support logical replication of DDLs

2022-03-17 Thread Japin Li
On Fri, 18 Mar 2022 at 08:18, Zheng Li wrote: > Hello, > > Attached please find the broken down patch set. Also fixed the failing > TAP tests Japin reported. > Thanks for updating the patchset, I will try it later. -- Regrads, Japin Li. ChengDu WenWu Information Technology Co.,Ltd.

Re: Support logical replication of DDLs

2022-03-17 Thread Japin Li
On Fri, 18 Mar 2022 at 00:22, Zheng Li wrote: > Hello Japin, >>The new patch change the behavior of publication, when we drop a table >>on publisher, the table also be dropped on subscriber, and this made the >>regression testa failed, since the regression test will try to drop the >>table on

Re: Support logical replication of DDLs

2022-03-17 Thread Zheng Li
Hello Alvaro, > I think this is a pretty interesting and useful feature. > > Did you see some old code I wrote towards this goal? > https://www.postgresql.org/message-id/20150215044814.gl3...@alvh.no-ip.org > The intention was that DDL would produce some JSON blob that accurately > describes the

Re: Support logical replication of DDLs

2022-03-17 Thread Japin Li
On Thu, 17 Mar 2022 at 05:17, Zheng Li wrote: > Hi, > >>If you don't mind, would you like to share the POC or the branch for this >>work? > > The POC patch is attached. It currently supports the following > functionalities: Hi, When I try to run regression test, there has some errors.

Re: Support logical replication of DDLs

2022-03-16 Thread Japin Li
Hi, Zhang Li On Thu, 17 Mar 2022 at 05:17, Zheng Li wrote: > Hi, > >>If you don't mind, would you like to share the POC or the branch for this >>work? > > The POC patch is attached. It currently supports the following > functionalities: > 1. Configure either database level or table level DDL

Re: Support logical replication of DDLs

2022-03-16 Thread Alvaro Herrera
Hello I think this is a pretty interesting and useful feature. Did you see some old code I wrote towards this goal? https://www.postgresql.org/message-id/20150215044814.gl3...@alvh.no-ip.org The intention was that DDL would produce some JSON blob that accurately describes the DDL that was run;

Re: Support logical replication of DDLs

2022-03-15 Thread rajesh singarapu
+ On Sun, Mar 13, 2022 at 5:05 PM Dilip Kumar wrote: > > On Mon, Feb 21, 2022 at 9:43 PM Zheng Li wrote: > > > > Hello, > > > > One of the most frequently requested improvements from our customers > > is to reduce downtime associated with software updates (both major and > > minor versions). To

Re: Support logical replication of DDLs

2022-03-13 Thread Dilip Kumar
On Mon, Feb 21, 2022 at 9:43 PM Zheng Li wrote: > > Hello, > > One of the most frequently requested improvements from our customers > is to reduce downtime associated with software updates (both major and > minor versions). To do this, we have reviewed potential contributions to > improving

Re: Support logical replication of DDLs

2022-02-24 Thread Aleksander Alekseev
Hi Zheng, > >Also, I suspect that implementing it may be a bit challenging. What if we > >focus on table-level replication for now? > > I think it is due to the fact that the current limitations in logical > replication are > holding it back in major version upgrade (MVU). Online / reduced

<    1   2   3   4   >