Re: Added schema level support for publication.

From: vignesh C <vignesh21(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Greg Nancarrow <gregn4422(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Smith <smithpb2250(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>, Ajin Cherian <itsajin(at)gmail(dot)com>, "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>, Rahila Syed <rahilasyed90(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Subject: Re: Added schema level support for publication.
Date: 2021-08-31 14:05:44
Message-ID: CALDaNm2cws6Q8a=LJUgheFgMfW4Fgp+C_7aR-UR0G4SqtKE8Yw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Aug 31, 2021 at 4:27 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Tue, Aug 31, 2021 at 10:50 AM Greg Nancarrow <gregn4422(at)gmail(dot)com> wrote:
> >
> > On Tue, Aug 31, 2021 at 1:41 PM vignesh C <vignesh21(at)gmail(dot)com> wrote:
> > >
> > > >
> > > > I notice that "CREATE PUBLICATION pub1 FOR ALL TABLES IN SCHEMA sc1,
> > > > TABLE sc1.test;" maintains the table separately and results in the
> > > > following in the \dRp+ output:
> > > >
> > > > Tables:
> > > > "sc1.test"
> > > > Schemas:
> > > > "sc1"
> > > >
> > > > and also then "ALTER PUBLICATION pub1 DROP ALL TABLES IN SCHEMA sc1;"
> > > > still leaves the "sc1.test" table in the publication.
> > >
> > > I had intentionally implemented this way, the reason being it gives
> > > the flexibility to modify the publications based on the way the
> > > publication is created. My idea was that if a user specified a
> > > table/schema of the same schema while creating the publication, the
> > > user should be allowed to drop any of them at any time. In the above
> > > case if we don't maintain the results separately, users will not be
> > > able to drop the table from the publication at a later point of time.
> > > Thoughts?
> > >
> >
> > Hmmm. I'm not sure it should work like that (but maybe I'm wrong -
> > what do others think???).
> > I thought that "CREATE PUBLICATION pub1 FOR ALL TABLES IN SCHEMA sc1,
> > TABLE sc1.test;" should silently just ignore the "TABLE sc1.test"
> > part, as that is a table in schema sc1, so it's effectively a
> > duplicate.
> >
>
> I find the way it is implemented to be more intuitive as that gives
> users more flexibility to retain certain tables from the schema and
> appears to be exactly what users intended by the command. I don't
> think finding duplicates among different object lists (schema, table)
> is a good idea because tomorrow for some other objects the same thing
> can happen. It might be better to get some other opinions on this
> matter though.
>
> > Also, I noticed the following:
> >
> > postgres=# CREATE PUBLICATION pub1 FOR ALL TABLES IN SCHEMA sc1,
> > postgres-# TABLE sc1.test;
> > CREATE PUBLICATION
> > postgres=# \dRp+
> > Publication pub1
> > Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root
> > -------+------------+---------+---------+---------+-----------+----------
> > gregn | f | t | t | t | t | f
> > Tables:
> > "sc1.test"
> > Schemas:
> > "sc1"
> >
> > postgres=# ALTER PUBLICATION pub1 DROP ALL TABLES IN SCHEMA sc1;
> > ALTER PUBLICATION
> > postgres=# \dRp+
> > Publication pub1
> > Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root
> > -------+------------+---------+---------+---------+-----------+----------
> > gregn | f | t | t | t | t | f
> > Tables:
> > "sc1.test"
> >
> > postgres=# ALTER PUBLICATION pub1 DROP ALL TABLES IN SCHEMA sc1;
> > ERROR: schema "sc1" is not part of the publication
> >
>
> What will happen if you second time run the command as ALTER
> PUBLICATION pub1 DROP Table sc1.test? If that works, I think the
> behavior should be fine.

Alter publication drop table works fine:
postgres=# ALTER PUBLICATION pub1 DROP table sc1.test ;
ALTER PUBLICATION
postgres=# \dRp+
Publication pub1
Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root
---------+------------+---------+---------+---------+-----------+----------
vignesh | f | t | t | t | t | f
(1 row)

Regards,
Vignesh

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Luzanov 2021-08-31 14:14:12 psql: \dl+ to list large objects privileges
Previous Message Alvaro Herrera 2021-08-31 13:56:30 Re: prevent immature WAL streaming