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 1mxXZf-0007NN-Uq for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Dec 2021 16:56:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mxXZd-0002ve-Vi for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Dec 2021 16:56:13 +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 1mxXZd-0002vV-65 for pgsql-hackers@lists.postgresql.org; Wed, 15 Dec 2021 16:56:13 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mxXZa-0003Ad-0L for pgsql-hackers@lists.postgresql.org; Wed, 15 Dec 2021 16:56:11 +0000 Received: by mail-ed1-x531.google.com with SMTP id y22so6247308edq.2 for ; Wed, 15 Dec 2021 08:56:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=Abo10a4Er8P3FYBCoAVnphPueNnOrAUbmsQinZgFEYs=; b=mNGvboXy0NzSqqj8ukL50PJNOD8xLUriQt+XdOXyTAK19x4F/xuhEpm5Ve0tudwAa5 W/6UTDJHYcIwP0J7+Ec8PitgVKZkP0uwKAPvAeFbFMVNWwfepCByKIs3MziDq6zdqSUO YMoJB1CUb/No6mFMuVZ4nZ+5ZY2nNj2J0emDpo0vbWhDl3SR/Ffx8MdQ3qasVLBKRPlf Yh32yXVb12hs3x6LMcYt4YHq1+1Qz37Le+2iahvDz7+fWs2ylPVkNtCJSwocC16QCHbl rExmJRak8n3yCD8onQFv3waJSl2lGsBND0Z/5OTVwXyWbPXomRrhSNJt/I6yeLalfNt3 3aVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Abo10a4Er8P3FYBCoAVnphPueNnOrAUbmsQinZgFEYs=; b=lfw9qxGB44Ti1mk1CmD1Lgs8vD07Sjj35LMkwMCu9eo6XU1Ld4rDbuafVcdy2Bg0w5 Fh8YUKGgATccFG8pUTUwuYCA6KRbftrWJj4+l/6hPBVaCJ5zaQp+xpy9mQpLI7QpP6PY YL12Fe+hPb/ub8QB865qI+B9je5e6E2hzax/wgRoJ5v5Rgmruo2rHiPMyp7LY/sqNIRY opkONNwLER4kD18iv6P2pHYft1KtsCpdI17jw8dRaq6awgIodrJpR54pCoo4uLYXIkeU IeBRjQuQyt1eZsLwDhhgFbu3SltSoeCbW/7I/S7kbRM4WbSr8no8vQLGX4hhvukHmAJv O2iQ== X-Gm-Message-State: AOAM531zrACqzb4LyNf1Sy7cBzgJDoJ8lEDXQyXGnLxm02XBEKBpv8yS kIrgjek8FlfNtf9t/9VrcPvHJiKU0vUhtQqtkde7pkobzqCNVL10prJoY0hRfCL5kXOd+3LlBa+ GUVJhSFuGTFb3oHNZ2E/HNRcLtZsUm6dv5EFISSeXzBiYAjCM6qtB1pz8pJp8zhzrVMk9TthymH c5XByaqxVnmFpizGTEHii3ZmCVO6sJe9mNaRQMnP0o/Xa73cMkt7/B X-Google-Smtp-Source: ABdhPJwMTMKJSN6fGS7/Tb63NTJrMMjmrWNhW91m6ICz6IFoAISsgg3O85Vbakozp/U+oqrn3mK+/A== X-Received: by 2002:a05:6402:11d2:: with SMTP id j18mr16292862edw.318.1639587367412; Wed, 15 Dec 2021 08:56:07 -0800 (PST) Received: from [10.137.0.19] (ip-86-49-251-241.net.upcbroadband.cz. [86.49.251.241]) by smtp.gmail.com with ESMTPSA id he14sm855514ejc.55.2021.12.15.08.56.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Dec 2021 08:56:06 -0800 (PST) Message-ID: <2ed1e3ff-076d-1127-555a-38b5d6c135ba@enterprisedb.com> Date: Wed, 15 Dec 2021 17:56:04 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: logical decoding and replication of sequences Content-Language: en-US To: Alvaro Herrera Cc: Peter Eisentraut , PostgreSQL Hackers , Petr Jelinek References: <202112151642.h7cehn6zplxg@alvherre.pgsql> From: Tomas Vondra In-Reply-To: <202112151642.h7cehn6zplxg@alvherre.pgsql> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/15/21 17:42, Alvaro Herrera wrote: > Looking at 0003, > > On 2021-Dec-14, Tomas Vondra wrote: > >> diff --git a/doc/src/sgml/ref/alter_publication.sgml b/doc/src/sgml/ref/alter_publication.sgml >> index bb4ef5e5e22..4d166ad3f9c 100644 >> --- a/doc/src/sgml/ref/alter_publication.sgml >> +++ b/doc/src/sgml/ref/alter_publication.sgml >> @@ -31,7 +31,9 @@ ALTER PUBLICATION name RENAME TO > where publication_object is one of: >> >> TABLE [ ONLY ] table_name [ * ] [, ... ] >> + SEQUENCE sequence_name [ * ] [, ... ] >> ALL TABLES IN SCHEMA { schema_name | CURRENT_SCHEMA } [, ... ] >> + ALL SEQUENCE IN SCHEMA { schema_name | CURRENT_SCHEMA } [, ... ] > > Note that this says ALL SEQUENCE; I think it should be ALL SEQUENCES. > >> diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y >> index 3d4dd43e47b..f037c17985b 100644 >> --- a/src/backend/parser/gram.y >> +++ b/src/backend/parser/gram.y >> @@ -9762,6 +9762,26 @@ PublicationObjSpec: > ... >> + | ALL SEQUENCE IN_P SCHEMA ColId >> + { >> + $$ = makeNode(PublicationObjSpec); >> + $$->pubobjtype = PUBLICATIONOBJ_SEQUENCE_IN_SCHEMA; >> + $$->name = $5; >> + $$->location = @5; >> + } >> + | ALL SEQUENCES IN_P SCHEMA CURRENT_SCHEMA >> + { >> + $$ = makeNode(PublicationObjSpec); >> + $$->pubobjtype = PUBLICATIONOBJ_SEQUENCE_IN_CUR_SCHEMA; >> + $$->location = @5; >> + } > > And here you have ALL SEQUENCE in one spot and ALL SEQUENCES in the > other. > > BTW I think these enum values should use the plural too, > PUBLICATIONOBJ_SEQUENCES_IN_CUR_SCHEMA (not SEQUENCE). I suppose you > copied from PUBLICATIONOBJ_TABLE_IN_CUR_SCHEMA, but that too seems to be > a mistake: should be PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA. > > >> @@ -10097,6 +10117,12 @@ UnlistenStmt: >> } >> ; >> >> +/* >> + * FIXME >> + * >> + * opt_publication_for_sequences and publication_for_sequences should be >> + * copies for sequences >> + */ > > Not sure if this FIXME is relevant or should just be removed. > >> @@ -10105,6 +10131,12 @@ UnlistenStmt: >> * BEGIN / COMMIT / ROLLBACK >> * (also older versions END / ABORT) >> * >> + * ALTER PUBLICATION name ADD SEQUENCE sequence [, sequence2] >> + * >> + * ALTER PUBLICATION name DROP SEQUENCE sequence [, sequence2] >> + * >> + * ALTER PUBLICATION name SET SEQUENCE sequence [, sequence2] >> + * > > This comment addition seems misplaced? > >> diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c >> index 2f412ca3db3..e30bf7b1b55 100644 >> --- a/src/bin/psql/tab-complete.c >> +++ b/src/bin/psql/tab-complete.c >> @@ -1647,13 +1647,13 @@ psql_completion(const char *text, int start, int end) >> COMPLETE_WITH("ADD", "DROP", "OWNER TO", "RENAME TO", "SET"); >> /* ALTER PUBLICATION ADD */ >> else if (Matches("ALTER", "PUBLICATION", MatchAny, "ADD")) >> - COMPLETE_WITH("ALL TABLES IN SCHEMA", "TABLE"); >> + COMPLETE_WITH("ALL TABLES IN SCHEMA", "TABLE|SEQUENCE"); >> /* ALTER PUBLICATION DROP */ >> else if (Matches("ALTER", "PUBLICATION", MatchAny, "DROP")) >> - COMPLETE_WITH("ALL TABLES IN SCHEMA", "TABLE"); >> + COMPLETE_WITH("ALL TABLES IN SCHEMA", "TABLE|SEQUENCE"); >> /* ALTER PUBLICATION SET */ >> else if (Matches("ALTER", "PUBLICATION", MatchAny, "SET")) >> - COMPLETE_WITH("(", "ALL TABLES IN SCHEMA", "TABLE"); >> + COMPLETE_WITH("(", "ALL TABLES IN SCHEMA", "TABLE|SEQUENCE"); > > I think you should also add "ALL SEQUENCES IN SCHEMA" to these lists. > > >> else if (Matches("ALTER", "PUBLICATION", MatchAny, "ADD|DROP|SET", "ALL", "TABLES", "IN", "SCHEMA")) > > ... and perhaps make this "ALL", "TABLES|SEQUENCES", "IN", "SCHEMA". > Thanks for the review. I'm aware 0003 is still incomplete and subject to change - it's certainly not meant for commit yet. The current 0003 patch is sufficient for testing the infrastructure, but we need to figure out how to make it easier to use, what to do with implicit sequences and similar things. Peter had some ideas in [1]. [1] https://www.postgresql.org/message-id/359bf6d0-413d-292a-4305-e99eeafead39%40enterprisedb.com -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company