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 1mKhUe-0001zS-O0 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Aug 2021 13:38:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mKhUd-0004XM-Ko for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Aug 2021 13:38:31 +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 1mKhUc-0004XE-GX for pgsql-hackers@lists.postgresql.org; Mon, 30 Aug 2021 13:38:31 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mKhUY-0006QG-Oy for pgsql-hackers@lists.postgresql.org; Mon, 30 Aug 2021 13:38:29 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 84C663200979; Mon, 30 Aug 2021 09:38:23 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 30 Aug 2021 09:38:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h= from:to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=fm3; bh=/Cgj+cAristA+k1gTF0hbraB3S FeQKCHPqefCiKRkkU=; b=HMTvSsucEOuYUJORRomp6qq6eTeLD/pUTWS2AiCZjG W07nq+lmjpGEYlUKtN7AR5kxQzjJtJ7F5Iz8sDRAgC+6THbV23w1B/guEIk9dNRF eRpKb5CRGRf51UIX9V/D0mgHKIiHHQOhVvpuYWzBSmwKPHlNh0aMAdsenxdkmkYa Bd9zc7/59AZHHDs3S5V88/GQLzCuPmCHuHkDmE5wtymCEl33u44Y5gwfu9NmNNzn 2Q9s0rfZCUvQnGZVMiLBO1E4qrY3v05ZU33Ko1eWzR6FZ1A0zonU9tfDF5N9mW1u OTv47m6uXmJdT0/q5g8ZSfWK9hqMaakJ9ekpyZJxo36g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=/Cgj+c AristA+k1gTF0hbraB3SFeQKCHPqefCiKRkkU=; b=NmzqmvMsBNkLPHE2KpNPbQ lbEc7NOhaViWSw6+VE0zRF7JRmt0UDIeFCfJF1oM65Dl21QKS8/JKwus+tl99RaN XxA+Arv5dP5FCLhGmnxeBkHHLwDOmNno8JJYcqBhflM68Ads/ANS01b7yGJisTcs MqNKiBuci3EJyg2O+bNgd8G3hEHVny5iJb3w5hp+nf8Rw3AeUd+n2r0A27gy8vwY 2cwQHjq8fCI+PUy75XvkVXqYLl25vzXcDcT1I5UtWbpbTRfD6q6KzmEBPz8LoP4w i5hOhh5Do2+0odZTbNJpf5xSt8YvWUiZqxXODbIdNFXTig9gOxxr51z2rMwSkUbA == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudduledgieeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdlfeehmdenucfjughrpefhvffufhffjgfkfgggtgesmhdtreertder jeenucfhrhhomhepffgrghhfihhnnhgpkfhlmhgrrhhipgforghnnhhsnohkvghruceoih hlmhgrrhhisehilhhmrghrihdrohhrgheqnecuggftrfgrthhtvghrnhepteevieehteet leeglefghfefkeejheelledttedtgfdvkeffheffvdekheeuudffnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhlmhgrrhhisehilhhmrghr ihdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 30 Aug 2021 09:38:21 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: Michael Paquier Cc: pgsql-hackers@lists.postgresql.org Subject: Re: [PATCH] Tab completion for ALTER TABLE =?utf-8?Q?=E2=80=A6?= ADD =?utf-8?Q?=E2=80=A6?= References: <87bl6ehhpl.fsf@wibble.ilmari.org> <87k0k7upla.fsf@wibble.ilmari.org> Date: Mon, 30 Aug 2021 14:38:19 +0100 In-Reply-To: (Michael Paquier's message of "Mon, 30 Aug 2021 09:55:53 +0900") Message-ID: <87h7f7uk6s.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; charset=utf-8 Content-Transfer-Encoding: 8bit Michael Paquier writes: > On Fri, Aug 27, 2021 at 11:52:33AM +0100, Dagfinn Ilmari Mannsåker wrote: >> That was easy enough to add (just a bit of extra fiddling to handle >> COLUMN being optional), done in the attached v2 patch. > > This part was a bit misleading, as it would recommend a list of types > when specifying just ADD CONSTRAINT for example, so I have removed > it. That was because I forgot to exclude all the other object types that can come after ADD. Attached is a patch that does that. I also moved it right next to the ALTER TABLE … ADD completion, and added a comment to keep the two lists in sync. > An extra thing that felt a bit overdoing is the addition of KEY after > PRIMARY/FOREIGN. Yeah, I guess people are unlikely to write out the whole PRIMARY or FOREIGN and only then hit tab to complete the rest. >> Doing a list of arbitrarily many comma-separated names is more >> complicated, so that can be the subject for another patch. > > No objections to that. I have applied what we have now, as that's > already an improvement. Thanks! - ilmari --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Complete-type-names-after-ALTER-TABLE-ADD-COLUMN.patch From a5fac64310b01ed32e281031a2c274e835463853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Mon, 30 Aug 2021 14:25:55 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Complete=20type=20names=20after=20ALTER=20T?= =?UTF-8?q?ABLE=20=E2=80=A6=20ADD=20[COLUMN]=E2=80=88=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since COLUMN is optional, we need to keep the list of object types to complete after ADD in sync with the list of words not to complete type names after. Add a comment to this effect. --- src/bin/psql/tab-complete.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 7c6af435a9..197f4c736c 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2025,8 +2025,14 @@ psql_completion(const char *text, int start, int end) "DETACH PARTITION", "FORCE ROW LEVEL SECURITY"); /* ALTER TABLE xxx ADD */ else if (Matches("ALTER", "TABLE", MatchAny, "ADD")) + /* make sure to keep this list and the !Matches() below in sync */ COMPLETE_WITH("COLUMN", "CONSTRAINT", "CHECK", "UNIQUE", "PRIMARY KEY", "EXCLUDE", "FOREIGN KEY"); + /* ATER TABLE xxx ADD [COLUMN] yyy */ + else if (Matches("ALTER", "TABLE", MatchAny, "ADD", "COLUMN", MatchAny) || + (Matches("ALTER", "TABLE", MatchAny, "ADD", MatchAny) && + !Matches("ALTER", "TABLE", MatchAny, "ADD", "COLUMN|CONSTRAINT|CHECK|UNIQUE|PRIMARY|EXCLUDE|FOREIGN"))) + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes, NULL); /* ALTER TABLE xxx ADD CONSTRAINT yyy */ else if (Matches("ALTER", "TABLE", MatchAny, "ADD", "CONSTRAINT", MatchAny)) COMPLETE_WITH("CHECK", "UNIQUE", "PRIMARY KEY", "EXCLUDE", "FOREIGN KEY"); -- 2.30.2 --=-=-=--