On Thu, Dec 2, 2021 at 7:18 PM Amit Langote <amitlangot...@gmail.com> wrote: > > On Thu, Dec 2, 2021 at 2:27 PM Amit Kapila <amit.kapil...@gmail.com> wrote: > > On Thu, Dec 2, 2021 at 8:42 AM Amit Langote <amitlangot...@gmail.com> wrote: > > > Reading Alvaro's email at the top again gave me a pause to reconsider > > > what I had said in reply. It might indeed have been nice if the > > > publication DDL itself had prevented the cases where a partition and > > > its ancestor are added to a publication, though as Hou-san mentioned, > > > partition ATTACHes make that a bit tricky to enforce at all times, > > > though of course not impossible. Maybe it's okay to just de-duplicate > > > pg_publication_tables output as the patch does, even though it may > > > appear to be a band-aid solution if we one considers Alvaro's point > > > about consistency. > > > > True, I think even if we consider that idea it will be a much bigger > > change, and also as it will be a behavioral change so we might want to > > keep it just for HEAD and some of these fixes need to be backpatched. > > Having said that, if you or someone want to pursue that idea and come > > up with a better solution than what we have currently it is certainly > > welcome. > > Okay, I did write a PoC patch this morning after sending out my > earlier email. I polished it a bit, which is attached. >
I see multiple problems with this patch and idea. (a) I think you forgot to deal with "All Tables In Schema" Publication which will be quite tricky to deal with during attach operation. How will you remove a particular relation from such a publication if there is a need to do so? (b) Also, how will we prohibit adding partition and its root in the case of "All Tables In Schema" or "All Tables" publication? If there is no way to do that, then that would mean we anyway need to deal with parent and child tables as part of the same publication and this new behavior will add an exception to it. (c) I think this can make switching "publish_via_partition_root" inconvenient for users. Say all or some of the partitions are part of the publication and then the user decides to add root table and change publish option "publish_via_partition_root" to "true" at that moment she needs to remove all partitions first. -- With Regards, Amit Kapila.