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 1nW1XB-0001po-EC for pgsql-hackers@arkaria.postgresql.org; Sun, 20 Mar 2022 19:48:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nW1XA-0005hx-1Y for pgsql-hackers@arkaria.postgresql.org; Sun, 20 Mar 2022 19:48:12 +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 1nW1X8-0005ho-CI for pgsql-hackers@lists.postgresql.org; Sun, 20 Mar 2022 19:48:11 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nW1X4-0006nh-7q for pgsql-hackers@lists.postgresql.org; Sun, 20 Mar 2022 19:48:10 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 5A8BD3200C10; Sun, 20 Mar 2022 15:48:02 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 20 Mar 2022 15:48:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :cc:content-transfer-encoding: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=fm2; bh=F+hhEWrHnEClJ7 xznLRlbSzDxHrrPJbiYRR4KAYEmjA=; b=hzeShyEXr6uD/kpDfZYDNbWdiBjtdp 96Ks1v5yLPANw+SY9klCZmQN5HdOQ/r6gk58eucmFEPA6wJHw6wzJHMzM0DHU0sQ lmrYLqGxOkfDzfnq6aPumGARP5rpMhZRnAmvB88gFi1MM+tu5ijjF7CjUGeE4K43 bd2bJxpupjPzOtYHX2NY+KNZ44QlaT9gM7VTKZlmw/ABTlah7sGVOgd8PVGPcEa2 jkee3Rwu1928CXvAgcU58VFldhhg/fyPRSUmQaYmf3z+qlP3KmTF5k+MsEysSuB6 4ltg3xs2XK5gnanE6xbmwpOUR2IO+uL6iwh7NJTC0R1b6FamOyYR5PtA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm3; bh=F+hhEWrHnEClJ7xznLRlbSzDxHrrPJbiYRR4KAYEm jA=; b=QK0AUXtEFO06w6x3WHB1R6LPoEYKxBy/hqTKCSnFvIInlGR24ur/nbugr w3XlxItoCED5BE/sU4mHzOv5teYPgjamaQ4mif0R16XZFHVqunqOU756wYjSLVE9 57Gcho3AFdC+HlGkCQStAaK8jQyvagyXBmE25jLZZVZJatkBLnq9XCfAap4ADn+j gd27vT4egQrPSssKJSoiP+dyT6Y3oVmb5RN8pvVh1gBeLVARYpvJzU9Qch9VeMlB dESPrTdDelRueY5q+DGEJ+rMTIt9VpCKgRh72jam4d1xExLw18RG1ka0C9akaO27 c1KM2VbkC8zRxDpHb16tz2LeoqKEw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudeguddguddvlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufhfffgjkfgfgggtgfesth ekredttderjeenucfhrhhomhepffgrghhfihhnnhgpkfhlmhgrrhhipgforghnnhhsnohk vghruceoihhlmhgrrhhisehilhhmrghrihdrohhrgheqnecuggftrfgrthhtvghrnhepve duudduieelfeeileduhfelteeuleefheffkeevjeevhffhffegtdeffedtheffnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhlmhgrrhhise hilhhmrghrihdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 20 Mar 2022 15:48:01 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Tab completion for SET TimeZone References: <87k0curq0w.fsf@wibble.ilmari.org> <87h77yrpsu.fsf@wibble.ilmari.org> <514658.1647438049@sss.pgh.pa.us> <87czikrtc1.fsf@wibble.ilmari.org> <87a6dnsgyr.fsf@wibble.ilmari.org> <1157472.1647629584@sss.pgh.pa.us> Date: Sun, 20 Mar 2022 19:47:58 +0000 In-Reply-To: <1157472.1647629584@sss.pgh.pa.us> (Tom Lane's message of "Fri, 18 Mar 2022 14:53:04 -0400") Message-ID: <877d8os8wh.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tom Lane writes: > =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= writes: >> I just realised there's no point in the subselect when I'm not applying >> the same function in the WHERE and the SELECT, so here's an updated >> version that simplifies that. It also fixes a typo in the commit >> message. > > This doesn't work right for me under libedit -- it will correctly > complete "am" to "'America/", but then it fails to complete > anything past that. The reason seems to be that once we have a > leading single quote, libedit will include that in the text passed > to future completion attempts, while readline won't. I ended up > needing three query variants, as attached (bikeshedding welcome). Well spotted, I must have just tested that it completed something on the first tab. The fix looks reasonable to me, and I have no better ideas for the names of the query string #defines. > I think the reason the COMPLETE_WITH_ENUM_VALUE macro doesn't look > similar is that it hasn't made an attempt to work with input that > the user didn't quote --- that is, if you type > alter type planets rename value ur > it just fails to match anything, instead of providing "'uranus'". > Should we upgrade that likewise?` The comment says it will add the quote before text if it's not there, so maybe we should adjust that to say that it will only add the quote if the user hasn't typed anything? > Not sure it's worth the trouble though; I think > COMPLETE_WITH_ENUM_VALUE is there more as a finger exercise than > because people use it regularly. I agree, I mostly implemented that for completeness after adding ALTER TYPE … RENAME VALUE. Also, enum values always need quoting, while SET TIMEZONE doesn't if the zone name follows identifier syntax and people might start typing it without quotes if they intend set one of those, so the extra effort to make that work even though we can't suggest a mix of quoted and non-quoted names is worth it. > I added a regression test case too. Good idea idea, I keep forgetting that we actually have tests for tab completion, since most cases are so simple and obviously correct that we don't bother with tests for them. > ... btw, I forgot to mention that I don't see any problem with > the patch's behavior for DEFAULT. What I see with both readline > and libedit is that if you type something reasonable, like > set timezone to d > then it will correctly complete "efault ", without any extra > quotes. Now, if you're silly and do > set timezone to 'd > then readline gives you "efault' " and libedit gives you nothing. > But I think that's your own, um, fault. I agree, it was just a quirk noticed while testing. Also, it helps that there aren't any actual time zone names starting with 'd'. > We don't have any other places where tab completion is so aggressive > as to remove quotes from a keyword. I noticed afterwards that other config varables behave the same, so even if we wanted to improve that, it's outwith the scope of this patch. > regards, tom lane - ilmari