Re: tab completion for setting search_path - Mailing list pgsql-hackers

From Bernd Helmle
Subject Re: tab completion for setting search_path
Date
Msg-id 095C748792186DC819637750@apophis.credativ.lan
Whole thread Raw
In response to Re: tab completion for setting search_path  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-hackers

--On 3. Mai 2014 10:11:33 +0200 Andres Freund <andres@2ndquadrant.com> 
wrote:

>> diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
>> new file mode 100644
>> index 6d26ffc..dec3d4a
>> *** a/src/bin/psql/tab-complete.c
>> --- b/src/bin/psql/tab-complete.c
>> *************** psql_completion(const char *text, int st
>> *** 3230,3235 ****
>> --- 3230,3242 ----
>>
>>               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\\_%%' "
>> +                                 " AND nspname not like 'information_schema' "
>> +                                 " UNION SELECT 'DEFAULT' ");
>> +         }
>
> Why should we exclude system schemata? That seems more likely to be
> confusing than helpful? I can see a point in excluding another backend's
> temp tables, but otherwise?

I put my hands on this a while ago, too, but had a different notion in 
mind, which schema the completion should select. I came up with the 
following:

<http://git.postgresql.org/gitweb/?p=users/bernd/postgres.git;a=commitdiff;h=03fd00cd190e8b529efeec1a1bb038454fb0b05f>

Just complete to a schema someone has CREATE or USAGE privs. However, the 
reason i stopped working on it was that i really want to have a completion 
to a list of schemas as well and i couldn't figure a good and easy way to 
do this atm.

-- 
Thanks
Bernd



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: 9.4 release notes
Next
From: Tom Lane
Date:
Subject: Re: Cluster name in ps output