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 1nELuZ-0006z9-Ui for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Jan 2022 01:55:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nELuY-0003r4-DD for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Jan 2022 01:55:18 +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 1nELuY-0003qv-4k for pgsql-hackers@lists.postgresql.org; Mon, 31 Jan 2022 01:55:18 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nELuV-0008Lv-SN for pgsql-hackers@lists.postgresql.org; Mon, 31 Jan 2022 01:55:17 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 20V1svVG534642; Sun, 30 Jan 2022 20:54:57 -0500 From: Tom Lane To: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= 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 In-reply-to: <8735l41ynm.fsf@wibble.ilmari.org> 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> <2645164.1643315022@sss.pgh.pa.u! s> <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> Comments: In-reply-to =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= message dated "Mon, 31 Jan 2022 01:28:45 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <534640.1643594097.1@sss.pgh.pa.us> Date: Sun, 30 Jan 2022 20:54:57 -0500 Message-ID: <534641.1643594097@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =?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. Currently, keywords are (usually) visually distinct from non-keywords in those menus, thanks to being upper-case where the object names usually aren't: regression=# create table foo (c1 int, c2 int); CREATE TABLE regression=# alter table foo rename c c1 c2 COLUMN CONSTRAINT With this change, the keywords would be visually indistinguishable from the object names, which I felt wouldn't be a net improvement. We could do something hacky like matching case only when there's no longer any matching object names, but that might be too magic. > The second might be more of a matter of style or opinion, but I noticed > a bunch of `if (foo) free(foo);`, which is redundant given that > `free(NULL)` is a no-op. To simplify the code further, I also made > `escape_string(NULL)` be a no-op, returning `NULL`. Yeah. Our fairly longstanding convention is to avoid doing free(NULL), dating back to when some platforms would crash on it. I realize that's archaic now, but I'm not inclined to change it in just some places. regards, tom lane