Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1npMaZ-0000wR-KT for pgsql-hackers@arkaria.postgresql.org; Fri, 13 May 2022 04:07:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1npMaY-00033E-Dr for pgsql-hackers@arkaria.postgresql.org; Fri, 13 May 2022 04:07:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1npMaY-000335-2L for pgsql-hackers@lists.postgresql.org; Fri, 13 May 2022 04:07:38 +0000 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1npMaV-00039q-Tq for pgsql-hackers@lists.postgresql.org; Fri, 13 May 2022 04:07:37 +0000 Received: by mail-qt1-x833.google.com with SMTP id x9so6010285qts.6 for ; Thu, 12 May 2022 21:07:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0VGJth287jmRAWoHiZWHM5lll5lbi+dkl8LGL8OdTMc=; b=OkWyhuIeWmiCfgXd1fuFBu+WPmb/Vq8ryGBX08H0CuWbKvOXqtuZQgMSSVoZtHJySu zYrtkVCA9g/B/pnLlXqjErGptbYh8nPDH2bq4fQ72wPruh06EuKoKZTusg4+1RQNor1M BPYIE98QrNe0bfcpugqh0wWgcCOK+d7Tm8DsSdhrb2JnKETPTo6I+MKd87aApdh2IlPi CUjKHSw6YRp4xnU4tfmrqalwM5sBcf8q/qy71X9sOayvoHK39chlKPagQw6mi8GbgLju R/5YQ3p4lmgPcZXJXNsngr4o8Q7NKCsELH/6di/YuYFv+6RGD8trwu97HgGhLUJiZ8+T geDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0VGJth287jmRAWoHiZWHM5lll5lbi+dkl8LGL8OdTMc=; b=OvuCYNyWYYz2rroDLfP017zma7Ro+ThX9F5jspnjTZk5RwQ0H9CG8SEioxuXsMYOnx Iv2pNFCxA5Cnbc/QmPW1jrL2CiUdrh1JQe04q3DGGL9opg6b5+YrDcrmgHqbIbas81sx c6+QsBWQHyAkaRl2I8rgLIF1sy9xAEpWFaOIzXELbeP96nqIXLd+CwJ9j0U5AYJfyqjn FwMuzyw9hc6ZrnbeidjeEhx0otVjlbifGy5YIffq+M30yQTg9aS/uTdm43feh6nodyOl teMqAbxoSYCnS3Tn8LvN6mZzgT70eRuTOmccPGF754qqot9vgsswKWLTfYHH3cc3MroT ZdBw== X-Gm-Message-State: AOAM532fnWTEGZ5dRNJFDvClsXo12qky/7io7RTf5G0n4LXwpHWNnyZA z923OyIOi9QiReRR9OGNtarXRgUOLy0YALSHfuiOvOQ2uK8= X-Google-Smtp-Source: ABdhPJw2RYGTMwToffuZR26+yq3TVl/0USmi6C2iEcgV+5aB4uZE4fwY5cXXRFQ2XRSshHF4ypYpNihATzDeWJGsTxs= X-Received: by 2002:a05:622a:1ba2:b0:2f3:b76a:a048 with SMTP id bp34-20020a05622a1ba200b002f3b76aa048mr2867472qtb.79.1652414853375; Thu, 12 May 2022 21:07:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Peter Smith Date: Fri, 13 May 2022 14:07:17 +1000 Message-ID: Subject: Re: Skipping schema changes in publication To: vignesh C Cc: Amit Kapila , 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 On Thu, May 12, 2022 at 2:24 PM vignesh C wrote: > ... > The attached patch has the implementation for "ALTER PUBLICATION > pubname RESET". This command will reset the publication to default > state which includes resetting the publication options, setting ALL > TABLES option to false and dropping the relations and schemas that are > associated with the publication. > Please see below my review comments for the v1-0001 (RESET) patch ====== 1. Commit message This patch adds a new RESET option to ALTER PUBLICATION which Wording: "RESET option" -> "RESET clause" ~~~ 2. doc/src/sgml/ref/alter_publication.sgml + + The RESET clause will reset the publication to default + state which includes resetting the publication options, setting + ALL TABLES option to false and drop the + relations and schemas that are associated with the publication. 2a. Wording: "to default state" -> "to the default state" 2b. Wording: "and drop the relations..." -> "and dropping all relations..." ~~~ 3. doc/src/sgml/ref/alter_publication.sgml + invoking user to be a superuser. RESET of publication + requires invoking user to be a superuser. To alter the owner, you must also Wording: "requires invoking user" -> "requires the invoking user" ~~~ 4. doc/src/sgml/ref/alter_publication.sgml - Example @@ -207,6 +220,12 @@ ALTER PUBLICATION sales_publication ADD ALL TABLES IN SCHEMA marketing, sales; production_publication: ALTER PUBLICATION production_publication ADD TABLE users, departments, ALL TABLES IN SCHEMA production; + + + + Resetting the publication production_publication: + +ALTER PUBLICATION production_publication RESET; Wording: "Resetting the publication" -> "Reset the publication" ~~~ 5. src/backend/commands/publicationcmds.c + /* Check and reset the options */ IMO the code can just reset all these options unconditionally. I did not see the point to check for existing option values first. I feel the simpler code outweighs any negligible performance difference in this case. ~~~ 6. src/backend/commands/publicationcmds.c + /* Check and reset the options */ Somehow it seemed a pity having to hardcode all these default values true/false in multiple places; e.g. the same is already hardcoded in the parse_publication_options function. To avoid multiple hard coded bools you could just call the parse_publication_options with an empty options list. That would set the defaults which you can then use: values[Anum_pg_publication_pubinsert - 1] = BoolGetDatum(pubactiondefs->insert); Alternatively, maybe there should be #defines to use instead of having the scattered hardcoded bool defaults: #define PUBACTION_DEFAULT_INSERT true #define PUBACTION_DEFAULT_UPDATE true etc ~~~ 7. src/include/nodes/parsenodes.h @@ -4033,7 +4033,8 @@ typedef enum AlterPublicationAction { AP_AddObjects, /* add objects to publication */ AP_DropObjects, /* remove objects from publication */ - AP_SetObjects /* set list of objects */ + AP_SetObjects, /* set list of objects */ + AP_ReSetPublication /* reset the publication */ } AlterPublicationAction; Unusual case: "AP_ReSetPublication" -> "AP_ResetPublication" ~~~ 8. src/test/regress/sql/publication.sql 8a. +-- Test for RESET PUBLICATION SUGGESTED +-- Tests for ALTER PUBLICATION ... RESET 8b. +-- Verify that 'ALL TABLES' option is reset SUGGESTED: +-- Verify that 'ALL TABLES' flag is reset 8c. +-- Verify that publish option and publish via root option is reset SUGGESTED: +-- Verify that publish options and publish_via_partition_root option are reset 8d. +-- Verify that only superuser can execute RESET publication SUGGESTED +-- Verify that only superuser can reset a publication ------ Kind Regards, Peter Smith. Fujitsu Australia