RE: Added schema level support for publication.

tanghy.fnst@fujitsu.com <tanghy.fnst@fujitsu.com>

From: "tanghy.fnst@fujitsu.com" <tanghy.fnst@fujitsu.com>
To: vignesh C <vignesh21@gmail.com>, Greg Nancarrow <gregn4422@gmail.com>
Cc: Ajin Cherian <itsajin@gmail.com>, Rahila Syed <rahilasyed90@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: 2021-07-19T03:13:14Z
Lists: pgsql-hackers
On Friday, July 16, 2021 6:13 PM vignesh C <vignesh21@gmail.com<mailto:vignesh21@gmail.com>> wrote:

>

> On Fri, Jul 16, 2021 at 9:25 AM Greg Nancarrow <mailto:gregn4422@gmail.com> wrote:

> >

> > Also, there seems to be an issue with ALTER PUBLICATION ... SET SCHEMA ...

> > (PubType is getting set to 'e' instead of 's'

> >

> > test_pub=# create publication pub1;

> > CREATE PUBLICATION

> > test_pub=# create table myschema.test(i int);

> > CREATE TABLE

> > test_pub=# alter publication pub1 set schema myschema;

> > ALTER PUBLICATION

> > test_pub=# \dRp pub1

> >                                    List of publications

> >  Name | Owner | All tables | Inserts | Updates | Deletes | Truncates |

> > Via root | PubType

> > ------+-------+------------+---------+---------+---------+-----------+----------+---------

> >  pub1 | gregn | f          | t       | t       | t       | t         |

> > f        | e

> > (1 row)

> >

> > test_pub=# alter publication pub1 add table test;

> > ALTER PUBLICATION

> > test_pub=# \dRp pub1

> >                                    List of publications

> >  Name | Owner | All tables | Inserts | Updates | Deletes | Truncates |

> > Via root | PubType

> > ------+-------+------------+---------+---------+---------+-----------+----------+---------

> >  pub1 | gregn | f          | t       | t       | t       | t         |

> > f        | t

> > (1 row)

> >

> >

> > When I use "ADD SCHEMA" instead of "SET SCHEMA" on an empty

> > publication, it seems OK.

>

> Modified.

>



Thanks for your patch. But there is a problem about "ALTER PUBLICATION … SET TABLE …", which is similar to the issue Greg reported at [1].



For example:

postgres=# CREATE TABLE public.t1 (a int);

CREATE TABLE

postgres=# CREATE PUBLICATION pub1;

CREATE PUBLICATION

postgres=# ALTER PUBLICATION pub1 SET TABLE public.t1;

ALTER PUBLICATION

postgres=# \dRp

                                    List of publications

Name |  Owner   | All tables | Inserts | Updates | Deletes | Truncates | Via root | PubType

------+----------+------------+---------+---------+---------+-----------+----------+---------

pub1 | postgres | f          | t       | t       | t       | t         | f        | e

(1 row)



I think PubType in this case should be 't' instead of 'e'. Please have a look.



[1] - https://www.postgresql.org/message-id/CAJcOf-ddXvY%3DOFC54CshdMa1bswzFjG9qokjC0aFeiS%3D6CNRzw%40mail.gmail.com

Regards,
Tang


Commits

  1. Include schema/table publications even with exclude options in dump.

  2. Rename some enums to use TABLE instead of REL.

  3. Add tap tests for the schema publications.

  4. Allow publishing the tables of schema.

  5. In pg_dump, use simplehash.h to look up dumpable objects by OID.