Shouldn't duplicate addition to publication be a no-op?

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Shouldn't duplicate addition to publication be a no-op?
Date: 2017-04-13 10:23:39
Message-ID: 64ec4f57-9361-d32c-ecbe-86158437cb7e@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wonder if trying to add a relation to a publication that it is already a
part should be considered a no-op, instead of causing an error (which
happens in the ALTER PUBLICATION ADD TABLES case).

create table bar (a int);
create publication mypub for table bar;
alter publication mypub add table bar;
ERROR: relation "bar" is already member of publication "mypub"

2nd command should be a no-op, IMHO.

Consider the following (I know we're discussing inheritance elsewhere as
well):

create table foo (a int);
create table baz () inherits (foo);
alter table bar inherit foo;

alter table mypub add table foo;
ERROR: relation "bar" is already member of publication "mypub"

There is no way to add foo and children other than bar to mypub without
doing so one-by-one.

If my proposal to make that a no-op sounds desirable, attached patch
implements that.

Thanks,
Amit

Attachment Content-Type Size
0001-Fix-how-duplicate-addition-to-a-publication-is-preve.patch text/x-diff 5.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vitaly Burovoy 2017-04-13 10:40:25 Re: sequence data type
Previous Message Masahiko Sawada 2017-04-13 10:23:37 Re: Interval for launching the table sync worker