RE: pg_get_publication_tables() output duplicate relid

From: "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Subject: RE: pg_get_publication_tables() output duplicate relid
Date: 2021-11-16 01:51:06
Message-ID: OS0PR01MB5716477188EB9F6026AEF04194999@OS0PR01MB5716.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 15, 2021 9:42 PM Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
> > On Mon, Nov 15, 2021 at 1:48 PM houzj(dot)fnst(at)fujitsu(dot)com
> > <houzj(dot)fnst(at)fujitsu(dot)com> wrote:
>
> > > create table tbl1 (a int) partition by range (a); create table
> > > tbl1_part1 partition of tbl1 for values from (1) to (10); create
> > > table tbl1_part2 partition of tbl1 for values from (10) to (20);
> > > create publication pub for table tbl1, tbl1_part1 with
> > > (publish_via_partition_root=false);
>
> In the name of consistency, I think this situation should be an error -- I mean, if
> we detect that the user is trying to add both the partitioned table *and* its
> partition, then all manner of things are possibly going to go wrong in some way,
> so my inclination is to avoid it altogether.
>
> Is there any reason to allow that?
>
> If we do that, then we have to be careful with later ALTER PUBLICATION
> too: adding a partition is not allowed if its partitioned table is there, and adding
> a partitioned table should behave in some sensible way if one of its partitions is
> there (either removing the partition at the same time, or outright rejecting the
> operation.)

Thanks for the response.

If we decide to disallow this case, we seem need to handle some other cases as
well, for example: We might also need additional check when ATTACH a partition,
because the partition's parent table could already be published in the same
publication as the partition. During the check we might also need to lock all
the parent tables to handle concurrently change which looks complicated to me :(
I am not sure is it worth adding these lock and check. Maybe we can leave the current
behavior as is ?

Best regards,
Hou zj

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message houzj.fnst@fujitsu.com 2021-11-16 01:56:41 RE: Data is copied twice when specifying both child and parent table in publication
Previous Message houzj.fnst@fujitsu.com 2021-11-16 01:50:45 RE: pg_get_publication_tables() output duplicate relid