Minimal psql tab completion support for SET search_path.
authorAndres Freund <andres@anarazel.de>
Sat, 12 Jul 2014 13:44:39 +0000 (15:44 +0200)
committerAndres Freund <andres@anarazel.de>
Sat, 12 Jul 2014 13:44:39 +0000 (15:44 +0200)
Complete SET search_path = ... to non-temporary and non-toast
schemas. Since there pretty much is no use case to add those to the
search path and there can be many it's helpful to exclude them.

It'd be nicer to complete multiple search path elements, but that's
not easy.

Jeff Janes

src/bin/psql/tab-complete.c

index c3a54d458a1ac7df1f6a983c5b6fd68e45a31b32..24e60b760917ccd9dddbdef2c15b177e07066bd6 100644 (file)
@@ -3352,6 +3352,13 @@ psql_completion(const char *text, int start, int end)
 
            COMPLETE_WITH_LIST(my_list);
        }
+       else if (pg_strcasecmp(prev2_wd, "search_path") == 0)
+       {
+           COMPLETE_WITH_QUERY(Query_for_list_of_schemas
+                               " AND nspname not like 'pg\\_toast%%' "
+                               " AND nspname not like 'pg\\_temp%%' "
+                               " UNION SELECT 'DEFAULT' ");
+       }
        else
        {
            static const char *const my_list[] =