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 1uc68g-008wkT-L3 for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Jul 2025 17:41:55 +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 1uc68d-00CKHu-6m for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Jul 2025 17:41:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uc68c-00CKHm-Dw for pgsql-hackers@lists.postgresql.org; Wed, 16 Jul 2025 17:41:51 +0000 Received: from fout-b6-smtp.messagingengine.com ([202.12.124.149]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uc68Z-0086RI-32 for pgsql-hackers@lists.postgresql.org; Wed, 16 Jul 2025 17:41:50 +0000 Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id AC0F01D0003E for ; Wed, 16 Jul 2025 13:41:44 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Wed, 16 Jul 2025 13:41:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm1; t=1752687704; x=1752774104; bh=6YAWwce1NU1WMbdiV9H2I9LFynICTQIB h/O0ogRciTQ=; b=WDg+93bYVXxjspcWB2yclDrIAIRt1YdZ4N70lqagni6sHw3+ FAyL3qL2DBnoWwtC1QB0E/Q6hEN8tV8d2yZbsgeH1Whrf9Z+prxBwD2Vv6TkdflL naf22pDmw0Y2VWp8rS4c4egdcIiWB7PcTLidQLgkJVD4/zVfikcSHRX6SCuIflkV 2xl5KA2UuMvL0jtQVEC9lNb1sDPPL3/3DzmVs016PcUqJfaZfndF7S/QXal3mxRG rmpq9S+WjmigWjmEf7UklCzUgp/1HE6uO+x2tVMUk1b77+DEDrx1qyJqNZWTU+nG N57Stpm89UYiJeQDKpcwQNRbufKL/vl4yQOfrQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1752687704; x= 1752774104; bh=6YAWwce1NU1WMbdiV9H2I9LFynICTQIBh/O0ogRciTQ=; b=C IWWrsSQNbcArBUpJu8MJIvsWDAQtvMkMiZ4BmZs41UDZoXpOU9WMtIzXxG9zpLvO P0XqJ944vH6uFUSX0yzE2vN0wg5YLz1yblpXit+/54fYNa1MVnxnznU1RDqXk4VQ WgwQCPQ8xq/kV1Fj08GEKSnP3FS23C6z0DDZhIj1iYadXRv8F7WtPmBmTlK+cpl5 chBSY53CaFB7SJvzAi4+DvKNhLUBojS9+89ggILzWM9gbrmQlUB+NclT7z8q0Qfc iwrTvdZARgrZxdh3TElNO/xcUiDTRDzz95u4j88o5mQed/qnb+X7uAzwFmKA/Cex sQt7tz7tXfu7NwPc5Oe7Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdehkeefgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhephffvufffkfgfgggtsehmtderredtreejne cuhfhrohhmpeffrghgfhhinhhnucfklhhmrghrihcuofgrnhhnshonkhgvrhcuoehilhhm rghrihesihhlmhgrrhhirdhorhhgqeenucggtffrrghtthgvrhhnpefguddujeegudegke evgfdukeeifeeltdevudekvdeuhfehtdehteevleekfffgueenucffohhmrghinhepphho shhtghhrrdgvshenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehilhhmrghrihesihhlmhgrrhhirdhorhhgpdhnsggprhgtphhtthhopedupdhm ohguvgepshhmthhpohhuthdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlih hsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 16 Jul 2025 13:41:43 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: pgsql-hackers@lists.postgresql.org Subject: Fix tab completion in v18 for ALTER DATABASE/USER/ROLE ... RESET Date: Wed, 16 Jul 2025 18:41:42 +0100 Message-ID: <87qzyghw2x.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (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 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. - ilmari --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Schema-qualify-unnest-call-in-ALTER-DATABASE-.-RESET.patch From 0dc6058941b5195b58d26ad5baeebc9fb4ca36fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Wed, 11 Jun 2025 13:10:54 +0100 Subject: [PATCH 1/2] Schema-qualify unnest() call in ALTER DATABASE ... RESET tab completion Commit 9df8727c5067 added tab completion for ALTER DATABASE ... RESET, but forgot to schema-qualifiy the unnest() call. --- src/bin/psql/tab-complete.in.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 37524364290..5ca9bc2fc0d 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1010,7 +1010,7 @@ static const SchemaQuery Query_for_trigger_of_table = { #define Query_for_list_of_database_vars \ "SELECT conf FROM ("\ -" SELECT setdatabase, pg_catalog.split_part(unnest(setconfig),'=',1) conf"\ +" SELECT setdatabase, pg_catalog.split_part(pg_catalog.unnest(setconfig),'=',1) conf"\ " FROM pg_db_role_setting "\ " ) s, pg_database d "\ " WHERE s.setdatabase = d.oid "\ -- 2.50.1 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Fix-tab-completion-for-ALTER-ROLE-USER-.-RESET.patch From 83bf13c9ea813047d1c462434fe32c54db9b28dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Mon, 9 Jun 2025 20:35:29 +0100 Subject: [PATCH 2/2] Fix tab completion for ALTER ROLE|USER ... RESET Commit c407d5426b87 added tab completion for ALTER ROLE|USER ... RESET, but it was buggy. It showed only the variables set on the role when hitting TAB just after RESET, but as soon as one starts typing something to pick what to complete, it would complete all possible variables, not just the ones set on the role. Fix it in the same way as ALTER DATABASE ... RESET does it. --- src/bin/psql/tab-complete.in.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 5ca9bc2fc0d..257ae55ee32 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1086,9 +1086,12 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " WHERE usename LIKE '%s'" #define Query_for_list_of_user_vars \ -" SELECT pg_catalog.split_part(pg_catalog.unnest(rolconfig),'=',1) "\ -" FROM pg_catalog.pg_roles "\ -" WHERE rolname LIKE '%s'" +"SELECT conf FROM ("\ +" SELECT rolname, pg_catalog.split_part(pg_catalog.unnest(rolconfig),'=',1) conf"\ +" FROM pg_catalog.pg_roles"\ +" ) s"\ +" WHERE s.conf like '%s' "\ +" AND s.rolname LIKE '%s'" #define Query_for_list_of_access_methods \ " SELECT amname "\ @@ -2516,7 +2519,10 @@ match_previous_words(int pattern_id, /* ALTER USER,ROLE RESET */ else if (Matches("ALTER", "USER|ROLE", MatchAny, "RESET")) + { + set_completion_reference(prev2_wd); COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_user_vars, "ALL"); + } /* ALTER USER,ROLE WITH */ else if (Matches("ALTER", "USER|ROLE", MatchAny, "WITH")) -- 2.50.1 --=-=-=--