Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1whU75-000Fnh-17 for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jul 2026 15:23:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1whU73-007it9-2p for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jul 2026 15:23:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1whU73-007isz-1p for pgsql-hackers@lists.postgresql.org; Wed, 08 Jul 2026 15:23:02 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1whU71-00000000I9q-2PIt for pgsql-hackers@lists.postgresql.org; Wed, 08 Jul 2026 15:23:02 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-5aeb6d00883so713841e87.1 for ; Wed, 08 Jul 2026 08:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783524179; cv=none; d=google.com; s=arc-20260327; b=WttR9+da9sok37Khk1jGau276GACf2cLY1JhgsyJ92GQEY1RlR8qJ/6IpOWBw0n2Zi zOwvqBewRddL68QrDwG6/PGU5u4ZQTHp0YSRy7KuAdorGyt+jwaVkx+mJk26OSgXF6LJ DNQvVSQbxwsPGkwAZJOE7bpzSb0sp1vixxnh3IJX0X0bqwLK/S74ktxfQcSo2QV1kkju +gayNfzlIkaR6EZKh5wXfgCvBFJVpY7aEw3Lpq2u0RZ1hHff33ZzDKnV11IH2TxnIGlv kLCnhqCCCTFbH10vIXfrQe4PX69wGROZGlgPkSpfBJlHTwZKd5oSXql6LozdahpvlpDp IM+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=HrzZklUQbtoqQ52iHvm4ZPPbTOEw4imrROprsKaLVHo=; fh=x3EQrMG/AK8ORr+CspYYvgpOaat+5QoO7noHUbAyd6M=; b=QkOGiMuGnS5apHqiLaziKWqwh95oM5rHyJldPk9NJvzOSGIurdvwrVxk9HFhuDRtPV zbCtc58Ir6NeApSA2/jXLInkPe+Tze1U7uMlkwGoI9PFIppniB9paGzw56kRruYCF3pL TktaTI/xyQSyK7UmceNbUcAkfAZubeka/bx2PlyP4q/H973D6ZNf+77mhc3OzDe1itkM fk6YMLfcEito5jWuGH6AbWcayPBoUYsXAhx0QB3LUlBcdurxdM4P74KleeqR/WZ0CVwa pOQ37mOgqc+duGsgVX2Q0nVYNmyyZ9ph6IkUyCVTATmjq/0TzLu/frTe+EBqiwLEX3+C oIaA==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783524179; x=1784128979; darn=lists.postgresql.org; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to:content-type; bh=HrzZklUQbtoqQ52iHvm4ZPPbTOEw4imrROprsKaLVHo=; b=roIAC3x5Vy9ErpVjN4txushwlM5ycurDLmEwKeDKGfbB8cUSp4KF5BvX6j1vgDtoDi 7xF3sxD8kgObYlzZeIY5ZCdJBpjZFupiX6sY4I03+aEKl1IAi3NyRwssD4uzvFkklBQn hxsZHw338F6/ZkjBTcr4qP5z09x49Lb8AdjclkcVVsAWW93gC6nzLc2XZ6mNo0ckCH0L MtWBk9avWSpv+JM3KBZ6zPyx5y2BpXn0TAETNvj4yryBzC72sGc+Efs5CREiv9FY7s4D 2eYs214RsGPXiFK/TUm9Cr4RKKz7rnel7E4l1oRnMiP5fygrxIOVY3UwZpgptQrkCFaB Rllw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783524179; x=1784128979; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=HrzZklUQbtoqQ52iHvm4ZPPbTOEw4imrROprsKaLVHo=; b=rbbC32ekXi2QPJi8ctO0ICXzwMvtGTV+i1+7HePOJPfx9XfEYI9y1rCKBhJzbqyQ4w kBA8AjQtuFjuM0aAKAAp4K/Z3AO3awTWdhgm5tAOzdopMNBHb2KpxomkritHXeNdnGrv HLtEDAqdW/ZpjV76braJ3eB9aYlr7lpyHXJgQKuHQW8WcHMtuodvz5AffDk3qauAm5wY VPirH0GEre6bSPR0TeX0cvJTfGkEus42tmtmcGX/Eyflh12pStQW2u3g+iI2N7DUJvwZ PsRBae48fHxraiEQIJcQCLtytNgtYMVp80Yi5+pmTcRdIywCtAviMriFZzBjZWmEmm3d SheQ== X-Forwarded-Encrypted: i=1; AHgh+Rq9NaCN/FMArJVScCh7JkI1B9bQ0Gw6YjGWgCKk8irOgiZU0yzGUARp4NIOiUnBpd3xVx16LRlHT5YBEcUm@lists.postgresql.org X-Gm-Message-State: AOJu0YzLD3KhKJ5dKB4eVFBtfrVhsgF3x4cNfjda3G34gjpT8lOnMIZ+ kK6vWbJSHTzQtYqY14DLBEHsp0/0Dp4NAxuoT11/NpP1pNxZio4EaMQI6FPYxDhpIY38skba3BE f/DvVjx9/KiopFLpfbuxLTgPvafEWCg== X-Gm-Gg: AfdE7cna6RhgO7xUGLk3KMZkXsqSkB00qpEw0Q1iuwFvZxi1eINUCGc5ZQR/N4oqrzu ysZTwCdjQjKp+CIxZh0B4Xu1pqGj2mrRCxIvl0YdhjfLrpFNNslvuA0VGd3AfuUqTEEE+2xDFGB AImZLouWQsN8DT57e61BokpxzDjuQKxd4vmoTnCuo/EaEemseZAQmOdaIGKC11ANoV6P1hZTKxc YXKpUO9O5jRiT+9i9W9mfzJ1Lhj0LTURLfJgBCs6KCWljPNt/xDNi78pYoz0NiexTBX7cOVLxRR O9o= X-Received: by 2002:a05:6512:a8b:b0:5ad:5c4a:8221 with SMTP id 2adb3069b0e04-5b011408a4amr844742e87.0.1783524178982; Wed, 08 Jul 2026 08:22:58 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Nisha Moond Date: Wed, 8 Jul 2026 20:52:45 +0530 X-Gm-Features: AVVi8Cc3SDDcc59NfBA31DFOOg0E1UD44lK85kL6iFWsoWgxzOxI6Ncn7F7wC-g Message-ID: Subject: Re: Support EXCEPT for TABLES IN SCHEMA publications To: Amit Kapila Cc: shveta malik , Peter Smith , Zsolt Parragi , pgsql-hackers@lists.postgresql.org, shveta malik Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jul 8, 2026 at 11:58=E2=80=AFAM Amit Kapila wrote: > > On Tue, Jul 7, 2026 at 4:13=E2=80=AFPM shveta malik wrote: > > > > On Tue, Jul 7, 2026 at 2:31=E2=80=AFPM shveta malik wrote: > > > > > > On Fri, Jul 3, 2026 at 10:15=E2=80=AFPM Nisha Moond wrote: > > > > > > > > > > > > postgres=3D# alter publication pub2 add table t_part_p1; > > > > ERROR: cannot add table "public.t_part_p1" to publication "pub2" > > > > DETAIL: Partition ancestor "public.t_part" of table > > > > "public.t_part_p1" is currently listed in the EXCEPT clause of the > > > > publication. > > > > HINT: Change EXCEPT list using ALTER PUBLICATION ... SET TABLES IN > > > > SCHEMA ... EXCEPT. > > > > ~~~ > > > > > > Thanks. Do you think we should restrict this case too? To me, this > > > seems like another variation of the above where conflicting entries > > > are given at the time of sub-creation itself. The root is excluded bu= t > > > parittion is included . > > > > > > postgres=3D# create publication pub1 for table s2.tab_part_1, tables = in > > > schema s2 except (table tab_root); > > > CREATE PUBLICATION > > > postgres=3D# \dRp+ > > > Publication pub= 1 > > > Owner | All tables | All sequences | Inserts | Updates | Deletes | > > > Truncates | Generated columns | Via root | Description > > > --------+------------+---------------+---------+---------+---------+-= ----------+-------------------+----------+------------- > > > shveta | f | f | t | t | t | = t > > > | none | f | > > > Tables: > > > "s2.tab_part_1" > > > Tables from schemas: > > > "s2" > > > Except tables: > > > "s2.tab_root" > > > > > > > Since alter is blocked for above case while create-sub is not, > > > > If a combination is not supported in ALTER, we should disallow the > same in CREATE as well. So, +1 to restrict the case you reported. > Fixed in v19. > > I had a > > look at the new check added in check_publication_add_relation > > > > a) The check introduced in this function for partitions/ancestors is > > sufficient for cases where an except-list is already present, but not > > for cases where we are in the process of adding one. Thus the > > create-sub scenario above is not covered by this. > > > > b) Also the new check in check_publication_add_relation() gets and > > traverses complete list of ancestors > > > > + List *ancestors =3D get_partition_ancestors(relid); > > + > > + foreach_oid(ancestor, ancestors) > > > > Isn't getting root (llast_oid(ancestors)) and checking that alone in > > EXCEPT list will suffice? Or am I missing something? > > > > I think this should be possible because we allow only root tables in > the EXCEPT list. If so, and we are planning to change as per your > suggestion then we should add a comment as to why checking only last > is okay here. > Agreed; I implemented the suggested optimization and added comments explaining why checking only the last element is sufficient. -- Thanks, Nisha