diff options
-rw-r--r-- | src/bin/psql/tab-complete.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 65d9610892..3b6498671c 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -576,6 +576,12 @@ static const SchemaQuery Query_for_list_of_matviews = { "SELECT pg_catalog.quote_ident(nspname) FROM pg_catalog.pg_namespace "\ " WHERE substring(pg_catalog.quote_ident(nspname),1,%d)='%s'" +#define Query_for_list_of_schemas_with_privs \ +"SELECT pg_catalog.quote_ident(nspname) FROM pg_catalog.pg_namespace "\ +" WHERE substring(pg_catalog.quote_ident(nspname),1,%d)='%s'"\ +" AND (has_schema_privilege(current_role::name, oid, 'USAGE'::text)"\ +" OR has_schema_privilege(current_role::name, oid, 'CREATE'::text))" + #define Query_for_list_of_set_vars \ "SELECT name FROM "\ " (SELECT pg_catalog.lower(name) AS name FROM pg_catalog.pg_settings "\ @@ -3123,7 +3129,7 @@ psql_completion(char *text, int start, int end) } else if (pg_strcasecmp(prev2_wd, "search_path") == 0) { - COMPLETE_WITH_QUERY(Query_for_list_of_schemas); + COMPLETE_WITH_QUERY(Query_for_list_of_schemas_with_privs); } else { |