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 1noGiH-0000iV-8d for pgsql-hackers@arkaria.postgresql.org; Tue, 10 May 2022 03:39:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1noGiG-0005BT-2b for pgsql-hackers@arkaria.postgresql.org; Tue, 10 May 2022 03:39:04 +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 1noGiF-0005BK-Mt for pgsql-hackers@lists.postgresql.org; Tue, 10 May 2022 03:39:03 +0000 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1noGiD-0003AW-Jx for pgsql-hackers@lists.postgresql.org; Tue, 10 May 2022 03:39:03 +0000 Received: by mail-io1-xd35.google.com with SMTP id e194so17310370iof.11 for ; Mon, 09 May 2022 20:39:01 -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=rYa5nMl+64RPT4HRHKN8arVsUdbFLrUlP0E+4bA0WBs=; b=NWUU6ULe/GKcSpXQG7fBAazRwQQMvfilETNdQDh8UwNVoAcia7L38lYPa2hNKwCpJS ZBsCnkDyDI3JVCKMskHAXgxG0Kl5M0XfsG+eryYlIrILPbySf77uKm64AajzPLrbuZ2Y YZWhL5Bux3fiyBBWMuiOddlhj0/VBjJzqG3uYg/qVZPMhgtxauKcYoi4qxK7VTuwG4+L yjhyTpzBQdKaqviqcEM3xh9tDRXcsbDkE2IS6Bc9eXg/b7XY/goHvH1FixRCHYfkJeOP SbgosNWF5F4S4k9ecux8gXmxSrCVl4r5tOgBIXhjqtxs7/fQIeEpjPepfidrt8I8CV0r TcLA== 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=rYa5nMl+64RPT4HRHKN8arVsUdbFLrUlP0E+4bA0WBs=; b=x1UhhKTTTakq9lGKcJqPhr4r2FNeae9EUnKaZ2aJgBnNBjdUAvhkbJkZYe1T2BoV2i gv91FreCW8XDj3n5hIFhaqeJ1T5GQU7iY+wW9jjLKb5Zrx6srN8QIEKbJHtK1jji6akC NXT711uxCt9XyqckHMbctuSAVc3/Vom8aPzTE9K6MmQdMOUpOswq2gvEEaXntPaWPPxA JYbNSZq846FC67pJn8QupXcYxDzsyrJD2tr5TVFe6G5qeneDhDDiZBIeZuVhCk1ot6wi pxwrqOkB6TbwyTXJR7iHI5WgJPw631lMQoRgsHv17PuH+7vquCZZLcO77cJK7ns4PdBE 8daA== X-Gm-Message-State: AOAM531HQKQOBXwCjW8vVffj+3On2eSDllwoGnLv+vaDTfQsNNGmCMdE 55sPDFLrfasAKxzFCLnty/nNE9cVZFYxZcdjz9+YiVwiKYB6pQ== X-Google-Smtp-Source: ABdhPJyEr/CQKvp+21C7l/KtaO0MDkKaJOz3L1VQw4vo+KH8c11xvXFl5Husay+uxnUwCorHJwRPCPERiJVNP2ZuIDM= X-Received: by 2002:a02:900d:0:b0:32a:ec66:4fa7 with SMTP id w13-20020a02900d000000b0032aec664fa7mr9418873jaf.271.1652153939610; Mon, 09 May 2022 20:38:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: vignesh C Date: Tue, 10 May 2022 09:08:48 +0530 Message-ID: Subject: Re: Skipping schema changes in publication To: Peter Smith 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 Fri, May 6, 2022 at 8:05 AM Peter Smith wrote: > > On Thu, Apr 28, 2022 at 9:32 PM Amit Kapila wrote: > > > ... > > > > Another idea that occurred to me today for tables this is as follows: > > 1. Allow to mention except during create publication ... For All Tables. > > CREATE PUBLICATION pub1 FOR ALL TABLES EXCEPT TABLE t1,t2; > > 2. Allow to Reset it. This new syntax will reset all objects in the > > publications. > > Alter Publication ... RESET; > > 3. Allow to add it to an existing publication > > Alter Publication ... Add ALL TABLES [EXCEPT TABLE t1,t2]; > > > > I think it can be extended in a similar way for schema syntax as well. > > > > If the proposed syntax ALTER PUBLICATION ... RESET will reset all the > objects in the publication then there still seems simple way to remove > only the EXCEPT list but leave everything else intact. IIUC to clear > just the EXCEPT list would require a 2 step process - 1) ALTER ... > RESET then 2) ALTER ... ADD ALL TABLES again. > > I was wondering if it might be useful to have a variation that *only* > resets the EXCEPT list, but still leaves everything else as-is? > > So, instead of: > ALTER PUBLICATION pubname RESET +1 for this syntax as this syntax can be extendable to include options like (except/all/etc) later. Currently we can support this syntax and can be extended later based on the requirements. The new feature will handle the various use cases based on the behavior given below: -- CREATE Publication with EXCEPT TABLE syntax CREATE PUBLICATION pub1 FOR ALL TABLES EXCEPT TABLE t1,t2; -- ok Alter Publication pub1 RESET; -- All Tables and options are reset similar to creating publication without any publication object and publication option (create publication pub1) \dRp+ pub1 Publication pub2 Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------+------------+---------+---------+---------+-----------+---------- vignesh | f | t | t | t | t | f (1 row) -- Can add except table after reset of publication ALTER PUBLICATION pub1 Add ALL TABLES EXCEPT TABLE t1,t2; -- ok -- Cannot add except table without reset of publication ALTER PUBLICATION pub1 Add EXCEPT TABLE t3,t4; -- not ok, need to be reset Alter Publication pub1 RESET; -- Cannot add table to ALL TABLES Publication ALTER PUBLICATION pub1 Add ALL TABLES EXCEPT TABLE t1,t2, t3, t4, TABLE t5; -- not ok, ALL TABLES Publications does not support including of TABLES Alter Publication pub1 RESET; -- Cannot add table to ALL TABLES Publication ALTER PUBLICATION pub1 Add ALL TABLES TABLE t1,t2; -- not ok, ALL TABLES Publications does not support including of TABLES -- Cannot add ALL TABLES IN SCHEMA to ALL TABLES Publication ALTER PUBLICATION pub1 Add ALL TABLES ALL TABLES IN SCHEMA sch1, sch2; -- not ok, ALL TABLES Publications does not support including of ALL TABLES IN SCHEMA -- Existing syntax should work as it is CREATE PUBLICATION pub1 FOR TABLE t1; ALTER PUBLICATION pub1 ADD TABLE t1; -- ok, existing ALTER should work as it is (ok without reset) ALTER PUBLICATION pub1 ADD ALL TABLES IN SCHEMA sch1; -- ok, existing ALTER should work as it is (ok without reset) ALTER PUBLICATION pub1 DROP TABLE t1; -- ok, existing ALTER should work as it is (ok without reset) ALTER PUBLICATION pub1 DROP ALL TABLES IN SCHEMA sch1; -- ok, existing ALTER should work as it is (ok without reset) ALTER PUBLICATION pub1 SET TABLE t1; -- ok, existing ALTER should work as it is (ok without reset) ALTER PUBLICATION pub1 SET ALL TABLES IN SCHEMA sch1; -- ok, existing ALTER should work as it is (ok without reset) I will modify the patch to handle this. Regards, Vignesh