Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit662dbe2

Browse files
committed
Simplify tab completion of extension versions.
Second thoughts about9cd43f6: given that we're staying bug-compatiblewith the old behavior of using double not single quotes for extensionversions, we can simplify this completion code by pretending thatextension versions *are* identifiers, and not using VERBATIM. Then_complete_from_query() will think that the query results are identifiersin need of quoting, and we end up with the same behavior as before.This doesn't work for Query_for_list_of_available_extension_versions_with_TO,but let's just drop that: there is no other place where we handlemulti-keyword phrases that way, and it doesn't seem very desirable hereeither. Handle completion of "UPDATE TO" in our more usual pattern.Discussion:https://postgr.es/m/CAMkU=1yV+egSYrzWvbDY8VZ6bKEMrKbzxr-HTuiHi+wDgSUMgA@mail.gmail.com
1 parent75bfe74 commit662dbe2

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

‎src/bin/psql/tab-complete.c

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,12 @@ static bool completion_force_quote; /* true to force-quote filenames */
239239
* 4) The list of attributes of the given table (possibly schema-qualified).
240240
* 5) The list of arguments to the given function (possibly schema-qualified).
241241
*
242-
* The query is generally expected to return raw SQL identifiers; quoting
243-
* is handled by the matching machinery. If what is returned is not SQL
244-
* identifiers, use one of the VERBATIM forms (and then, if quoting is
245-
* needed, do it inside the query).
242+
* The query is generally expected to return raw SQL identifiers; matching
243+
* to what the user typed is done in a quoting-aware fashion. If what is
244+
* returned is not SQL identifiers, use one of the VERBATIM forms, in which
245+
* case the query results are matched to the user's text without double-quote
246+
* processing (so if quoting is needed, you must provide it in the query
247+
* results).
246248
*/
247249
#defineCOMPLETE_WITH_QUERY(query) \
248250
COMPLETE_WITH_QUERY_LIST(query, NULL)
@@ -1081,19 +1083,10 @@ static const SchemaQuery Query_for_trigger_of_table = {
10811083
" FROM pg_catalog.pg_available_extensions "\
10821084
" WHERE name LIKE '%s' AND installed_version IS NULL"
10831085

1084-
/* the result of this query is not a raw identifier, so use VERBATIM */
10851086
#defineQuery_for_list_of_available_extension_versions \
1086-
" SELECTpg_catalog.quote_ident(version) "\
1087+
" SELECT version "\
10871088
" FROM pg_catalog.pg_available_extension_versions "\
1088-
" WHERE pg_catalog.quote_ident(version) LIKE '%s'"\
1089-
" AND name='%s'"
1090-
1091-
/* the result of this query is not a raw identifier, so use VERBATIM */
1092-
#defineQuery_for_list_of_available_extension_versions_with_TO \
1093-
" SELECT 'TO ' || pg_catalog.quote_ident(version) "\
1094-
" FROM pg_catalog.pg_available_extension_versions "\
1095-
" WHERE ('TO ' || pg_catalog.quote_ident(version)) LIKE '%s'"\
1096-
" AND name='%s'"
1089+
" WHERE version LIKE '%s' AND name='%s'"
10971090

10981091
#defineQuery_for_list_of_prepared_statements \
10991092
" SELECT name "\
@@ -1934,20 +1927,17 @@ psql_completion(const char *text, int start, int end)
19341927

19351928
/* ALTER EXTENSION <name> */
19361929
elseif (Matches("ALTER","EXTENSION",MatchAny))
1937-
COMPLETE_WITH("ADD","DROP","UPDATE","SET SCHEMA");
1930+
COMPLETE_WITH("ADD","DROP","UPDATE TO","SET SCHEMA");
19381931

19391932
/* ALTER EXTENSION <name> UPDATE */
19401933
elseif (Matches("ALTER","EXTENSION",MatchAny,"UPDATE"))
1941-
{
1942-
set_completion_reference(prev2_wd);
1943-
COMPLETE_WITH_QUERY_VERBATIM(Query_for_list_of_available_extension_versions_with_TO);
1944-
}
1934+
COMPLETE_WITH("TO");
19451935

19461936
/* ALTER EXTENSION <name> UPDATE TO */
19471937
elseif (Matches("ALTER","EXTENSION",MatchAny,"UPDATE","TO"))
19481938
{
19491939
set_completion_reference(prev3_wd);
1950-
COMPLETE_WITH_QUERY_VERBATIM(Query_for_list_of_available_extension_versions);
1940+
COMPLETE_WITH_QUERY(Query_for_list_of_available_extension_versions);
19511941
}
19521942

19531943
/* ALTER FOREIGN */
@@ -2824,7 +2814,7 @@ psql_completion(const char *text, int start, int end)
28242814
elseif (Matches("CREATE","EXTENSION",MatchAny,"VERSION"))
28252815
{
28262816
set_completion_reference(prev2_wd);
2827-
COMPLETE_WITH_QUERY_VERBATIM(Query_for_list_of_available_extension_versions);
2817+
COMPLETE_WITH_QUERY(Query_for_list_of_available_extension_versions);
28282818
}
28292819

28302820
/* CREATE FOREIGN */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp