On Mon, Feb 16, 2026 at 8:50 AM vignesh C <[email protected]> wrote:
>
> Thanks for the comments, the attached v44 version patch has the
> changes for the same.
>
I’ve started reviewing/testing the patch. Few comments:

1) File - /doc/src/sgml/catalogs.sgml
       if there is no publication qualifying condition.</para></entry>
      </row>

+     <row>
+      <entry role="catalog_table_entry"><para role="column_definition">
+      <structfield>prexcept</structfield> <type>bool</type>
+      </para>

Should the column order in the doc match the order in
pg_publication_rel? In the table, the "prexcept" column appears before
"prqual", whereas in the doc it is listed after.

pg_publication.c: GetAllPublicationExcludedTables()
2) There may be a scope for optimization in how relids are processed.
Each time a new parentid is appended to the relids list, the first for
loop:

+ while (is_parent_in_except)
+ {
+ List    *parentids = NIL;
+ List    *curr = NIL;
+
+ foreach_oid(relid, relids)     <<< this
+ {
+ Oid parentid;
+
+ if (!get_rel_relispartition(relid))
+ continue;
+

reprocesses all existing relids. Could we restrict it to check only
the newly added relids and avoid redundant work? Does this make sense?

I also feel the function would benefit from a few brief comments to
clarify the logic.

The attached file has the changes for the suggested optimization and
few comment suggestions for the function, if they seem suitable.

--
Thanks,
Nisha
diff --git a/src/backend/catalog/pg_publication.c 
b/src/backend/catalog/pg_publication.c
index 17b821fbd71..9fb121d9b0f 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -872,16 +872,16 @@ List *
 GetAllPublicationExceptTables(Oid pubid, PublicationPartOpt pub_partopt)
 {
        List       *relids = get_publication_relations(pubid, pub_partopt, 
true);
-       bool            is_parent_in_except = true;
+       List *new_relids = list_copy(relids);
 
        Assert(GetPublication(pubid)->alltables);
 
-       while (is_parent_in_except)
+       while (new_relids != NIL)
        {
                List       *parentids = NIL;
                List       *curr = NIL;
 
-               foreach_oid(relid, relids)
+               foreach_oid(relid, new_relids)
                {
                        Oid                     parentid;
 
@@ -916,9 +916,8 @@ GetAllPublicationExceptTables(Oid pubid, PublicationPartOpt 
pub_partopt)
                                curr = lappend_oid(curr, parentid);
                }
 
-               if (curr == NIL)
-                       is_parent_in_except = false;
-               else
+               new_relids = curr;
+               if (curr != NIL)
                        relids = list_concat(relids, curr);
        }
 

Reply via email to