Skip to content

Commit b5607b0

Browse files
committed
Fix case sensitivity in psql's tab completion for GUC names.
Input for these should be case-insensitive, but was not completely so. Comparing to the similar queries for timezone names, I realized that we'd missed forcing the comparison pattern to lower-case. With that, it behaves as I expect. While here, flatten the sub-selects in these queries; I don't find that those add any readability. Discussion: https://postgr.es/m/3369130.1649348542@sss.pgh.pa.us
1 parent 139d46e commit b5607b0

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/bin/psql/tab-complete.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,24 +1006,18 @@ static const SchemaQuery Query_for_trigger_of_table = {
10061006

10071007
/* Use COMPLETE_WITH_QUERY_VERBATIM with these queries for GUC names: */
10081008
#define Query_for_list_of_alter_system_set_vars \
1009-
"SELECT name FROM "\
1010-
" (SELECT pg_catalog.lower(name) AS name FROM pg_catalog.pg_settings "\
1011-
" WHERE context != 'internal' "\
1012-
" ) ss "\
1013-
" WHERE name LIKE '%s'"
1009+
"SELECT pg_catalog.lower(name) FROM pg_catalog.pg_settings "\
1010+
" WHERE context != 'internal' "\
1011+
" AND pg_catalog.lower(name) LIKE pg_catalog.lower('%s')"
10141012

10151013
#define Query_for_list_of_set_vars \
1016-
"SELECT name FROM "\
1017-
" (SELECT pg_catalog.lower(name) AS name FROM pg_catalog.pg_settings "\
1018-
" WHERE context IN ('user', 'superuser') "\
1019-
" ) ss "\
1020-
" WHERE name LIKE '%s'"
1014+
"SELECT pg_catalog.lower(name) FROM pg_catalog.pg_settings "\
1015+
" WHERE context IN ('user', 'superuser') "\
1016+
" AND pg_catalog.lower(name) LIKE pg_catalog.lower('%s')"
10211017

10221018
#define Query_for_list_of_show_vars \
1023-
"SELECT name FROM "\
1024-
" (SELECT pg_catalog.lower(name) AS name FROM pg_catalog.pg_settings "\
1025-
" ) ss "\
1026-
" WHERE name LIKE '%s'"
1019+
"SELECT pg_catalog.lower(name) FROM pg_catalog.pg_settings "\
1020+
" WHERE pg_catalog.lower(name) LIKE pg_catalog.lower('%s')"
10271021

10281022
#define Query_for_list_of_roles \
10291023
" SELECT rolname "\

0 commit comments

Comments
 (0)