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 1m5rha-00061F-0f for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Jul 2021 15:30:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m5rhY-0004VP-TD for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Jul 2021 15:30:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m5rhY-0004VH-Kr for pgsql-hackers@lists.postgresql.org; Tue, 20 Jul 2021 15:30:32 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m5rhW-0005di-45 for pgsql-hackers@lists.postgresql.org; Tue, 20 Jul 2021 15:30:31 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 6B3143200956; Tue, 20 Jul 2021 11:30:28 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 20 Jul 2021 11:30:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=NJNgKObpv5b/Wt1a8ItzbSrpq3l6KIit8j6AKVVl6 zQ=; b=XW4gii1s7ieel1tHbAqf5svv9MA6EEJB/3qufATYX36cOmmlycTJeumqU 2FEd4H0yVqzgAbQ3yiMxjEwFYINXiWZOBv0fAkpnyfCvjOxZyYE4CRfQHFJ1LTvU DNSif7KJkOz9Dyq2XQC0+xI2OFnWS1Z18MFNxGpJnvl4Hskc3nbrYeWtz/5sm5p2 IqfvvgpXJPVbreYByfZX+2z/OPzjPkwZ+UJ04sHUe01lQGgUApEcC5pjiwC30MH2 vbAkGfTdfZcySLMJKR9BB4lqeRZTtAPoQCOqcQYXeQ0zaJWWR2+yUz3x2B/UMuxI gkPJa0Tz4UsVz2+EGK5cUUTEdlwiQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrfedvgdekjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpefrvghtvghr ucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvghnthgvrh hprhhishgvuggsrdgtohhmqeenucggtffrrghtthgvrhhnpeelveehheeuieduieetiedt keeuteelfeetjeffieffudegvdffvdfftdeivdeukeenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrrdgvihhsvghnthhrrghuthes vghnthgvrhhprhhishgvuggsrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 20 Jul 2021 11:30:26 -0400 (EDT) Subject: Re: logical decoding and replication of sequences To: Tomas Vondra , PostgreSQL Hackers Cc: Petr Jelinek References: From: Peter Eisentraut Message-ID: <359bf6d0-413d-292a-4305-e99eeafead39@enterprisedb.com> Date: Tue, 20 Jul 2021 17:30:25 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 08.06.21 00:28, Tomas Vondra wrote: > > new "sequence" publication action > --------------------------------- > > The publications now have a new "sequence" publication action, which is > enabled by default. This determines whether the publication decodes > sequences or what. > > > FOR ALL SEQUENCES > ----------------- > > It should be possible to create FOR ALL SEQUENCES publications, just > like we have FOR ALL TABLES. But this produces shift/reduce conflicts > in the grammar, and I didn't bother dealing with that. So for now it's > required to do ALTER PUBLICATION ... [ADD | DROP] SEQUENCE ... I have been thinking about these DDL-level issues a bit. The most common use case will be to have a bunch of tables with implicit sequences, and you just want to replicate them from here to there without too much effort. So ideally an implicit sequence should be replicated by default if the table is part of a publication (unless sequences are turned off by the publication option). We already have support for things like that in GetPublicationRelations(), where a partitioned table is expanded to include the actual partitions. I think that logic could be reused. So in general I would have GetPublicationRelations() include sequences and don't have GetPublicationSequenceRelations() at all. Then sequences could also be sent by pg_publication_tables(), maybe add a relkind column. And then you also don't need so much duplicate DDL code, if you just consider everything as a relation. For example, there doesn't seem to be an actual need to have fetch_sequence_list() and subsequent processing on the subscriber side. It does the same thing as fetch_table_list(), so it might as well just all be one thing. We do, however, probably need some checking that we don't replicate tables to sequences or vice versa. We probably also don't need a separate FOR ALL SEQUENCES option. What users really want is a "for everything" option. We could think about renaming or alternative syntax, but in principle I think FOR ALL TABLES should include sequences by default. Tests under src/test/subscription/ are needed. I'm not sure why test_decoding needs a skip-sequences option. The source code says it's for backward compatibility, but I don't see why we need that.