diff options
Diffstat (limited to 'src/bin/psql/tab-complete.c')
| -rw-r--r-- | src/bin/psql/tab-complete.c | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index d6fffcf42f1..6e759d0b76f 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -3775,8 +3775,9 @@ append_variable_names(char ***varnames, int *nvars, /* * This function supports completion with the name of a psql variable. * The variable names can be prefixed and suffixed with additional text - * to support quoting usages. If need_value is true, only the variables - * that have the set values are picked up. + * to support quoting usages. If need_value is true, only variables + * that are currently set are included; otherwise, special variables + * (those that have hooks) are included even if currently unset. */ static char ** complete_from_variables(const char *text, const char *prefix, const char *suffix, @@ -3789,33 +3790,12 @@ complete_from_variables(const char *text, const char *prefix, const char *suffix int i; struct _variable *ptr; - static const char *const known_varnames[] = { - "AUTOCOMMIT", "COMP_KEYWORD_CASE", "DBNAME", "ECHO", "ECHO_HIDDEN", - "ENCODING", "FETCH_COUNT", "HISTCONTROL", "HISTFILE", "HISTSIZE", - "HOST", "IGNOREEOF", "LASTOID", "ON_ERROR_ROLLBACK", "ON_ERROR_STOP", - "PORT", "PROMPT1", "PROMPT2", "PROMPT3", "QUIET", - "SHOW_CONTEXT", "SINGLELINE", "SINGLESTEP", - "USER", "VERBOSITY", NULL - }; - varnames = (char **) pg_malloc((maxvars + 1) * sizeof(char *)); - if (!need_value) - { - for (i = 0; known_varnames[i] && nvars < maxvars; i++) - append_variable_names(&varnames, &nvars, &maxvars, - known_varnames[i], prefix, suffix); - } - for (ptr = pset.vars->next; ptr; ptr = ptr->next) { if (need_value && !(ptr->value)) continue; - for (i = 0; known_varnames[i]; i++) /* remove duplicate entry */ - { - if (strcmp(ptr->name, known_varnames[i]) == 0) - continue; - } append_variable_names(&varnames, &nvars, &maxvars, ptr->name, prefix, suffix); } |
