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 1o2myx-00069o-RX for pgsql-hackers@arkaria.postgresql.org; Sun, 19 Jun 2022 04:56: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 1o2myw-0008Mb-IT for pgsql-hackers@arkaria.postgresql.org; Sun, 19 Jun 2022 04:56:18 +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 1o2myw-0008MS-99 for pgsql-hackers@lists.postgresql.org; Sun, 19 Jun 2022 04:56:18 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o2myt-0003Kb-WB for pgsql-hackers@lists.postgresql.org; Sun, 19 Jun 2022 04:56: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 25J4uDSP1930938; Sun, 19 Jun 2022 00:56:13 -0400 From: Tom Lane To: Jeff Janes cc: PostgreSQL Hackers Subject: Re: 15beta1 tab completion of extension versions In-reply-to: <1803867.1655596168@sss.pgh.pa.us> References: <1803867.1655596168@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sat, 18 Jun 2022 19:49:28 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <1930779.1655614547.0@sss.pgh.pa.us> Date: Sun, 19 Jun 2022 00:56:13 -0400 Message-ID: <1930937.1655614573@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1930779.1655614547.1@sss.pgh.pa.us> I wrote: > Jeff Janes writes: >> Putting pg_catalog.quote_ident back >> into Query_for_list_of_available_extension_versions* fixes it, but might >> not be the best way to fix it. > Yeah, that seems like the appropriate fix. Done, thanks for the report! Actually ... after further thought it seems like maybe we should make this more like other cases rather than less so. ISTM that much of the issue here is somebody's decision that "TO version" should be offered as a completion of "UPDATE", which is unlike the way we do this anywhere else --- the usual thing is to offer "UPDATE TO" as a single completion. So I'm thinking about the attached. This behaves a little differently from the old code. In v14, alter extension pg_trgm upd gives you alter extension pg_trgm update and another produces alter extension pg_trgm update TO "1. With this, alter extension pg_trgm upd gives you alter extension pg_trgm update to and another produces alter extension pg_trgm update to "1. That seems more consistent with other cases, and it's the same number of presses. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="further-extension-version-tab-hacking.patch"; charset="us-ascii" Content-ID: <1930779.1655614547.2@sss.pgh.pa.us> Content-Description: further-extension-version-tab-hacking.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 7f0ab5acb9..941daaeb7c 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1081,19 +1081,10 @@ static const SchemaQuery Query_for_trigger_of_tabl= e =3D { " FROM pg_catalog.pg_available_extensions "\ " WHERE name LIKE '%s' AND installed_version IS NULL" = -/* the result of this query is not a raw identifier, so use VERBATIM */ #define Query_for_list_of_available_extension_versions \ -" SELECT pg_catalog.quote_ident(version) "\ +" SELECT version "\ " FROM pg_catalog.pg_available_extension_versions "\ -" WHERE pg_catalog.quote_ident(version) LIKE '%s'"\ -" AND name=3D'%s'" - -/* the result of this query is not a raw identifier, so use VERBATIM */ -#define Query_for_list_of_available_extension_versions_with_TO \ -" SELECT 'TO ' || pg_catalog.quote_ident(version) "\ -" FROM pg_catalog.pg_available_extension_versions "\ -" WHERE ('TO ' || pg_catalog.quote_ident(version)) LIKE '%s'"\ -" AND name=3D'%s'" +" WHERE version LIKE '%s' AND name=3D'%s'" = #define Query_for_list_of_prepared_statements \ " SELECT name "\ @@ -1934,20 +1925,17 @@ psql_completion(const char *text, int start, int e= nd) = /* ALTER EXTENSION */ else if (Matches("ALTER", "EXTENSION", MatchAny)) - COMPLETE_WITH("ADD", "DROP", "UPDATE", "SET SCHEMA"); + COMPLETE_WITH("ADD", "DROP", "UPDATE TO", "SET SCHEMA"); = /* ALTER EXTENSION UPDATE */ else if (Matches("ALTER", "EXTENSION", MatchAny, "UPDATE")) - { - set_completion_reference(prev2_wd); - COMPLETE_WITH_QUERY_VERBATIM(Query_for_list_of_available_extension_vers= ions_with_TO); - } + COMPLETE_WITH("TO"); = /* ALTER EXTENSION UPDATE TO */ else if (Matches("ALTER", "EXTENSION", MatchAny, "UPDATE", "TO")) { set_completion_reference(prev3_wd); - COMPLETE_WITH_QUERY_VERBATIM(Query_for_list_of_available_extension_vers= ions); + COMPLETE_WITH_QUERY(Query_for_list_of_available_extension_versions); } = /* ALTER FOREIGN */ @@ -2824,7 +2812,7 @@ psql_completion(const char *text, int start, int end= ) else if (Matches("CREATE", "EXTENSION", MatchAny, "VERSION")) { set_completion_reference(prev2_wd); - COMPLETE_WITH_QUERY_VERBATIM(Query_for_list_of_available_extension_vers= ions); + COMPLETE_WITH_QUERY(Query_for_list_of_available_extension_versions); } = /* CREATE FOREIGN */ ------- =_aaaaaaaaaa0--