Another tweak for tab completion of CREATE TEMP. Instead of only
authorNeil Conway <neilc@samurai.com>
Thu, 26 Apr 2007 22:25:56 +0000 (22:25 +0000)
committerNeil Conway <neilc@samurai.com>
Thu, 26 Apr 2007 22:25:56 +0000 (22:25 +0000)
completing CREATE { TEMP | TEMPORARY } TABLE, we should also suggest
VIEW and SEQUENCE. Per Greg Sabino Mullane.

src/bin/psql/tab-complete.c

index 612702ffad4ff8fec41ca9715bd80413c8b20c51..06ba257cfd3bc064e972afc3e3cf9a4f7d0bdabb 100644 (file)
@@ -1107,11 +1107,16 @@ psql_completion(char *text, int start, int end)
                COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
 
 /* CREATE TABLE */
-       /* Complete CREATE TEMP/TEMPORARY with "TABLE" */
+       /* Complete "CREATE TEMP/TEMPORARY" with the possible temp objects */
        else if (pg_strcasecmp(prev2_wd, "CREATE") == 0 &&
                         (pg_strcasecmp(prev_wd, "TEMP") == 0 ||
                          pg_strcasecmp(prev_wd, "TEMPORARY") == 0))
-               COMPLETE_WITH_CONST("TABLE");
+       {
+               static const char *const list_TEMP[] =
+               { "SEQUENCE", "TABLE", "VIEW", NULL };
+
+               COMPLETE_WITH_LIST(list_TEMP);
+       }
 
 /* CREATE TABLESPACE */
        else if (pg_strcasecmp(prev3_wd, "CREATE") == 0 &&