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

Commit9cd43f6

Browse files
committed
Fix busted tab completion of extension versions.
In02b8048 I (tgl) got rid of the need for most tab-completion queriesto return pre-quoted identifiers. But I over-hastily removed thequote_ident call from Query_for_list_of_available_extension_versions*too; those still need it, because what is returned isn't an identifierat all and will (almost?) always need quoting.Arguably we should use quote_literal here instead. But quote_identworks too and people may be used to that behavior, so stick with it.In passing, fix inconsistent omission of schema-qualification inQuery_for_list_of_encodings. That's not a security issue per ourcurrent guidelines, but it ought to be like the rest.Jeff JanesDiscussion:https://postgr.es/m/CAMkU=1yV+egSYrzWvbDY8VZ6bKEMrKbzxr-HTuiHi+wDgSUMgA@mail.gmail.com
1 parent7bd4a9e commit9cd43f6

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ static bool completion_force_quote; /* true to force-quote filenames */
238238
* QUERY_PLUS forms combine such literal lists with a query result.
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).
241+
*
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).
241246
*/
242247
#defineCOMPLETE_WITH_QUERY(query) \
243248
COMPLETE_WITH_QUERY_LIST(query, NULL)
@@ -992,7 +997,7 @@ static const SchemaQuery Query_for_trigger_of_table = {
992997
#defineQuery_for_list_of_encodings \
993998
" SELECT DISTINCT pg_catalog.pg_encoding_to_char(conforencoding) "\
994999
" FROM pg_catalog.pg_conversion "\
995-
" WHERE pg_catalog.pg_encoding_to_char(conforencoding) LIKEUPPER('%s')"
1000+
" WHERE pg_catalog.pg_encoding_to_char(conforencoding) LIKEpg_catalog.upper('%s')"
9961001

9971002
#defineQuery_for_list_of_languages \
9981003
"SELECT lanname "\
@@ -1076,18 +1081,18 @@ static const SchemaQuery Query_for_trigger_of_table = {
10761081
" FROM pg_catalog.pg_available_extensions "\
10771082
" WHERE name LIKE '%s' AND installed_version IS NULL"
10781083

1079-
/* the result of this query is notan identifier, so use VERBATIM */
1084+
/* the result of this query is nota raw identifier, so use VERBATIM */
10801085
#defineQuery_for_list_of_available_extension_versions \
1081-
" SELECT version "\
1086+
" SELECTpg_catalog.quote_ident(version) "\
10821087
" FROM pg_catalog.pg_available_extension_versions "\
1083-
" WHERE version LIKE '%s'"\
1088+
" WHEREpg_catalog.quote_ident(version) LIKE '%s'"\
10841089
" AND name='%s'"
10851090

1086-
/* the result of this query is notan identifier, so use VERBATIM */
1091+
/* the result of this query is nota raw identifier, so use VERBATIM */
10871092
#defineQuery_for_list_of_available_extension_versions_with_TO \
1088-
" SELECT 'TO ' || version "\
1093+
" SELECT 'TO ' ||pg_catalog.quote_ident(version) "\
10891094
" FROM pg_catalog.pg_available_extension_versions "\
1090-
" WHERE ('TO ' || version) LIKE '%s'"\
1095+
" WHERE ('TO ' ||pg_catalog.quote_ident(version)) LIKE '%s'"\
10911096
" AND name='%s'"
10921097

10931098
#defineQuery_for_list_of_prepared_statements \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp