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 1vYFJ9-00GnUC-2C for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Dec 2025 03:13:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vYFJ7-003JHF-38 for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Dec 2025 03:13:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vYFJ7-003JH6-1i for pgsql-hackers@lists.postgresql.org; Wed, 24 Dec 2025 03:13:02 +0000 Received: from mail-qv1-xf2c.google.com ([2607:f8b0:4864:20::f2c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vYFJ6-002KRA-13 for pgsql-hackers@lists.postgresql.org; Wed, 24 Dec 2025 03:13:01 +0000 Received: by mail-qv1-xf2c.google.com with SMTP id 6a1803df08f44-8888a444300so60119686d6.1 for ; Tue, 23 Dec 2025 19:12:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766545979; x=1767150779; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=KYt3V9vTVMnpmbowfGoelD5BuS2Mp2zk872PnyEvdyA=; b=GToa8fRY9LbMH7GEu2wu87K+ZMn8ymkcezh8pNAKa4dp1ZSTXUyotab3OUjAt6mBnK hhd8SYokvgBgFtSMJMaudT+kDNZ2vZAZQ5YaH4CWA78JTo8w++QwYX2aaWFTYdNF/czA GYapWYoX9+SjZ5fAKueO5Pr0GVHiJN25TFUIVm69/wf9j9CQsteV1Tx81lhHhUNxZ8Up iGD0eLCTIR3XLt7A+nRYB8Jk5UEaYzH/j/R4EgMRS72RiGQgqWmre9jE59pBlBbFJh63 o/YotF/KbFYC0AL9ivUmqaWPbuSuV2kbR0SMka4jdc4S5KZMkjn3R197GLQoDPMx5AB/ eq3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766545979; x=1767150779; h=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=KYt3V9vTVMnpmbowfGoelD5BuS2Mp2zk872PnyEvdyA=; b=Ul3jNeQsFPM8UskAWj7GqZb94Dw37PdK0MuOuRJYFoE8zphy7NTAx/PJB36jvTV+ZR +nfCWx2g4w1Qn6S6Mhvy8qFxRAakND6lPIW7C9B8MEJ7g12TYZklzi5eMuLHfuIBbnOc +LP4+MKqKgIT36u9Tz0fHV/1AI5UNbmQXIJ6OeNqHFkpcmc3fJ8RJgKDu2kdazo4pLOi trDmC0sB5GfE78/ibcmV5c5v2s6+JX44XtPXzM8HvQyn4vdkeQRFmty7NS6lrN0cj/4S kBOOIOUWhDdmO1tKeguzWzRfZtBGiTtV/8V+K9Z6SnuHN4/lsVMkpnaDUNiPTNUqsio2 GuWg== X-Forwarded-Encrypted: i=1; AJvYcCXtJkwOl9NO+nsHLQpO9vaYxJ8dPFvgl9DlE70ynXc8NaQHXZ+c+uL7EBvOgE6VOzqFoWt2yW1bJx/WADHP@lists.postgresql.org X-Gm-Message-State: AOJu0YyAo15p9v8CTxMaYKY1Lo1WH5Vac272r69eDrJ1bL6Y8Adx0gTJ KQMo0zu5kD0GGtj2FBPErnz8bBUmiutdYzc0nAyf+982C2CuFv6GnahcnTTi+QyWKcloHVsEED5 354PiH7kWVELLS56l75ff6f082BxJT2A= X-Gm-Gg: AY/fxX7UfXjsq6OISif8ehhxoy8zexrvpcEADd8cVSg6hvnM1SiXmc2HeNoWrIaqumH IaljqBDxG9tNF+ra/2VNYmbbEgLpMeSgveRp0SCl1W2f2e6KRrRByWFywMfT9YMXdjEN4sAxtoX MD+ZoJTE4RDc7QaIU1SkTYKIjYAYpy/LvlnMELaPFRDfqWWP2csdjeU0Vd5N2wWoN+1FvM0RHGH +/iN606i/3lQVmhZRLgugltTABH04HBizGZ922R9aFs8FG5uxsA7UFk6eFTiXITryNICQQir6VC 6nqBpDvCu+VO4uGM7ZLk8y1dPmhZBCC3iIGnvgK0 X-Google-Smtp-Source: AGHT+IFR054pUAH/MyN/7SLIUX9u7VVj8uU1TBJ8LiEhH2zkfZz7JVX3aTC+4Gjxf2Nly2mqvVeL8dVC40eRlPC7Tls= X-Received: by 2002:a0c:ed43:0:b0:888:4938:49e6 with SMTP id 6a1803df08f44-88d859bf925mr222968086d6.70.1766545979153; Tue, 23 Dec 2025 19:12:59 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Peter Smith Date: Wed, 24 Dec 2025 14:12:31 +1100 X-Gm-Features: AQt7F2oEpaqm0hW5u2lkuIWY15lyiMek6fAAvUBEXBHjkh6MMDd-7mvNMLPMGdQ Message-ID: Subject: Re: Skipping schema changes in publication To: Shlok Kyal Cc: shveta malik , Amit Kapila , vignesh C , "Zhijie Hou (Fujitsu)" , YeXiu <1518981153@qq.com>, Ian Lawrence Barwick , Bharath Rupireddy , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Shlok Some review comments for patch v34-0001 (code) ====== src/backend/catalog/pg_publication.c 1. +static List * +get_publication_relations_internal(Oid pubid, PublicationPartOpt pub_partopt, + bool except_flag) No need to name this function as "_internal"; the snake_case name and static already indicate it is internal. ====== src/bin/pg_dump/pg_dump.c getPublications: 2. + if (fout->remoteVersion >= 190000) + { + int ntbls; + PGresult *res_tbls; + + resetPQExpBuffer(query); + appendPQExpBuffer(query, + "SELECT prrelid\n" + "FROM pg_catalog.pg_publication_rel\n" + "WHERE prpubid = %u and prexcept = true", + pubinfo[i].dobj.catId.oid); + + res_tbls = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); + + ntbls = PQntuples(res_tbls); + if (ntbls == 0) + continue; + + for (int j = 0; j < ntbls; j++) + { + Oid prrelid; + TableInfo *tbinfo; + + prrelid = atooid(PQgetvalue(res_tbls, j, 0)); + + tbinfo = findTableByOid(prrelid); + if (tbinfo == NULL) + continue; + + simple_ptr_list_append(&pubinfo[i].except_tables, tbinfo); + } + + PQclear(res_tbls); + } 2a. I suppose this code is for populating the list of all tables except those excluded, but there is no explanatory comment stating the purpose of all this. ~ 2b. BEFORE "WHERE prpubid = %u and prexcept = true" SUGGESTION "WHERE prpubid = %u AND prexcept" ~~~ dumpPublication: 3. + { + bool first_tbl = true; + appendPQExpBufferStr(query, " FOR ALL TABLES"); + + /* Include exception tables if the publication has EXCEPT TABLEs */ + for (SimplePtrListCell *cell = pubinfo->except_tables.head; cell; cell = cell->next) + { + TableInfo *tbinfo = (TableInfo *) cell->ptr; + + if (first_tbl) + { + appendPQExpBufferStr(query, " EXCEPT TABLE ("); + first_tbl = false; + } + else + appendPQExpBufferStr(query, ", "); + appendPQExpBuffer(query, "ONLY %s", fmtQualifiedDumpable(tbinfo)); + } + if (!first_tbl) + appendPQExpBufferStr(query, ")"); + } 3a. That code comment seems backwards. BEFORE /* Include exception tables if the publication has EXCEPT TABLEs */ SUGGESTION /* Include EXCEPT TABLE clause if there are except_tables. */ ~~~ 3b. Although it works OK, I felt the following looked strange: + if (!first_tbl) + appendPQExpBufferStr(query, ")"); IMO it would be better implemented as a counter: Replace bool first_tbl = true; with int n_excluded = 0; Then, + if (first_tbl) + { + appendPQExpBufferStr(query, " EXCEPT TABLE ("); + first_tbl = false; + } becomes + if (++n_excluded == 1) + appendPQExpBufferStr(query, " EXCEPT TABLE ("); And, + if (!first_tbl) + appendPQExpBufferStr(query, ")"); becomes + if (n_excluded > 0) + appendPQExpBufferStr(query, ")"); ====== src/bin/psql/describe.c describeOneTableDetails: 4. + /* Print publication the relation is excluded explicitly */ + if (pset.sversion >= 190000) The comment doesn't seem right: SUGGESTION Print publications that the table is explicitly excluded from ====== src/test/regress/sql/publication.sql 5. Missing tests. There are no test cases to show that \d is working for printing the "Except Publications:". ====== Kind Regards, Peter Smith. Fujitsu Australia.