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 1wSYtN-003GDC-3D for pgsql-hackers@arkaria.postgresql.org; Thu, 28 May 2026 11:27:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wSYtM-00BgF6-07 for pgsql-hackers@arkaria.postgresql.org; Thu, 28 May 2026 11:27:12 +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 1wSYtL-00BgEx-2K for pgsql-hackers@lists.postgresql.org; Thu, 28 May 2026 11:27:12 +0000 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wSYtK-00000001qY2-1pQL for pgsql-hackers@lists.postgresql.org; Thu, 28 May 2026 11:27:12 +0000 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-38e97e73234so15668911fa.1 for ; Thu, 28 May 2026 04:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1779967629; cv=none; d=google.com; s=arc-20240605; b=aEO1yg+G+PrHygXU7kzO49IcCpniWW0KkyPhQCMQhXSWw2gD4KCndzJv2a8FzUVI+b sYR1b0vCmt4Fq7zXJBE1TDTh1l94zyu15f07T7bl25ZChkPTtpM9gKmJZ21CsyGV+23c ad7GdDmTStclaiH/TLgsSW8TEMr/IUa+utfcyeGtdZ7au7HanEeIa9pGzzLE+kTnkJsq SYYs0PDUYnOCndBJ00qWBAlvleaP1vjKUJmoC1Ra00rNqmzWLXaeoR3r+zGfAFBfHroZ BQzB+H6lpKDmfw5DjeRqSwpukwlbCQc3d3IKPQcZhW/bUvgiCbPt3Wk4CGG0HjlGGM/k +5gw== 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=psTsYaEEuzKpevCTA4gcpRD59e4g93HIhdyT/xrHD54=; fh=+Lt490e6lB5E7HHXAdwbbycjWRPNWwMiJWWWH7+rEW8=; b=bSMNL815475kwrAasvx2/kMj66ripNG1wC4hiTBf6Sb3c0afjIESZA1dFZ/dHhLSEF LRUbp3e7ehTidSxHdRtZmNt4QCv9uxNCiytAjwmGL7/JWiZttjVOZpA6wtsd9q/fjzgv Nmxm97Z9Pe2ayvvIAlKOD1DXY2FizZwHBnKjpCTBFpDe6Qr8j0KeO+LXyJrmZ3fkXGe5 nBdjLDnaFReIBQjsQirCzRq7T68moGnQ9z7V2MKFTtF9MsevlzUQPcrZ1+wRn7x4+PCl Jt1lM62zCg0f3SOD6joDKxyKzAeuKm4XevBlLx1tJRpmTJhsv7HO6waYad9hDawb2hLM aFjA==; 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=1779967629; x=1780572429; 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=psTsYaEEuzKpevCTA4gcpRD59e4g93HIhdyT/xrHD54=; b=niEMlQBvsu0Es7CEI84lqwj+XJ6wNAa++6HFjcd7BwnjvvkHpVx7w0bKOLHzxiCJE0 5IrBqxnjrwiyWgSuswh000e/Zc00POwzPopjQ5NpSmh99QJ/q8CXLWj9ArQo8y0fS7CW ik3UQ4WI8kv/uQoZZ6Ppv4prPzG68gMXkzlHm/YDG/8DX1/VjqDDXHsgIO1joR63TvwW zcv6MoR+YtUxakH3/8cG9eVCCvZWpEHRgRtT9yFMl3E3gCrFf3o5NZlWHB5QXSVYIWuV zQfrudrccL8JUjS9cFKy7Ooh178+l6+JuNp+NQ306GdGupXu7EskcbrC01QPYMam8FKm S5cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779967629; x=1780572429; 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=psTsYaEEuzKpevCTA4gcpRD59e4g93HIhdyT/xrHD54=; b=UsSi1pRd0tuosxM+w89PA9jc7bDhOJnAYb1NV0yRTqjPCtLBa/OX6QpIkN7U1u86jh 8NG8jwHalK6GHWD30YxVnyimIE1zGEui19j5Wj/xnHs0kvsPqUV6Bn5cKNiRpiPH5fSc gGUXAihxpOpYRr5gZt0n2WZS2BYiwT5Fis++hT4bQBG6sOI47p6d74YloPhypuuBq+1R wQWonkRWbfTmOMDWGG0WDc3fMJaQZ9tnUTw6AfmdK8sgCl7zCsHdyaQ+O4cqvyEFgudb briY/UP96NXWJP901JkF/1Hs9n4eqVOmIIEulBDbbaEmXEJW/KL/27GGy4HrDELNqX/+ odXQ== X-Forwarded-Encrypted: i=1; AFNElJ+dmmUunyUk8pAP05BIt1MvlMhJorzj46MO25Z48ZMCcMI3KniuD/vK1PEGkPgPoOUWe10T4IRsypHC7DyR@lists.postgresql.org X-Gm-Message-State: AOJu0Ywr8JCFjg/np5drIDDC3Fut0rCYFs9JNOz8QnmegHWdkbDHwaOr 5BDsovT2z5/n+/esk5kvVLTXx9pmvUV4A+QhV/5kQ5tiCAbE7HtcZgXe9XYtO9h5hkJOInW8eFh B73rBwZV23P5nbLg54Uha9FX0S5pMZQ== X-Gm-Gg: Acq92OHQGBdiWcGDwT12VzLlStj6efn+clt3/XByqz9bwA8bvdpLgzT7+LafaslUtlw /yP1aBVXM0mQukTXhQsKc8ke3kbm5rmORxrYHzygqqF+/7FVUcL4WfxY/WYZ6xxdveb3iKAs6eo 8QqdI9LyTHMeNGAE3shZyjmb3n2IBmKl9hMYOYORrq05HTcJSiwVmJ8a4IVu/h04KH4xaPaMdg3 DipVa6UdOO2wXMLcJZvR+LvWDxhyPrmSP2GvM1UtxGMEqMYJUt7lAxt2XCscdj0uFsHC8Z3ungP 2acGyLQV9y0mrb9s3a3DTvxM6ugJrZw7NPusS2H47ja4sAEvqg== X-Received: by 2002:a2e:8e7b:0:b0:38d:ed62:f1d5 with SMTP id 38308e7fff4ca-395d8d1d662mr57463981fa.17.1779967628541; Thu, 28 May 2026 04:27:08 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Nisha Moond Date: Thu, 28 May 2026 16:56:56 +0530 X-Gm-Features: AVHnY4K69g98qcd7IVrzVUcw6qjHdrYjUSLLqtF49_MEMxWG1FdvjIpLMfb6Fis Message-ID: Subject: Re: Support EXCEPT for TABLES IN SCHEMA publications To: Peter Smith 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 On Fri, May 22, 2026 at 7:57=E2=80=AFAM Peter Smith wrote: > > Hi Nisha. > > Here are some review comments for patch v6-0001. > Thanks for the review. All comments are addressed in v7. Please find responses below for a few of the comments. > =3D=3D=3D=3D=3D=3D > src/backend/catalog/pg_publication.c > > GetTopMostAncestorInPublication: > > 1. > +GetTopMostAncestorInPublication(Oid puboid, List *ancestors, > + int *ancestor_level, List *except_pubids) > > I am having dificulty understanding this function. There needs to be a > description what does the input parameter 'except_pubids' mean. The > param name doesn't tell me anything much -- just that it is a list of > pubids that "something" (what?) is excluded from. And how does that > relate to the 'ancestors'? > Updated the function comments to explain except_pubids. > ~~~ > > 2. > { > aschemaPubids =3D GetSchemaPublications(get_rel_namespace(ancestor)); > - if (list_member_oid(aschemaPubids, puboid)) > + if (list_member_oid(aschemaPubids, puboid) && > + !list_member_oid(except_pubids, puboid)) > > Is this new code in the right place? I'm not 100% sure of the > 'except_pubids' details, but shouldn't it be checked sooner? e.g. if > we know already that this pubid is no good > (!list_member_oid(except_pubids, puboid)) then what is the point to > even assign/check aschemaPubids? > except_pubids represents the set of publication OIDs from which the root relation has been explicitly excluded via EXCEPT (TABLE ...). But yes, we can check it before computing schemaPubids. Fixed. > ~~~ > > 3. > + if (is_except) > + ereport(ERROR, > + (errcode(ERRCODE_DUPLICATE_OBJECT), > + errmsg("table \"%s\" cannot be added because it is excluded from > publication \"%s\"", > + RelationGetQualifiedRelationName(targetrel), > + pub->name))); > + else > + ereport(ERROR, > + (errcode(ERRCODE_DUPLICATE_OBJECT), > + errmsg("relation \"%s\" is already member of publication \"%s\"", > + RelationGetRelationName(targetrel), pub->name))); > > Fully qualified 'targetrel' in the first error, but not in the second? Is= it OK? > IMO, we should use fully qualified names in both cases. Though the second error is not part of this patch, I=E2=80=99ve updated it as well. Please let me know if you think otherwise. > =3D=3D=3D=3D=3D=3D > src/backend/replication/pgoutput/pgoutput.c > > get_rel_sync_entry: > ... > > 5b. > Actually, this is becoming a GENERAL comment. There too many ways that > these EXCEPT tables are getting named, and it is causing confusion: > - except_pubids > - exceptlist > - exceptrelations > - exceptrels > - except_relid > - except_tables > - schemaExceptPubids > > Can we standardize on some common names, to make all the code more consis= tent? > I have now used the "except_" prefix consistently for all names to avoid confusion. Also updated the naming in all places as below: except_rel_names: parse-level table names in EXCEPT except_rels: internal relations in the EXCEPT list (opened/accessed) except_relids: list of relation OIDs wherever used except_pubids: publication OIDs from which a given relation (or its root) is excluded > ~ > > 5c. > Previously, the result of 'get_partition_ancestors' was being freed, > but now it is not. I'm not sure how importatnt that is, because I > found other examples in PG source code also not freeing... > Sorry, this was mistakenly removed in v6 while cleaning up the code, and I did not verify it against the older version. Fixed now. > =3D=3D=3D=3D=3D=3D > src/bin/psql/tab-complete.in.c > > 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? -- Thanks, Nisha