Re: Support logical replication of DDLs

From: Zheng Li <zhengli10(at)gmail(dot)com>
To: li jie <ggysxcq(at)gmail(dot)com>
Cc: vignesh C <vignesh21(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, Ajin Cherian <itsajin(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(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: 2022-12-02 23:48:59
Message-ID: CAAD30UJw=4s-BezskPH6XieigAVBdsO9dCGQddzwC7z_7MxUaQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

> 2. ALTER TABLE (inherits)
> case:
> ```
> CREATE TABLE gtest30 (
> a int,
> b int GENERATED ALWAYS AS (a * 2) STORED
> );
> CREATE TABLE gtest30_1 () INHERITS (gtest30);
> ALTER TABLE gtest30 ALTER COLUMN b DROP EXPRESSION;
> ```
> After this case is executed in the publication, the following error occurs in the subscription :
>
> ERROR: column "b" of relation "gtest30" is not a stored generated column
> STATEMENT: ALTER TABLE public.gtest30 ALTER COLUMN b DROP EXPRESSION, ALTER COLUMN b DROP EXPRESSION
>
> Obviously, the column modifications of the inherited table were also captured,
>
> and then deparse the wrong statement.
>
> I believe that such errors may also occur in other alter table subcmd scenarios where tables are inherited.

This is fixed in the attached v43 patch set. The fix is to skip the
deparse of the subcommand if the objectId of the subcommand doesn't
match the objectId of the parent/wrapper ALTER TABLE command.

Regards,
Zheng

Attachment Content-Type Size
v43-0003-Support-CREATE-TABLE-AS-SELECT-INTO.patch application/octet-stream 15.0 KB
v43-0004-Test-cases-for-DDL-replication.patch application/octet-stream 24.6 KB
v43-0002-Support-DDL-replication.patch application/octet-stream 133.5 KB
v43-0005-Skip-ALTER-TABLE-subcommands-generated-for-TableLike.patch application/octet-stream 2.2 KB
v43-0001-Functions-to-deparse-DDL-commands.patch application/octet-stream 317.9 KB

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2022-12-03 11:23:17 Re: Stored procedure code no longer stored in v14 and v15, changed behaviour
Previous Message Tom Lane 2022-12-02 23:11:46 Re: Views "missing" from information_schema.view_table_usage

Browse pgsql-hackers by date

  From Date Subject
Next Message David Zhang 2022-12-03 00:05:08 Re: Patch: Global Unique Index
Previous Message David Zhang 2022-12-02 23:29:25 Re: Patch: Global Unique Index