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 1wSpoo-0008Uc-2W for pgsql-hackers@arkaria.postgresql.org; Fri, 29 May 2026 05:31:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wSpol-001bMt-2u for pgsql-hackers@arkaria.postgresql.org; Fri, 29 May 2026 05:31:36 +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 1wSpol-001bMl-1r for pgsql-hackers@lists.postgresql.org; Fri, 29 May 2026 05:31:35 +0000 Received: from mail-qv1-xf33.google.com ([2607:f8b0:4864:20::f33]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wSpoi-000000005O3-3hEp for pgsql-hackers@lists.postgresql.org; Fri, 29 May 2026 05:31:34 +0000 Received: by mail-qv1-xf33.google.com with SMTP id 6a1803df08f44-8ccdef9f3d4so8923946d6.2 for ; Thu, 28 May 2026 22:31:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1780032691; cv=none; d=google.com; s=arc-20240605; b=TVel91JR9fwB4JFV9wnFqf9nRuqGCFexhYK8CrxJg3jglWT0YuzJlw9ksjvfs02oIr zo/mu06es13PgoxxupmMt4gLRdQn0nW43yz9uTa486m4C1kZXhG6gcjMRdZZQaGzZCu2 34pFse7m8I7oUCuNl//wzlJwVQPBnCScOFhOFQi1skuYVbO9/I8LyO9sbwOdWUz20VLs Mz1/uHpue+RvtGB4zSv5yfXm6RwMSWT4/MGFoNGvgMNtyXxOJkchroc+/6CPWldsXC/4 i+oTv5nBfMAmBeMDR+hpAoEQYh+/BpBnPPPegkCaSHWQbiAtvWBvo5AnexQw7hHQlzxo 8+gg== 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=OjJDzmDH94adca63orp46b6dY608Fd5zDEwVPin1efo=; fh=++i4n/3yxAvLy6KJQAxcH9NbgoVLv8dovN8rQC+AMYI=; b=H9JELfCC7w+N5fXLfm/qmhdNIwPF3C7QK2SCzR2BRXfKtD/u3CxnUDVc46CDu12gBv 6K1wzD2fDgugUxAN/w8BAKdyyKWWX5/sILfHViYlxBIQPgX9+a/3lOBBnaDUa+5CSbrk HE1uFwoaub7MtC9rZlr/+yVFKg76KTa4wozzdadY3I1DH6FHn7VljDuMkS/0BZ6yM+57 TUgsLuo1K35vm/2Gsnxe+QdMF426O6TpoHSiaBpKSka1VwlOBD/7bT97TLnsneyKsPfD XNK8ftWbLZeiPoONxz7UcZe6nhPOJE168ga3C7XOmBVGa7KHVmqrldO3kXu68/GSqfki 4GSA==; 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=1780032691; x=1780637491; 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=OjJDzmDH94adca63orp46b6dY608Fd5zDEwVPin1efo=; b=jJG+yMYc+PJew6akI7OMDAulxBEEQTVJBqiI4UMlJW/LXQUYxfPaBl1EMGLTVkwWtI nqOpHw5B/tKt6O1k9ptd5EpMVwly6YRc9Th1ORdQQKEdX/YDYKtmYGtnGxWK1XbX2nAm 01xQt955oLGVpIgIRkFfeNTMAXiWdxxoZRk+QILF+4T29VprhUutKyjjuKyIRP7JH1wo l7dKUqgkxBcgYPKpU13bmuP2bSSV8Dfb8/KaP+ov0ABLAXlet9rccQYcjAR3VhxS7Puw FS0N4PbGbufBzAb49QsitjkMLLFyrpCENg1PO7uv5stOdHwZEfcOVScFPMX+cfahyADm UpAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780032691; x=1780637491; 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=OjJDzmDH94adca63orp46b6dY608Fd5zDEwVPin1efo=; b=Hh8uSS3RQXNRuqjcz0jI7t6kaGIZ5pnXqji3QliRLmGXMgqWp5VlObcY57nYlrS8bu TVfIbtuLtifW7YMHGeMUa8cMei5/XPQl3j0EQb+fo6kVXiPDLBNdynWV8KbZODrw/qQT 01cwrI93tmCdrOkBLaGc/6ipQNySGuWuWjtc7ZYnw5EMTsoRW77pd+QG04NFczYS6kGJ 3xZz/rdwGSgaQk1v9f9oKKeS6p8inxhAWay5rHf6Jrbe3HVkPKDQqdnTtp1Rqfga9wVJ WlmvN39B/CBUmEjHSpn9qfmFfxd5N/GE34KcaxUxv8Qly6dLTTjxTrfT5dNFE4rySdzZ orhA== X-Forwarded-Encrypted: i=1; AFNElJ/mrvDQn3gv/SAvJ0xpl0zuOyfo4fqb9tz6hecpFSMb+uQvBAMz6EH7aH5mgi7DocaCKH0NYJKLr4nyoXJM@lists.postgresql.org X-Gm-Message-State: AOJu0YxxmAXeYEUsOyi3Vy6ilHCJetM1dy1WpVyUGlvZsM0zMtVZYXlS 0U+fehl4g18j/p9X7VYHeAeFlwOk14/UTzBMJaDWG317LpvkK1q/hSWiQ/oug9uN+EiQcqTKctt EYUPaA5ckSGDV0t9Rep5uJv2Ke7q6nqM= X-Gm-Gg: Acq92OH3vSuwAVpp6n//y67IQovwlqqmCIDeHbWLv/OdzURSRyg67rcs2Q4PROqUakH ivGq97zSrZ7Q/40O/soGSEgZfDLiOBnf5YuPEQaV+clxDL5M6zBG9ABtOHo9aXmFcqaVWA3f2/H 1dz6mt2zWieEu/OkapUvjnah7OXhcS355AJ7XFXW03dYY5RJxHdpq3OvG3vzPIH4iBRQ3df786R rHvEBRhoPZMu3ZT5Ouv9sdnF9rCfL54QP1RPDvSOlTl63x0nxJFNNJ8zDwLc9T3FhJvLXMuhdSP 2V/Mqfr5dFFZJ2D9HQ== X-Received: by 2002:a05:620a:319f:b0:911:e37f:d80d with SMTP id af79cd13be357-9152fe10cccmr176805585a.48.1780032690572; Thu, 28 May 2026 22:31:30 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Peter Smith Date: Fri, 29 May 2026 15:31:01 +1000 X-Gm-Features: AVHnY4KYozsdLdi4ZWeWqty9ja4uftZg2trUZrLH2pxI7JphjsPqof8C54K1wgw Message-ID: Subject: Re: Support EXCEPT for TABLES IN SCHEMA publications To: Nisha Moond Cc: shveta malik , Amit Kapila , PostgreSQL Hackers 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 Hi Nisha. Some review comments for patch v7-0001. =3D=3D=3D=3D=3D=3D src/backend/catalog/pg_publication.c GetTopMostAncestorInPublication: 1. - else + else if (!list_member_oid(except_pubids, puboid)) { aschemaPubids =3D GetSchemaPublications(get_rel_namespace(ancestor)); IIUC this `except_pubids` and `puboid` are not changing, so you do not need to be doing this member check every loop iteration. Is it better to assign some variable up-front? e.g. bool check_schemas =3D !list_member_oid(except_pubids, puboid); ~~~ publication_add_relation: 2. + if (is_except) + ereport(ERROR, + (errcode(ERRCODE_DUPLICATE_OBJECT), + errmsg("relation \"%s\" cannot be added because it is excluded from publication \"%s\"", + RelationGetQualifiedRelationName(targetrel), + pub->name))); I am unsure about the changed wording from "table" to "relation". IIUC we say "relation" when it could be either a table or a sequence. So maybe "table" is correct for your patch;l OTHOH this should change to "relation" by Shlok's EXCEPT SEQUENCE patch [1]. ~~~ 3. + ereport(ERROR, + (errcode(ERRCODE_DUPLICATE_OBJECT), + errmsg("relation \"%s\" is already member of publication \"%s\"", + RelationGetQualifiedRelationName(targetrel), pub->name))); IMO making everything fully qualified like this would be a good change, but doing it here perhaps does not belong in your patch. I have resurrected this question in the other thread [2], which would affect not only this statement. but many others. Please post your opinion about this on that other thread. =3D=3D=3D=3D=3D=3D src/backend/commands/publicationcmds.c ObjectsInPublicationToOids: 4. static void ObjectsInPublicationToOids(List *pubobjspec_list, ParseState *pstate, - List **rels, List **exceptrels, List **schemas) + List **rels, List **except_rel_names, List **schemas) Is `except_rel_names` an accurate name? IMO it makes it sound like it's a list of char* names, but IIUC that is not the case; aren't these PublicationTable objects? Would something like `except_pubtables` be more correct? ~~~ CreatePublication: 5. - List *exceptrelations =3D NIL; + List *except_rel_names =3D NIL; Same doubts about this `except_rel_names` variable name. ~~~ AlterPublication: 6. List *relations =3D NIL; - List *exceptrelations =3D NIL; + List *except_rel_names =3D NIL; Same doubts about this `except_rel_names` variable name. =3D=3D=3D=3D=3D=3D src/backend/replication/pgoutput/pgoutput.c get_rel_sync_entry: 7. + if (am_partition) + { + List *part_ancestors =3D get_partition_ancestors(relid); + + root_relid =3D llast_oid(part_ancestors); + list_free(part_ancestors); I think just call this `ancestors` (not `part_ancestors`) for consistency with other code in the same function. =3D=3D=3D=3D=3D=3D src/bin/psql/tab-complete.in.c On Thu, May 28, 2026 at 9:27=E2=80=AFPM Nisha Moond wrote: > > On Fri, May 22, 2026 at 7:57=E2=80=AFAM Peter Smith wrote: ... > > 6. > > + else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "TABLES", > > "IN", "SCHEMA", MatchAny, "EXCEPT", "(", "TABLE", MatchAnyN) && > > ends_with(prev_wd, ',')) > > + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables); > > > > I'm not sure if this is working as intended. > > > > When testing for multiple except tables I get results like: > > ---- > > test_pub=3D# create publication pub1 for tables IN SCHEMA myschema > > EXCEPT ( TABLE WITH ( > > test_pub=3D# create publication pub1 for tables IN SCHEMA myschema > > except ( table > > test_pub=3D# create publication pub1 for tables IN SCHEMA myschema > > except ( table myschema.t > > myschema.t1 myschema.t2 myschema.t3 > > test_pub=3D# create publication pub1 for tables IN SCHEMA myschema > > except ( table myschema.t1, > > information_schema. myschema. public. t1 > > t2 t3 > > ---- > > > > Note: it is offering suggstions for schema names outside of the > > "myschema". Should this code be calling > > Query_for_list_of_tables_in_schema instead of > > Query_for_list_of_tables? > > > > For this case, I don't think it's really possible to keep suggesting > after a comma. Even if we handle a fixed number of comma-separated > entries, the same problem reappears with the next entry. > Query_for_list_of_tables_in_schema needs a correct schema reference, > but with each comma the relative offset changes, so there is no single > fixed prev*_wd that can reliably point to the schema across all > entries. > > But I see, the current call to Query_for_list_of_tables is clearly > incorrect here. I have now suppressed suggestions after a comma, > instead of showing incorrect suggestions. > Thoughts? > 8. REPLY: Yeah, I don't have any good ideas how to fix this, or if a fix is even possible, but I agree that doing nothing is better than doing the wrong thing. ~~~ 9. BTW, the current code is not able to handle multiple schemas. So, this works: test_pub=3D# CREATE PUBLICATION pub1 for TABLES IN SCHEMA myschema EXCEPT ( TABLE WITH ( but, this doesn't do anything: test_pub=3D# CREATE PUBLICATION pub1 for TABLES IN SCHEMA public, myschema = =3D=3D=3D=3D=3D=3D [1] Shlok EXCEPT - https://www.postgresql.org/message-id/flat/CAHut%2BPsUrYmbZ996ZybjMWvpW_ufX= B8WM94pdvAPyzQpoe%2BHRA%40mail.gmail.com#579d9b99c4f620602085cc59ff0e2b7d [2] schema-qualified messages - https://www.postgresql.org/message-id/CAHut%2BPvWoOyLKFb627Ch%2BXg3TYHuHdaO= Z_XmxYgKVYdOzpqFsw%40mail.gmail.com Kind Regards, Peter Smith. Fujitsu Australia