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 1uh3so-00A7BE-I5 for pgsql-hackers@arkaria.postgresql.org; Wed, 30 Jul 2025 10:18:03 +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 1uh3sn-008coS-J7 for pgsql-hackers@arkaria.postgresql.org; Wed, 30 Jul 2025 10:18:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uh3sn-008coJ-0W for pgsql-hackers@lists.postgresql.org; Wed, 30 Jul 2025 10:18:01 +0000 Received: from fhigh-b7-smtp.messagingengine.com ([202.12.124.158]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uh3sl-001XM3-0C for pgsql-hackers@lists.postgresql.org; Wed, 30 Jul 2025 10:18:00 +0000 Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 0151A7A1F0C; Wed, 30 Jul 2025 06:17:57 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Wed, 30 Jul 2025 06:17:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :cc:content-transfer-encoding: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=1753870677; x=1753957077; bh=nv1wnXyNYWEAR71wE+iG9OwJD4TFJA0Yf2wkx3b/Pew=; b= H6l8U/fW7DMaJA9Ji3zkgjBjcmcjRiO5hHdskCfD/OSPoTO9fIfCAEBGsc0zhdXH foVewrNNLTuFTSNcXSNPfJxJrVsfMehscsm7oknWsCVcPQq/CQYg3v1tjDe38Y+a 9qLzjhl5MLpxojCE0d6djl+sZ5QPmGmF0WAtJt1r+F3AlMrDewdrsZtgD9AemxsF OxH7adONj7kGGBy1MdxNMljDtpgqvixo1dDjwClM3R5UW1/MiFVyiST9+TvE2T2O gzXtvzOpXieNTmTkNa/op/H28X1vie+qBY2q0PcQG5a0DHKrwKKzphT9CtJNckrB ZRxphP0HF0orYG2r8iCCuw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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-sender:x-me-sender:x-sasl-enc; s=fm3; t=1753870677; x= 1753957077; bh=nv1wnXyNYWEAR71wE+iG9OwJD4TFJA0Yf2wkx3b/Pew=; b=G DpPnMuJgDjRLiBTIl8fXLTlosSdlHLUIEXoEE6yKj0ruEiO9mAyEDldpdGsZArgf sQYe9rPSBqEZMQ1ecKLZmgMGPLWaGYdL9iDrAV93yWTqdwCs6skbjQXXHhFFW8rx kDemMbvMgOKST2tdS7w3mCOFwlB48QdqjUi2Ppf/6JI5bXUBEw7I3O8Hsff2WATR RuWvQkVLZBGujOGu0+UXyhZziEOTbllJOheMZJ3TTmG4Jdo0rA7rmj+8vv9ebIud kyG7xY5iy9eBBTKYeZkHMDx/0SG35ois3woImmvl5DxHRbfdxWMXFocaS+wpfYOA A60tzGBVKJtOInJ9ntFrQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdeljeeijecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhvfevufhfffgjkfgfgggtgfesthekredttderjeenucfhrhhomhepffgrghhfihhn nhcukfhlmhgrrhhiucforghnnhhsnohkvghruceoihhlmhgrrhhisehilhhmrghrihdroh hrgheqnecuggftrfgrthhtvghrnhepfeehteetveeltdduueduffdvtdeuudejueethefg leegtdeftdefleehkefgudfgnecuffhomhgrihhnpehpohhsthhgrhdrvghsnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhlmhgrrhhisehi lhhmrghrihdrohhrghdpnhgspghrtghpthhtohephedpmhhouggvpehsmhhtphhouhhtpd hrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghs qhhlrdhorhhgpdhrtghpthhtohepthhomhgrshdrvhhonhgurhgrsehpohhsthhgrhgvsh hqlhdrohhrghdprhgtphhtthhopehthhgrrhgrkhgrnhesghhmrghilhdrtghomhdprhgt phhtthhopehjihgrnhdruhhnihhvvghrshgrlhhithihsehgmhgrihhlrdgtohhmpdhrtg hpthhtohepthhomhgrshesvhhonhgurhgrrdhmvg X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 30 Jul 2025 06:17:56 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: Tomas Vondra Cc: jian he , Robins Tharakan , Tomas Vondra , pgsql-hackers@lists.postgresql.org Subject: Re: Fix tab completion in v18 for ALTER DATABASE/USER/ROLE ... RESET References: <87qzyghw2x.fsf@wibble.ilmari.org> <87ecu8iid7.fsf@wibble.ilmari.org> <54b435ab-ce2a-4a65-b4a9-35633dea2b28@vondra.me> Date: Wed, 30 Jul 2025 11:17:55 +0100 In-Reply-To: <54b435ab-ce2a-4a65-b4a9-35633dea2b28@vondra.me> (Tomas Vondra's message of "Tue, 29 Jul 2025 19:13:13 +0200") Message-ID: <875xfahtik.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (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 Tomas Vondra writes: > On 7/22/25 13:18, Dagfinn Ilmari Mannsåker wrote: >> jian he writes: >> >>> On Thu, Jul 17, 2025 at 1:41 AM Dagfinn Ilmari Mannsåker >>> wrote: >>>> >>>> Hi hackers, >>>> >>>> These two patches are split out from my earlier thread about improving >>>> tab completion for varous RESET forms >>>> (https://postgr.es/m/87bjqwwtic.fsf@wibble.ilmari.org), so that the bug >>>> fixes can be tracked as an open item for v18. >>>> >>>> Commits 9df8727c5067 and c407d5426b87 added tab completion for ALTER >>>> DATABASE ... RESET and ALTER ROLE/USER ... RESET, respectively, but >>>> they're both differently buggy. The query for the DATABASE form >>>> neglected to schema-qualify the unnest() call, and the query for the >>>> ROLE/USER form shows all possible variables once you start typing a >>>> variable name, not just the ones that are set on the role. The attached >>>> patches fix both. >>>> >>> >>> I played around with it, and overall it looks good. >> >> Thanks for the review. >> >> I realise I should have included Robins and Tomas in the original mail, >> since they were the author and committer, respectively, of the original >> patches. I've added them now, and reattached the patches for their >> convenience. >> > > Thanks for the fixes. Both seem correct to me. It took me a while to > reproduce some sort of issue with unnest(), but that was mostly because > I didn't realize the tab completion does not report errors to the user. > > While testing the ALTER ROLE part, I realized there's a second related > issue with similar symptoms - after starting to type a variable that is > *not* set for the role, it was offering all matching variables anyway. I > believe that's because of the block at line ~5022. The "database" case > was already excluded, so I made 0002 to do that for ROLE too. Ah, good catch, I missed that edge case. > @@ -5015,7 +5021,8 @@ match_previous_words(int pattern_id, > /* Complete with a variable name */ > else if (TailMatches("SET|RESET") && > !TailMatches("UPDATE", MatchAny, "SET") && > - !TailMatches("ALTER", "DATABASE", MatchAny, "RESET")) > + !TailMatches("ALTER", "DATABASE", MatchAny, "RESET") && > + !TailMatches("ALTER", "USER|ROLE", MatchAny, "RESET")) > COMPLETE_WITH_QUERY_VERBATIM_PLUS(Query_for_list_of_set_vars, > "CONSTRAINTS", > "TRANSACTION", Instead of adding another !TailMatches() call, why not just change "DATABASE" to "DATABASE|ROLE|USER"? - ilmari