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 1wgZkm-006GoJ-2S for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Jul 2026 03:12:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wgZkj-00Ee55-18 for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Jul 2026 03:12:13 +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 1wgZki-00Ee4x-38 for pgsql-hackers@lists.postgresql.org; Mon, 06 Jul 2026 03:12:13 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wgZkf-00000001yqF-1HlM for pgsql-hackers@lists.postgresql.org; Mon, 06 Jul 2026 03:12:11 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-2cad8076b01so32326795ad.2 for ; Sun, 05 Jul 2026 20:12:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783307527; cv=none; d=google.com; s=arc-20260327; b=OjR4MsTB5ONakguST3yqKT0G+ZKMHf68FWr9aAQA+7obPeV1OanoqzqmshoL1AB73X OqspR3dnSBhY4e2W5pLxrkSI2ZoQNARPwUXqpvPdLAt/o5wDhtefxU+TLkXX+bDXnaxm fOUO4Df4pCnxv009J4rda6Vlso04KICztxaaFzuN3H/NI5dPqXWDn5VDPRV0JtwlVRh+ 00zbLUY5c6HWStUy7fj/qEvgaUQ6jV9g+kBj0g/VinapusAKomWgO6Xteflg7oVWRbCL KaRtqkIQMvl+vfUWHIRR77oBVeaF0stz3YNuN3EYmSZsGyOia7FsOILZCJWZAMQZ8CVu T1Qw== 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=oyZVhH5G9+s859eptrIOjIdVTbrhfXEc1Uhy1IyH3l8=; fh=5PVIwT6aMiyVRlGFrXWi/y7B7PVFGBbLmar5Hz6F7YQ=; b=TjLwtxEqEgZbfQetx/HGqarRRK6e0jQBGqK/C/3qwEkXFYfJ7zesbwgjt3FWysnRQT u+aQB/RkZ2kfvnaweFIvTh3tgNxdoJAYY4ddTkF92xzkpq5HTVdg5J/g/5Xdyk984Pcm FqOXAE3x4avTDD6daQM6BEaP7eC/7LXGBYYRZs9mBjlk5ZgOhZeOsrgOyr8DvSyc4lRv h69irIezOhOK3bpSUS/+JSR/iImNeyuUPtk/MXw3VCLMKRlADCYXRcmrEc0qA5Ylrh+s 5aJtufCEScZ5d16DN4d1USftZ+EZlR4QKvei9eQvYHObHTtNviBhK3Vs6UlFlfiKopDX 54Qw==; 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=1783307527; x=1783912327; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=oyZVhH5G9+s859eptrIOjIdVTbrhfXEc1Uhy1IyH3l8=; b=JCUeOcrrpBedEKYi1BfEEIB2IKfX62wmzCCBApuBO5SXe+Lt7y5Mam8SPj33ns3O7U HKrMtK8/LcK4rEIbrcctaAWIR7MmwvPgcglUSAPICAcWu7rQbkzHAhue7tW7Rlf1dQah vW0OR/IFzighzpi2ybpvTUFRScHZimvAYo6pSKzbR5Qb8Knx1fRA4NFIECs+1C6FRopx KKWb0LmpE9jwxE+jCkkbbhtYC9NjnDS095z+rdo89QmtrHSasKrwIM3o4kD/ryGAuxYq QRKYFfI9Aa6z6IQP6cxEFsxKd1Q4U0kS/LBjBatOGmYami6vYZNeEV6CBkddynPibZF6 6JpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783307527; x=1783912327; h=content-transfer-encoding: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; bh=oyZVhH5G9+s859eptrIOjIdVTbrhfXEc1Uhy1IyH3l8=; b=C7g7E83UQHxPc/ixUQiMN7D2UyJT/WBz0SWTDwFa/xbQcqMT3Cb1kmOc/LeQUxBM6r UIuf33xMpeH7nx+5Phx3CjMpilzFVDGVkrYylVDwQi0UrlAOL8UNK0NMLkTBjsq860v6 eE3iImh0bl67OxD+VaUqNzIGfwB4Nz0i5A5zebzAQyMTmDEPwULICSP9TuP1pYfVWRkX wSsCw5CE37p22B0WQTvDV6FZI6M6dVDgHT+NvElwrj24kyIEp9MPS1VzKF9wVhpTuWWG J6xeEzHnfy272yzVwdM2wFmOmSO/zK1nU7anSBaYxDzL7GXtYzoPuivc5znREBxXjPg/ IqCQ== X-Forwarded-Encrypted: i=1; AHgh+Rp61c0d5wgmLUYUn6KyE4iuHbzVMTEqyScPnEeU6KwJnM5ESpYSf896TF3vipO87jP0TsdAbNYTOFcEfbO/@lists.postgresql.org X-Gm-Message-State: AOJu0YzeRe6N572Unw0u9Boc+873AZRhjRXztdkze98U03DJDNomp/g6 w0A/v2IyciRzthqrvwim4D6fqCgAB0jWGrUHV/kGnMImwyADWaSRPQxnhdJJnPPfyeTZl6ry2cw TieMvS+m7J0mdxjjh+Oq/CyO43XOhFMs= X-Gm-Gg: AfdE7clslXHah41vfp6DvrZ2zqnEk64edYHs74/+p0rfnMWrqL/EzbDehIvpNoaShQ3 WePt3uzcIwwthEr5l+GokOB9Vcs0WF2jL+XUrDxInS4iUcYLlq83szy+Qp2XjpZKiqmcB0f940Z RtbgnOvM00eUR0V2RiD1c+9/b0T/8Av59AFlXbUHfL42XiVa0yU13j0VTqZbAQnQY4hySz65YGA zP5Y85DVyYYNYrR6SrOE8bqs/SD6rw5fm5J+Cqdbbdyjp2oVOgOPrV/fBAqyYHtjLAhgtVXJFak tkH7LMaEBOzDDlD4WA/B+ldye/aBg0u1MUHY9jWZr4U= X-Received: by 2002:a17:903:b8f:b0:2bd:8395:fedd with SMTP id d9443c01a7336-2cbb9f03560mr84577965ad.37.1783307526795; Sun, 05 Jul 2026 20:12:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Mon, 6 Jul 2026 08:41:53 +0530 X-Gm-Features: AVVi8CdYZd3wCdSuW38KhH0OzunJF-96XlRWOMVeGatvxshQT7sH2AqmDJy6nC0 Message-ID: Subject: Re: Support EXCEPT for TABLES IN SCHEMA publications To: Nisha Moond Cc: Peter Smith , Amit Kapila , 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 Fri, Jul 3, 2026 at 10:15=E2=80=AFPM Nisha Moond wrote: > > On Thu, Jul 2, 2026 at 2:19=E2=80=AFPM shveta malik wrote: > > > > A few comments: > > > > 1) > > postgres=3D# alter publication pub1 add table s2.t1; > > ERROR: table "s2.t1" cannot be added because it is excluded from > > publication "pub1" > > > > It will be good to add hint in above error. > > > > Suggestion: > > ERROR: cannot add table "s2.t1" to publication "pub1" > > DETAIL: Table "s2.t1" is currently in EXCEPT list > > HINT: Change EXCEPT list using ALTER PUBLICATION ..SET TABLES IN > > SCHEMA .. EXCEPT > > > > Please rephrase above as needed. Look earlier such messages/hints > > already added for ALL TABLES. > > > > Updated the error as suggested, with a slight change in DETAIL message. > > > From the user's perspective, it seems slightly odd that if he has > > excluded a table from publication, he can not add it back using 'add > > table'. Was this point discussed earlier? > > > > This hasn't been discussed yet. > > I kept the current behavior, as IMO, it is hard to tell whether the > user is trying to re-include a table or whether the ADD is unintended > and should be blocked. To avoid ambiguity, I think EXCEPT entries > should be modified only through the EXCEPT (...) clause itself, such > as ALTER PUBLICATION ... ADD/SET ... EXCEPT(TABLE ...), or by omitting > EXCEPT in the SET case. > > This would also keep the behavior of ADD TABLE and DROP TABLE aligned, > as both would operate only on the include list without touching the > EXCEPT list. > I think this also aligns with FOR ALL TABLES, where ADD TABLE is > disallowed, so the EXCEPT list can only be modified through SET .. > EXCEPT (...). > > Thoughts? Okay. Makes sense. > > > 2) > > Currently: > > postgres=3D# alter publication pub1 drop table s2.t1; > > ERROR: relation "t1" is not part of the publication > > > > s2.t1 is EXCEPT list here. > > > > Should we have below error for this case rather than above generic > > error, it will be more intuitive for user. Plus both add and drop > > table commands will have similar error-style for EXCEPT list. > > Thoughts? > > > > ERROR: cannot drop table "s2.t1" from publication "pub1" > > DETAIL: Table "s2.t1" is currently in EXCEPT list > > HINT: Change EXCEPT list using ALTER PUBLICATION ..SET TABLES IN > > SCHEMA .. EXCEPT > > > > Makes sense. Fixed. > > > 3) > > Please see below test: > > > > --Setting Except list for pub1 which has all tables of s2 included: > > alter publication pub1 set tables in schema s2 EXCEPT ( TABLE t1, t2); > > > > --pg_publication_rel entries: > > pubname | schema_name | table_name | prexcept > > --------+-------------+------------+--------- > > pub1 | s2 | t1 | t > > pub1 | s2 | t2 | t > > > > > > --Then added a partition: > > alter publication pub1 add table s2.tab_part_1_p2; > > > > --pg_publication_rel entries: > > pubname | schema_name | table_name | prexcept > > --------+-------------+---------------+--------- > > pub1 | s2 | t1 | t > > pub1 | s2 | t2 | t > > pub1 | s2 | tab_part_1_p2 | f > > > > > > --Then changed pub1 to exclude tab_root (parent of tab_part_1_p2) as we= ll: > > > > alter publication pub1 set tables in schema s2 EXCEPT ( TABLE t1, t2, t= ab_root); > > > > --pg_publication_rel entries: > > pubname | schema_name | table_name | prexcept > > --------+-------------+------------+--------- > > pub1 | s2 | t1 | t > > pub1 | s2 | t2 | t > > pub1 | s2 | tab_root | t > > > > Note theoutput above, tab_part_1_p2 is removed internally as part of > > earlier command since its parent tab_root is now excluded. > > > > --Now add parition back, it allowed to add it: > > alter publication pub1 add table s2.tab_part_1_p2; > > > > pg_publication_rel entries: > > pubname | schema_name | table_name | prexcept > > --------+-------------+---------------+--------- > > pub1 | s2 | t1 | t > > pub1 | s2 | t2 | t > > pub1 | s2 | tab_root | t > > pub1 | s2 | tab_part_1_p2 | f > > > > > > FOR ALL TABLES publicaiton, if root is excluded, there is no way > > publication can have parition included independently. Same should hold > > true here. Thoughts? > > Right, based on the discussion at [1], since we follow "all partitions > are excluded if the root is excluded", a partition child should not be > allowed to be added when its partition root is already excluded from > the publication. > Fixed. Such an operation will now raise an error: > > 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. > ~~~ Okay, looks good. thanks Shveta