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 1nEt0o-00075u-JE for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Feb 2022 13:15:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nEt0m-0001eA-Cc for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Feb 2022 13:15:56 +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 1nEt0k-0001e1-EL for pgsql-hackers@lists.postgresql.org; Tue, 01 Feb 2022 13:15:56 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nEt0g-0007sy-SI for pgsql-hackers@lists.postgresql.org; Tue, 01 Feb 2022 13:15:53 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 98C735C011B; Tue, 1 Feb 2022 08:15:49 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 01 Feb 2022 08:15:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; bh=pxniUonhrnxo98psFoPLORmozAdd58E3LUgdfH Wy0a8=; b=vJY5tM+4jIuAUVNMYi+pjhAW6AI6Y3UiPD55+oUGUUgkKmucr0jhra En0jK5Xjx+R3LLJ1I29l5YwapnX3LgY3yZ69uv71Fjts962iHCTVPuFzSFQ/iCJJ 56Q2CBM05DKISwjtqS3tvwSpBFYVgaJhdugPicMen+gNd8bgqa6ZDK2xW5Uyd+Vp qF1R6CXAmGbDRxZ8YIgJRYKk8d/JJtmMHMo1YDuwQ14yUs+8v68qkP7gBt40vc1U Mf4VGf//SiqhYkVQWPFZhBvIk68ZdLihBcJYvVjmH+KCI4pcYO9VZ8a0ce7sv7Fj Yq01Fc2G8CuVEmNB0WGpHVij9ycgXlNA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=pxniUonhrnxo98psF oPLORmozAdd58E3LUgdfHWy0a8=; b=XHnWLj+oX2jj+sX6qNj/T4/fuwyshR7TH Hfs4cjftl4l5FnbL3eAxv7PkNnzT+k3DIl4NYW+aXcoj4G0aUY93y5fie7NVEesu XLU/WHQGFo7AyKGbnmar8TcI+uZHDHbeiD6WCMENNCbXyT1XB+SLx1IB0V8dA6gn KtepQwxSqEoRPcbQWc1rDj+yEl3qF/fvDu6I54gulNWOf9NyKBohZ6Qo1TQXeXqw pPjslBlqd0qMkkHcTY5LyAg4KXPBF6aO3jgH1l2+OCaF7WC0/SPTvxMEuEuMpl4b hg1dxYrCVTR0y2aTgoMVIj3Jrka0XzDU1BHsN23xCB3zXcxdrqUCg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrgeefgdehtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufhffjgfkfgggtgesmhdtreertderjeenucfhrhhomhepffgrghhfihhn nhgpkfhlmhgrrhhipgforghnnhhsnohkvghruceoihhlmhgrrhhisehilhhmrghrihdroh hrgheqnecuggftrfgrthhtvghrnhepteevieehteetleeglefghfefkeejheelledttedt gfdvkeffheffvdekheeuudffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepihhlmhgrrhhisehilhhmrghrihdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Feb 2022 08:15:47 -0500 (EST) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: Tom Lane Cc: "tanghy.fnst@fujitsu.com" , Peter Eisentraut , Japin Li , Kyotaro Horiguchi , Laurenz Albe , "smithpb2250@gmail.com" , "david.zhang@highgo.ca" , "pgsql-hackers@lists.postgresql.org" Subject: Re: Support tab completion for upper character inputs in psql References: <80b093ae-88bd-8d8a-68b9-b535a3ab11be@enterprisedb.com> <54bd7839-f463-ef03-f2d2-ccb8184b9b27@enterprisedb.com> <1068530.1641480996@sss.pgh.pa.us> <3547066.1642272686@sss.pgh.pa.us> <2304294.1643152287@sss.pgh.pa.us> <2771362.1643385796@sss.pgh.pa.us> <2805502.1643405157@sss.pgh.pa.us> <2818574.1643408192@sss.pgh.pa.us> <324281.1643567679@sss.pgh.pa.us> <8735l41ynm.fsf@wibble.ilmari.org> <534641.1643594097@sss.pgh.pa.us> <838381.1643665141@sss.pgh.pa.us> Date: Tue, 01 Feb 2022 13:15:45 +0000 In-Reply-To: <838381.1643665141@sss.pgh.pa.us> (Tom Lane's message of "Mon, 31 Jan 2022 16:39:01 -0500") Message-ID: <87wniezq0u.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 Tom Lane writes: > I wrote: >> =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= writes: >>> First, as noted in the test, it doesn't preserve the case of the input >>> for keywords appended to the query result. This is easily fixed by >>> using `pg_strdup_keyword_case()`, per the first attached patch. > >> I thought about that, and intentionally didn't do it, because it >> would also affect the menus produced by tab completion. >> ... >> We could do something hacky like matching case only when there's >> no longer any matching object names, but that might be too magic. > > I experimented with that, and it actually doesn't seem as weird > as I feared. See if you like this ... That's a reasonable compromise, and the implementation is indeed less hacky than one might have feared. Although I think putting the `num_keywords` variable before `num_other` would read better. Going through the uses of COMPLETE_WITH(_SCHEMA)_QUERY_PLUS, I noticed a few that had the keywords in lower case, which is fixed in the attached patch (except the hardcoded data types, which aren't really keywords). While I was there, I also added completion of "AUTHORIZATION" after "SHOW SESSSION", which is necessary since there are variables starting with "session_". > regards, tom lane Cheers, - ilmari --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Make-all-tab-completion-keywords-upper-case.patch From 9cc255e0cdddeda3d655c1265d698b1f6027aec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Tue, 1 Feb 2022 13:13:07 +0000 Subject: [PATCH] Make all tab completion keywords upper case. So they stand out from the object names in the same tab completion menu. Also fix tab completion of SHOW SESSION AUTHORIZATION in the face of config variables starting with session_. --- src/bin/psql/tab-complete.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index b2ec50b4f2..d2744cdb6f 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2059,7 +2059,7 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH("SET", "RESET"); else if (Matches("ALTER", "SYSTEM", "SET|RESET")) COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_alter_system_set_vars, - "all"); + "ALL"); else if (Matches("ALTER", "SYSTEM", "SET", MatchAny)) COMPLETE_WITH("TO"); /* ALTER VIEW */ @@ -4039,16 +4039,18 @@ psql_completion(const char *text, int start, int end) /* Complete with a variable name */ else if (TailMatches("SET|RESET") && !TailMatches("UPDATE", MatchAny, "SET")) COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_set_vars, - "constraints", - "transaction", - "session", - "role", - "tablespace", - "all"); + "CONSTRAINTS", + "TRANSACTION", + "SESSION", + "ROLE", + "TABLESPACE", + "ALL"); else if (Matches("SHOW")) COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_show_vars, - "session authorization", - "all"); + "SESSION AUTHORIZATION", + "ALL"); + else if (Matches("SHOW", "SESSION")) + COMPLETE_WITH("AUTHORIZATION"); /* Complete "SET TRANSACTION" */ else if (Matches("SET", "TRANSACTION")) COMPLETE_WITH("SNAPSHOT", "ISOLATION LEVEL", "READ", "DEFERRABLE", "NOT DEFERRABLE"); -- 2.30.2 --=-=-=--