vartabcomplete-experimental.diff
text/x-patch
Filename: vartabcomplete-experimental.diff
Type: text/x-patch
Part: 1
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: context
| File | + | − |
|---|---|---|
| src/bin/psql/tab-complete.c | 85 | 1 |
*** ./src/bin/psql/tab-complete.c.orig 2010-08-14 15:59:49.000000000 +0200
--- ./src/bin/psql/tab-complete.c 2010-10-04 11:31:25.834909194 +0200
***************
*** 2447,2453 ****
pg_strcasecmp(prev3_wd, "\\copy") != 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tsv, NULL);
-
/* Backslash commands */
/* TODO: \dc \dd \dl */
else if (strcmp(prev_wd, "\\connect") == 0 || strcmp(prev_wd, "\\c") == 0)
--- 2447,2452 ----
***************
*** 2517,2522 ****
--- 2516,2606 ----
COMPLETE_WITH_LIST(my_list);
}
+ else if (strcmp(prev_wd, "\\set") == 0)
+ {
+ const char **varnames;
+ int nvars = 0;
+ int size = 100;
+ struct _variable *ptr;
+
+ varnames = (const char **) pg_malloc((size + 1) * sizeof(char *));
+
+ /* fill array of varnames */
+ for (ptr = pset.vars->next; ptr; ptr = ptr->next)
+ {
+ if (nvars == size)
+ {
+ size = size + 100;
+ varnames = (const char **) realloc(varnames, (size + 1) * sizeof(char *));
+ if (!varnames)
+ {
+ psql_error("out of memory\n");
+ exit(EXIT_FAILURE);
+ }
+ }
+ varnames[nvars++] = ptr->name;
+ }
+ varnames[nvars] = NULL;
+ COMPLETE_WITH_LIST(varnames);
+
+ free(varnames);
+ }
+ else if (strncmp(text,"::", 2) != 0 && strncmp(text, ":", 1) == 0)
+ {
+ const char **varnames;
+ int nvars = 0;
+ int size = 100;
+ struct _variable *ptr;
+ const char *prefix;
+ const char *sufix;
+ char *buffer;
+
+ if (strncmp(text, ":'", 2) == 0)
+ {
+ prefix = ":'";
+ sufix = "'";
+ }
+ else if (strncmp(text, ":\"", 2) == 0)
+ {
+ prefix = ":\"";
+ sufix = "\"";
+ }
+ else
+ {
+ prefix = ":";
+ sufix = "";
+ }
+
+ varnames = (const char **) pg_malloc((size + 1) * sizeof(char *));
+
+ /* fill array of varnames */
+ for (ptr = pset.vars->next; ptr; ptr = ptr->next)
+ {
+ int n;
+
+ if (nvars == size)
+ {
+ size = size + 100;
+ varnames = (const char **) realloc(varnames, (size + 1) * sizeof(char *));
+ if (!varnames)
+ {
+ psql_error("out of memory\n");
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ /* alloc enought for name, prefix, and suffix */
+ n = strlen(ptr->name) + 2 + 1 + 1;
+ buffer = (char *) pg_malloc(n);
+ snprintf(buffer, n, "%s%s%s", prefix, ptr->name, sufix);
+ varnames[nvars++] = buffer;
+
+ }
+ varnames[nvars] = NULL;
+ COMPLETE_WITH_LIST(varnames);
+
+ free(varnames);
+ }
else if (strcmp(prev_wd, "\\sf") == 0 || strcmp(prev_wd, "\\sf+") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_functions, NULL);
else if (strcmp(prev_wd, "\\cd") == 0 ||