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.94.2) (envelope-from ) id 1rxVAi-009Etb-RH for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Apr 2024 17:03:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rxVAg-0077X8-Ld for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Apr 2024 17:03:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rxVAf-0077X0-1R for pgsql-hackers@lists.postgresql.org; Thu, 18 Apr 2024 17:03:38 +0000 Received: from fout2-smtp.messagingengine.com ([103.168.172.145]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rxVAX-001esO-0h for pgsql-hackers@lists.postgresql.org; Thu, 18 Apr 2024 17:03:36 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfout.nyi.internal (Postfix) with ESMTP id 9E8AA13800C6; Thu, 18 Apr 2024 13:03:26 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Thu, 18 Apr 2024 13:03:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1713459806; x=1713546206; bh=0spz5U9Mbr 3Hf8xpwkz/nyVznPtV1O79Gro9LmuCYq8=; b=ov/axLghBBz86UXfH/+45o2hJN JxXwk2yk1xXFzWgaVtFXeKgyio0/nXg5kQ9XHL35LhXzkgShrDZdbCt53F0L/HVb vxZvBLzoV0c6Fy2oK0p6eeqM6wEiNQ3Ky/XVm9IHAxAPZDCuOcE+Y31i5DBNYTSp JX4m/2HEdwOfAYKU/RP0fP88ad6m2+TB3g0Wd4t+rIVQDQ4Zf2Qar1k2i6tsSIDT jmG9UA6CgQZ54cVMdf3h2f5aHDyNvWZXvfnu+VDZCvWkkQ1NFX7XS0N2xJSqTsnX jegvz/osoEfhLJbKXwoCEZsT1doCyaaOinoE7wNeJNUaADuJVflGesYWagKg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1713459806; x=1713546206; bh=0spz5U9Mbr3Hf8xpwkz/nyVznPtV 1O79Gro9LmuCYq8=; b=D5npT/yXmhONTeJ2S+WTrN4MiO3uweLJ41vEE/NZA+73 Zk7t1M/Rv5q+O7WnNGjSjDuiVBLbbukVaIGyaxzdePzYFGeI3bpJQRK5GNt9liR+ DoQHrVPvplJkk2qhraAojDn/doIRDd1ZcsQIg9Q+wKzxzZU3+oOW8VfIPEEf8F3C eKSeZFzpnpd/aWHKX2qOCcC/r0Msdi0qQbV6Dm/oNNLwsEsYso/TfQWXCSOFUq3c kzs/7fiKqa3boTNBG/3fSPgndUaysNkV4R7BtC6oVQJMUQkHROA8F8QdMWnulrAm vvEczM4K25bQWV7EV21lQp+e7z5IxmgK3bfRLItPgQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudektddguddtjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufhfffgjkfgfgggtsehmtderredtreejnecuhfhrohhmpeffrghg fhhinhhnucfklhhmrghrihcuofgrnhhnshonkhgvrhcuoehilhhmrghrihesihhlmhgrrh hirdhorhhgqeenucggtffrrghtthgvrhhnpedvvdfhhedtfeekudfgtedufeehgffggeej ieejheeugfethefggedtleegteetjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehilhhmrghrihesihhlmhgrrhhirdhorhhg X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Apr 2024 13:03:23 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: Alexander Lakhin Cc: Alexander Korotkov , Dmitry Koval , Robert Haas , PostgreSQL Hackers Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands References: <86bfd241-a58c-479a-9a72-2c67a02becf8@postgrespro.ru> <0f655bcd-6487-4179-f9cf-c248efbad510@gmail.com> <56e0000c-6b39-44ce-90b4-d3c3062e408c@postgrespro.ru> <5dee3937-8e9f-cca4-11fb-737709a92b37@gmail.com> Date: Thu, 18 Apr 2024 18:03:21 +0100 In-Reply-To: <5dee3937-8e9f-cca4-11fb-737709a92b37@gmail.com> (Alexander Lakhin's message of "Thu, 18 Apr 2024 19:00:00 +0300") Message-ID: <87plumiox2.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-=-= Content-Type: text/plain Alexander Lakhin writes: > Hi Alexander, > > 18.04.2024 13:35, Alexander Korotkov wrote: >> >> The revised patchset is attached. >> 1) I've split the fix for the CommandCounterIncrement() issue and the >> fix for relation persistence issue into a separate patch. >> 2) I've validated that the lock on the new partition is held in >> createPartitionTable() after ProcessUtility() as pointed out by >> Robert. So, no need to place the lock again. >> 3) Added fix for problematic error message as a separate patch [1]. >> 4) Added rename "salemans" => "salesmen" for tests as a separate patch. >> >> I think these fixes are reaching committable shape, but I'd like >> someone to check it before I push. > > I think the feature implementation should also provide tab completion for > SPLIT/MERGE. > (ALTER TABLE t S > fills in only SET now.) Here's a patch for that. One thing I noticed while testing it was that the tab completeion for partitions (Query_for_partition_of_table) shows all the schemas in the DB, even ones that don't contain any partitions of the table being altered. - ilmari --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-tab-completion-for-ALTER-TABLE-SPLIT-MERGE-PARTI.patch From 26db03b7a7675aa7dbff1f18ee084296caa1e181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Thu, 18 Apr 2024 17:47:22 +0100 Subject: [PATCH] =?UTF-8?q?Add=20tab=20completion=20for=20ALTER=20TABLE=20?= =?UTF-8?q?=E2=80=A6=20SPLIT|MERGE=20PARTITION(S)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin/psql/tab-complete.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 6fee3160f0..97cd5d9f62 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2353,6 +2353,7 @@ psql_completion(const char *text, int start, int end) "OWNER TO", "SET", "VALIDATE CONSTRAINT", "REPLICA IDENTITY", "ATTACH PARTITION", "DETACH PARTITION", "FORCE ROW LEVEL SECURITY", + "SPLIT PARTITION", "MERGE PARTITIONS (", "OF", "NOT OF"); /* ALTER TABLE xxx ADD */ else if (Matches("ALTER", "TABLE", MatchAny, "ADD")) @@ -2609,10 +2610,10 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH("FROM (", "IN (", "WITH ("); /* - * If we have ALTER TABLE DETACH PARTITION, provide a list of + * If we have ALTER TABLE DETACH|SPLIT PARTITION, provide a list of * partitions of . */ - else if (Matches("ALTER", "TABLE", MatchAny, "DETACH", "PARTITION")) + else if (Matches("ALTER", "TABLE", MatchAny, "DETACH|SPLIT", "PARTITION")) { set_completion_reference(prev3_wd); COMPLETE_WITH_SCHEMA_QUERY(Query_for_partition_of_table); @@ -2620,6 +2621,19 @@ psql_completion(const char *text, int start, int end) else if (Matches("ALTER", "TABLE", MatchAny, "DETACH", "PARTITION", MatchAny)) COMPLETE_WITH("CONCURRENTLY", "FINALIZE"); + /* ALTER TABLE SPLIT PARTITION */ + else if (Matches("ALTER", "TABLE", MatchAny, "SPLIT", "PARTITION", MatchAny)) + COMPLETE_WITH("INTO ( PARTITION"); + + /* ALTER TABLE MERGE PARTITIONS ( */ + else if (Matches("ALTER", "TABLE", MatchAny, "MERGE", "PARTITIONS", "(")) + { + set_completion_reference(prev4_wd); + COMPLETE_WITH_SCHEMA_QUERY(Query_for_partition_of_table); + } + else if (Matches("ALTER", "TABLE", MatchAny, "MERGE", "PARTITIONS", "(*)")) + COMPLETE_WITH("INTO"); + /* ALTER TABLE OF */ else if (Matches("ALTER", "TABLE", MatchAny, "OF")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_composite_datatypes); -- 2.39.2 --=-=-=--