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 1wZLWz-000xu5-2m for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jun 2026 04:36:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wZLWy-00F88E-2D for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jun 2026 04:36:08 +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 1wZLWy-00F886-19 for pgsql-hackers@lists.postgresql.org; Tue, 16 Jun 2026 04:36:08 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wZLWv-00000000efZ-2rWX for pgsql-hackers@lists.postgresql.org; Tue, 16 Jun 2026 04:36:08 +0000 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-842307473b5so2840359b3a.2 for ; Mon, 15 Jun 2026 21:36:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781584563; cv=none; d=google.com; s=arc-20240605; b=YapAgnbP9UqRqlXAm3okIXFtP0vr585QrB+jfVseoVPESmGujLmnHi8SIs/5QnswJl BY4/+JQHHNpX0JvvyW19thorC5U1RVNPF+wPyhx1UoNbrer7JHfMd4smjY7swpVMW7Zz ryT+DzbyoFA6DTPeMPbEPT9eRX/lDWsWhyc/srNQQjRl6qelUwtnhIrf6VZcX5CqD6+i NLISzc1bp7RZ5FAdEwNL3Qr6/mrBDqmIWNnqtoW039e0H360eympDLvLx9gKIyexm8iv 4bvj+gWFIC97il4pQd4gTUsUyATw3r8TkhQlJQoTQ2T/ifYH0xrBWkKUIqNmSkfCgDaU yjsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=QOcM+doRNzTvkOiQOsidG+pp2/BYm/UrzGzXJe0kH90=; fh=xk5bFEkKXYksIRTFwIsoF/0hTuyM0Zfg3nou9ELAkvA=; b=jsCLow4cc0/nLLYFLtRcU0xl/YvmMswnLq9g0kyKhMT/Y5XQFcUvCAXnnGUDt7M0Ej V1W7jPOUEgLlhlibeVPzgUbYLlFakp0et31gtTTNW2dG62+8PPAk2hXtSYJcUvSQ2aqJ 0ajZ6v5bUGVgf8Q2Et0Cvd5OciG72YE4Z1szLkiSh77Xmnlnw04i/W+QAM1v63Wy2oho IQCxU1+fK4sPxwgCD9U4Y94VR3WND+5BlblCjl2sidwfkh5iDhtECH//icXbudjmYHZn zDkJKiwkz2W+Q+eLHqRMlrVwzDu2A7bDKxMAppkOUN8AuhymRrN6+wDHBmCZPqE3850A WqCw==; 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=1781584563; x=1782189363; 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=QOcM+doRNzTvkOiQOsidG+pp2/BYm/UrzGzXJe0kH90=; b=bbO1+pHYiZZu6hzYO8m/674VDI2gUvtzFEZxDJ4L59L21JX93FcWFNNc1LJP3zM9JZ szVDZ+aDAHe1Qft3Ow2NZ6dADTgR2ytFULccn1ZliJd4H2aIhoYZfgXH5lTXEfiQouuO lm7F3ge9XMOfjnVJ0ZITncpVJ3lyjDTc4Nu2AWh/sBaM+wTBsLMou+Mo50AEn6UpQGnK 9WDyK0P9jwDT5Z8DVp8ubexRh+ucRVI69cyH/jmtgG6vd7ZRkMaJTXSj8GQ58HSp/aDF qHhmNonmimzM7YrlmPrF78zjzZLvxgSEdY+ML6rwE/8pQBz35wfya8p3x4ht97sZ0tSm p8FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781584563; x=1782189363; 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=QOcM+doRNzTvkOiQOsidG+pp2/BYm/UrzGzXJe0kH90=; b=DDrjLBTY23qOLLI91NPFjeweKEkOb7HM9VbwMhRGPpDXxoDEdPIjzJ3mhC2KPNwXA0 8thBpebLsDcgH3re1XJ1QEPUokuk38x8FE9BYcIyxIouvttVCC19hxD4wijpayeRRd2a s180S4rP5sK5ritehoYaxkpD2MzI0G/dgMr973pn4jft56/a3lqbBV9z6k6nNjPr+cbP 0mtUXdVJoQN7QM5QFlbyix41DDF706RZ/RcwodHKpCqLssoBIBEhdIiR4jwqot39toFe jiOlNVZJwFUE4+IY8rhYqlnHseNI7YwooGH8rBgo+AN1rZ9lTA3RfHEbFb0FbXRa+C+t I4fA== X-Forwarded-Encrypted: i=1; AFNElJ/dAXgorN1YiSHFkKv+lQUFp8QWaK8X3gqrmFyrm6vL2Pl1TIrOPufItt86qGdU5Qbk9MMtcENTf+H2Vc5F@lists.postgresql.org X-Gm-Message-State: AOJu0YzH293GGAhDRyZkA9Ej7qUn0NZ5LC85ZSABmitLpunLvEVg6qlO zxnyRWWeh1NBrD7KFSCjJZj9r520+hS75+qaxQ3cBfCbBPoiQv3K3J/2MaD2eYVjqxJr3kMARex tdo4Qq+i+ZIwpOn2fpL4TKLNpsBvWko8= X-Gm-Gg: Acq92OEgfhcqAW3CFuny+6qwUhxEEiCO0lu5oAPFcMy3ggBaDD3uqG3M/t4YvsHXT6G ZdZN24m0y2gcMFM3p0r6QPaQGi1RVF9A9oNKLg50ewA16BV0XIMf0RWPXSU9/JbFIAb5z6ccW6p tkMhvufcGFvFoZ2PjZ2pavKbZVGwfiBa7tn16FkSC0gI3cgodmceYuQM4LA5iTuEXG3NOfjGNIA d3wkAexuHaI5w/x6OM81NuSCNLc1MRp55cTZGRaE8WIKyFUu+7QQaNhxdbqYh3illVuasw/0/sL tdztQCS+u/NW9/FdZ/q7qWVDpZlQVEA7BThnBhePuKBaM5BDGssbNH4LPudZRGznuULb0dK0zj+ fTYFQJJCObX1vIAf0Ig== X-Received: by 2002:a05:6a00:189c:b0:841:dc8d:8066 with SMTP id d2e1a72fcca58-8434cec14d9mr18732055b3a.39.1781584563144; Mon, 15 Jun 2026 21:36:03 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Tue, 16 Jun 2026 10:05:51 +0530 X-Gm-Features: AVVi8CfvIbBhQRJfatoXBW0X6pDv66mzNKPPbOc-clF3jWdXBJFSfsmjETU8reY Message-ID: Subject: Re: Support EXCEPT for TABLES IN SCHEMA publications To: Peter Smith Cc: Nisha Moond , Zsolt Parragi , pgsql-hackers@lists.postgresql.org 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 Tue, Jun 16, 2026 at 6:52=E2=80=AFAM Peter Smith = wrote: > > This discussion about the impact of ALTER TABLE ... SET SCHEMA made me > wonder what happens for the existing PG19 case of FOR ALL TABLES > EXCEPT (TABLE ...) > > It turns out to be quite different: > > =3D=3D=3D=3D=3D=3D > > test_pub=3D# CREATE SCHEMA myschema; > CREATE SCHEMA > test_pub=3D# CREATE TABLE t1(A INT); > CREATE TABLE > test_pub=3D# CREATE TABLE t2(A INT); > CREATE TABLE > test_pub=3D# CREATE TABLE myschema.myt1(A INT); > CREATE TABLE > test_pub=3D# CREATE PUBLICATION pub1 FOR ALL TABLES EXCEPT (TABLE myschem= a.myt1); > CREATE PUBLICATION > test_pub=3D# \d myschema.myt1 > Table "myschema.myt1" > Column | Type | Collation | Nullable | Default > --------+---------+-----------+----------+--------- > a | integer | | | > Excluded from publications: > "pub1" > > test_pub=3D# \dRp+ pub1 > Publication pub1 > Owner | All tables | All sequences | Inserts | Updates | Deletes | > Truncates | Generated columns | Via root | Descri > ption > ----------+------------+---------------+---------+---------+---------+---= --------+-------------------+----------+------- > ------ > postgres | t | f | t | t | t | > t | none | f | > Except tables: > "myschema.myt1" > > test_pub=3D# ALTER TABLE myschema.myt1 SET SCHEMA public; > ALTER TABLE > test_pub=3D# \d myt1 > Table "public.myt1" > Column | Type | Collation | Nullable | Default > --------+---------+-----------+----------+--------- > a | integer | | | > Excluded from publications: > "pub1" > > test_pub=3D# \dRp+ pub1 > Publication pub1 > Owner | All tables | All sequences | Inserts | Updates | Deletes | > Truncates | Generated columns | Via root | Descri > ption > ----------+------------+---------------+---------+---------+---------+---= --------+-------------------+----------+------- > ------ > postgres | t | f | t | t | t | > t | none | f | > Except tables: > "public.myt1" > > =3D=3D=3D=3D=3D=3D > > This experiment shows that moving the table did *not* remove the exclusio= n. > > It is kind of "explainable" in hindsight because the exclusion is by > table OID, not name, so it follows the table around when it is moved. > I don't think this is what a user would expect, given that they > explicitly asked to exclude it from a different schema. > > Is it a PG19 exclusion bug? > > Is it behaviour that needs more documenting? > > ~ > > IMO it seemed like a bug of the PG19 FOR ALL TABLES EXCEPT, because it > is the opposite of what the new FOR TABLES IN SCHEMA EXCEPT patch > does: > "If a table listed in the EXCEPT clause is later > moved to a different schema using ALTER TABLE ... SET > SCHEMA, the exclusion is removed;" > No, I don't think this is a bug for PG19 and the new behaviour for PG20 is intentional and required because in this case, the EXCEPT clause is schema-scoped, so once schema is changed, the table should be removed from the exclusion list. OTOH, in PG19, the exclusion list follows the table-level exclusion based on its OID as we can see in the example provided by you. I think we can consider adding a line for this in docs if you and others feel that such explicit mention can avoid ambiguity around this. How about something like the following as a separate para in EXCEPT clause description: Once a table is excluded, the exclusion applies to that table itself, regardless of its name or schema. Renaming the table or moving it to another schema with ALTER TABLE ... SET SCHEMA does not cancel the exclusion." --=20 With Regards, Amit Kapila.