Re: tab completion for setting search_path

Lists: pgsql-hackers
From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: tab completion for setting search_path
Date: 2014-05-03 05:34:55
Message-ID: CAMkU=1xMsJZ3dJhHvH5ba5L40h6QKd1FcaHZ-Nu4G9_A8T=oew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I've been working with an app that uses a schema name whose spelling is
hard to type, and the lack of tab completion for "SET search_path TO" was
bugging me. So see attached.

I filter out the system schemata, but not public.

For commit fest next.

Cheers,

Jeff


From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-05-03 07:13:45
Message-ID: CAMkU=1xJzK0h7=0_sOLLKGaf7zSwp_YzcKwuG41Ns+_Qcn+t=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Friday, May 2, 2014, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:

> I've been working with an app that uses a schema name whose spelling is
> hard to type, and the lack of tab completion for "SET search_path TO" was
> bugging me. So see attached.
>
> I filter out the system schemata, but not public.
>
> For commit fest next.
>

Once more, with attachment....

Cheers,

Jeff

Attachment Content-Type Size
search_path_complete_v1.patch text/x-patch 639 bytes

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-05-03 08:11:33
Message-ID: 20140503081133.GH12715@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-05-03 00:13:45 -0700, Jeff Janes wrote:
> On Friday, May 2, 2014, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
>
> > I've been working with an app that uses a schema name whose spelling is
> > hard to type, and the lack of tab completion for "SET search_path TO" was
> > bugging me. So see attached.
> >
> > I filter out the system schemata, but not public.

That'd be nice.

> 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?

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Andres Freund <andres(at)2ndquadrant(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-05-05 13:49:34
Message-ID: 095C748792186DC819637750@apophis.credativ.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

--On 3. Mai 2014 10:11:33 +0200 Andres Freund <andres(at)2ndquadrant(dot)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


From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-05-05 16:10:17
Message-ID: CAMkU=1yo97bcGR-z6wg-OJpHKfEcaaaS=X1N7xYGxcUAKV5r9g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, May 3, 2014 at 1:11 AM, Andres Freund <andres(at)2ndquadrant(dot)com>wrote:

> On 2014-05-03 00:13:45 -0700, Jeff Janes wrote:
> > On Friday, May 2, 2014, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
> >
> > > I've been working with an app that uses a schema name whose spelling is
> > > hard to type, and the lack of tab completion for "SET search_path TO"
> was
> > > bugging me. So see attached.
> > >
> > > I filter out the system schemata, but not public.
>
> That'd be nice.
>
> > 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've personally never had a need to set the search_path to a system schema,
and I guess I was implicitly modelling this on what is returned by \dn, not
by \dnS. I wouldn't object much to including them; that would be better
than not having any completion. I just don't see much point.

And now playing a bit with the system ones, I think it would be more
confusing to offer them. pg_catalog and pg_temp_<appropriate> always get
searched, whether you put them in the search_path or not.

Cheers,

Jeff


From: Christoph Berg <cb(at)df7cb(dot)de>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-05-06 13:46:49
Message-ID: 20140506134649.GD10014@msgid.df7cb.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Re: Jeff Janes 2014-05-05 <CAMkU=1yo97bcGR-z6wg-OJpHKfEcaaaS=X1N7xYGxcUAKV5r9g(at)mail(dot)gmail(dot)com>
> I've personally never had a need to set the search_path to a system schema,
> and I guess I was implicitly modelling this on what is returned by \dn, not
> by \dnS. I wouldn't object much to including them; that would be better
> than not having any completion. I just don't see much point.
>
> And now playing a bit with the system ones, I think it would be more
> confusing to offer them. pg_catalog and pg_temp_<appropriate> always get
> searched, whether you put them in the search_path or not.

Imho the system schemas should be included, because they don't hurt.
If you do tab completion, you'll usually enter a few chars and hit
<tab>, so you won't get confused by pg_catalog and information_schema
just because you won't see them. Also, it makes sense to explicitely
put pg_catalog at the beginning or the end of search_path, so tab
completion should support that.

I would opt to exclude pg_temp_*, though - these don't serve any
purpose SQL-wise and the name changes all the time anyway.

Christoph
--
cb(at)df7cb(dot)de | http://www.df7cb.de/


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-06-22 15:58:04
Message-ID: 20140622155804.GM30721@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-05-05 09:10:17 -0700, Jeff Janes wrote:
> On Sat, May 3, 2014 at 1:11 AM, Andres Freund <andres(at)2ndquadrant(dot)com>wrote:
>
> > On 2014-05-03 00:13:45 -0700, Jeff Janes wrote:
> > > On Friday, May 2, 2014, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
> > 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've personally never had a need to set the search_path to a system schema,
> and I guess I was implicitly modelling this on what is returned by \dn, not
> by \dnS. I wouldn't object much to including them; that would be better
> than not having any completion. I just don't see much point.
>
> And now playing a bit with the system ones, I think it would be more
> confusing to offer them. pg_catalog and pg_temp_<appropriate> always get
> searched, whether you put them in the search_path or not.

I thought about committing this but couldn't get over this bit. If you
type "SELECT * FROM pg_cat<tab>" it'll get autocompleted to
pg_catalog.pg_ and "pg_temp<tab>" will list all the temp schemas
including the numeric and toast ones. So we have precedent for *not*
bothering about excluding any schemas. I don't think we should start
doing so in a piecemal fashion in an individual command's completion.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Ian Barwick <ian(at)2ndquadrant(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-06-23 01:26:01
Message-ID: 53A78229.9020402@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 23/06/14 00:58, Andres Freund wrote:
> On 2014-05-05 09:10:17 -0700, Jeff Janes wrote:
>> On Sat, May 3, 2014 at 1:11 AM, Andres Freund <andres(at)2ndquadrant(dot)com>wrote:
>>
>>> On 2014-05-03 00:13:45 -0700, Jeff Janes wrote:
>>>> On Friday, May 2, 2014, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
>>> 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've personally never had a need to set the search_path to a system schema,
>> and I guess I was implicitly modelling this on what is returned by \dn, not
>> by \dnS. I wouldn't object much to including them; that would be better
>> than not having any completion. I just don't see much point.
>>
>> And now playing a bit with the system ones, I think it would be more
>> confusing to offer them. pg_catalog and pg_temp_<appropriate> always get
>> searched, whether you put them in the search_path or not.
>
> I thought about committing this but couldn't get over this bit. If you
> type "SELECT * FROM pg_cat<tab>" it'll get autocompleted to
> pg_catalog.pg_ and "pg_temp<tab>" will list all the temp schemas
> including the numeric and toast ones. So we have precedent for *not*
> bothering about excluding any schemas. I don't think we should start
> doing so in a piecemal fashion in an individual command's completion.

There is an exception of sorts already for system schemas, in that although
"SELECT * FROM p<tab>" will list the system schemas, it will not list any
tables from them, and won't until "SELECT * FROM pg_<tab>" is entered
(see note in tab-completion.c around line 3722).

Personally I'd be mildly annoyed if every "SET search_path TO p<tab>" resulted
in all the system schemas being displayed when all I want is "public"; how
about having these listed only once "pg_" is entered, i.e.
"SET search_path TO pg_<tab>"?

Regards

Ian Barwick

--
Ian Barwick http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ian Barwick <ian(at)2ndquadrant(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-06-23 03:02:57
Message-ID: 707.1403492577@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Ian Barwick <ian(at)2ndquadrant(dot)com> writes:
> On 23/06/14 00:58, Andres Freund wrote:
>> I thought about committing this but couldn't get over this bit. If you
>> type "SELECT * FROM pg_cat<tab>" it'll get autocompleted to
>> pg_catalog.pg_ and "pg_temp<tab>" will list all the temp schemas
>> including the numeric and toast ones. So we have precedent for *not*
>> bothering about excluding any schemas. I don't think we should start
>> doing so in a piecemal fashion in an individual command's completion.

> There is an exception of sorts already for system schemas, in that although
> "SELECT * FROM p<tab>" will list the system schemas, it will not list any
> tables from them, and won't until "SELECT * FROM pg_<tab>" is entered
> (see note in tab-completion.c around line 3722).

> Personally I'd be mildly annoyed if every "SET search_path TO p<tab>" resulted
> in all the system schemas being displayed when all I want is "public"; how
> about having these listed only once "pg_" is entered, i.e.
> "SET search_path TO pg_<tab>"?

I think there is a pretty strong practical argument for excluding the
pg_temp and pg_toast schemas from completion for search_path, namely
that when does anyone ever need to include those in their search_path
explicitly?

The use-case for including pg_catalog in your path is perhaps a bit
greater, but not by much.

I'm not sure that what we do when auto-completing after FROM is an
entirely valid analogy, because the use-cases are different as a result
of the rules about schemas getting automatically included in your path.

regards, tom lane


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ian Barwick <ian(at)2ndquadrant(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-06-23 11:22:26
Message-ID: 20140623112226.GP16260@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-06-22 20:02:57 -0700, Tom Lane wrote:
> Ian Barwick <ian(at)2ndquadrant(dot)com> writes:
> > On 23/06/14 00:58, Andres Freund wrote:
> >> I thought about committing this but couldn't get over this bit. If you
> >> type "SELECT * FROM pg_cat<tab>" it'll get autocompleted to
> >> pg_catalog.pg_ and "pg_temp<tab>" will list all the temp schemas
> >> including the numeric and toast ones. So we have precedent for *not*
> >> bothering about excluding any schemas. I don't think we should start
> >> doing so in a piecemal fashion in an individual command's completion.
>
> > There is an exception of sorts already for system schemas, in that although
> > "SELECT * FROM p<tab>" will list the system schemas, it will not list any
> > tables from them, and won't until "SELECT * FROM pg_<tab>" is entered
> > (see note in tab-completion.c around line 3722).
>
> > Personally I'd be mildly annoyed if every "SET search_path TO p<tab>" resulted
> > in all the system schemas being displayed when all I want is "public"; how
> > about having these listed only once "pg_" is entered, i.e.
> > "SET search_path TO pg_<tab>"?
>
> I think there is a pretty strong practical argument for excluding the
> pg_temp and pg_toast schemas from completion for search_path, namely
> that when does anyone ever need to include those in their search_path
> explicitly?

Infrequently, yes. I've only done it when trying to break stuff ;)

> The use-case for including pg_catalog in your path is perhaps a bit
> greater, but not by much.

I don't know. It feelds like inappropriate nannyism to me. More
confusing than actually helpful. The schemas are there, so they should
get autocompleted.
But anyway, the common opinion seems to be swinging against my position,
so lets do it that way.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ian Barwick <ian(at)2ndquadrant(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-06-23 13:10:24
Message-ID: 1403529024.76370.YahooMailNeo@web122303.mail.ne1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
> On 2014-06-22 20:02:57 -0700, Tom Lane wrote:
>> Ian Barwick <ian(at)2ndquadrant(dot)com> writes:
>>> On 23/06/14 00:58, Andres Freund wrote:
>>>> I thought about committing this but couldn't get over this bit. If you
>>>> type "SELECT * FROM pg_cat<tab>" it'll get autocompleted to
>>>> pg_catalog.pg_ and "pg_temp<tab>" will list all the temp schemas
>>>> including the numeric and toast ones. So we have precedent for *not*
>>>> bothering about excluding any schemas. I don't think we should start
>>>> doing so in a piecemal fashion in an individual command's completion.
>>
>>> There is an exception of sorts already for system schemas, in that although
>>> "SELECT * FROM p<tab>" will list the system schemas, it will not list any
>>> tables from them, and won't until "SELECT * FROM pg_<tab>" is entered
>>> (see note in tab-completion.c around line 3722).
>>
>>> Personally I'd be mildly annoyed if every "SET search_path TO p<tab>" resulted
>>> in all the system schemas being displayed when all I want is "public"; how
>>> about having these listed only once "pg_" is entered, i.e.
>>> "SET search_path TO pg_<tab>"?
>>
>> I think there is a pretty strong practical argument for excluding the
>> pg_temp and pg_toast schemas from completion for search_path, namely
>> that when does anyone ever need to include those in their search_path
>> explicitly?
>
> Infrequently, yes. I've only done it when trying to break stuff ;)
>
>> The use-case for including pg_catalog in your path is perhaps a bit
>> greater, but not by much.
>
> I don't know. It feelds like inappropriate nannyism to me. More
> confusing than actually helpful. The schemas are there, so they should
> get autocompleted.
> But anyway, the common opinion seems to be swinging against my position,
> so lets do it that way.

I would be for excluding the pg_toast, pg_toast_temp_n, and
pg_temp_n schemas, and including public and pg_catalog.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Kevin Grittner <kgrittn(at)ymail(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ian Barwick <ian(at)2ndquadrant(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-06-23 17:10:34
Message-ID: CA+Tgmoa7gLfwNakgKDq0GT8WNPmHXpY-ccx6-2TVX27pxOkEdg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jun 23, 2014 at 9:10 AM, Kevin Grittner <kgrittn(at)ymail(dot)com> wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
>> On 2014-06-22 20:02:57 -0700, Tom Lane wrote:
>>> Ian Barwick <ian(at)2ndquadrant(dot)com> writes:
>>>> On 23/06/14 00:58, Andres Freund wrote:
>>>>> I thought about committing this but couldn't get over this bit. If you
>>>>> type "SELECT * FROM pg_cat<tab>" it'll get autocompleted to
>>>>> pg_catalog.pg_ and "pg_temp<tab>" will list all the temp schemas
>>>>> including the numeric and toast ones. So we have precedent for *not*
>>>>> bothering about excluding any schemas. I don't think we should start
>>>>> doing so in a piecemal fashion in an individual command's completion.
>>>
>>>> There is an exception of sorts already for system schemas, in that although
>>>> "SELECT * FROM p<tab>" will list the system schemas, it will not list any
>>>> tables from them, and won't until "SELECT * FROM pg_<tab>" is entered
>>>> (see note in tab-completion.c around line 3722).
>>>
>>>> Personally I'd be mildly annoyed if every "SET search_path TO p<tab>" resulted
>>>> in all the system schemas being displayed when all I want is "public"; how
>>>> about having these listed only once "pg_" is entered, i.e.
>>>> "SET search_path TO pg_<tab>"?
>>>
>>> I think there is a pretty strong practical argument for excluding the
>>> pg_temp and pg_toast schemas from completion for search_path, namely
>>> that when does anyone ever need to include those in their search_path
>>> explicitly?
>>
>> Infrequently, yes. I've only done it when trying to break stuff ;)
>>
>>> The use-case for including pg_catalog in your path is perhaps a bit
>>> greater, but not by much.
>>
>> I don't know. It feelds like inappropriate nannyism to me. More
>> confusing than actually helpful. The schemas are there, so they should
>> get autocompleted.
>> But anyway, the common opinion seems to be swinging against my position,
>> so lets do it that way.
>
> I would be for excluding the pg_toast, pg_toast_temp_n, and
> pg_temp_n schemas, and including public and pg_catalog.

+1.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Kevin Grittner <kgrittn(at)ymail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ian Barwick <ian(at)2ndquadrant(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-06-23 22:53:01
Message-ID: 20140623225301.GC9755@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-06-23 13:10:34 -0400, Robert Haas wrote:
> On Mon, Jun 23, 2014 at 9:10 AM, Kevin Grittner <kgrittn(at)ymail(dot)com> wrote:
> > I would be for excluding the pg_toast, pg_toast_temp_n, and
> > pg_temp_n schemas, and including public and pg_catalog.
>
> +1.

Jeff, are you willing to update the patch that way? Seems we have
something several people can live with ;)

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Kevin Grittner <kgrittn(at)ymail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ian Barwick <ian(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: tab completion for setting search_path
Date: 2014-06-24 01:25:48
Message-ID: CAMkU=1xjDw2QokXv094m-iXyRhrrF4DeJrC3WdXxY4tNWSQ7vg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jun 23, 2014 at 3:53 PM, Andres Freund <andres(at)2ndquadrant(dot)com
<javascript:;>> wrote:
> On 2014-06-23 13:10:34 -0400, Robert Haas wrote:
>> On Mon, Jun 23, 2014 at 9:10 AM, Kevin Grittner <kgrittn(at)ymail(dot)com
<javascript:;>> wrote:
>> > I would be for excluding the pg_toast, pg_toast_temp_n, and
>> > pg_temp_n schemas, and including public and pg_catalog.
>>
>> +1.
>
> Jeff, are you willing to update the patch that way? Seems we have
> something several people can live with ;)

I was hoping not to add a third set of filters (separate from the ones
already implicit in either \dn or \dnS), but that's OK; as long as I get a
doghouse I won't worry much about the color.

I've included information_schema as well, in analogy to the inclusion of
pg_catalog.

Cheers and Thanks,

Jeff


From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Kevin Grittner <kgrittn(at)ymail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ian Barwick <ian(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-06-24 02:57:21
Message-ID: CAMkU=1zhXD8-fC8SddALG1ofk3m0aHXtC-B5MEYmqr=0JrO4vQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jun 23, 2014 at 6:25 PM, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
> On Mon, Jun 23, 2014 at 3:53 PM, Andres Freund <andres(at)2ndquadrant(dot)com>
> wrote:
>> On 2014-06-23 13:10:34 -0400, Robert Haas wrote:
>>> On Mon, Jun 23, 2014 at 9:10 AM, Kevin Grittner <kgrittn(at)ymail(dot)com>
>>> wrote:
>>> > I would be for excluding the pg_toast, pg_toast_temp_n, and
>>> > pg_temp_n schemas, and including public and pg_catalog.
>>>
>>> +1.
>>
>> Jeff, are you willing to update the patch that way? Seems we have
>> something several people can live with ;)
>
> I was hoping not to add a third set of filters (separate from the ones
> already implicit in either \dn or \dnS), but that's OK; as long as I get a
> doghouse I won't worry much about the color.
>
> I've included information_schema as well, in analogy to the inclusion of
> pg_catalog.
>
> Cheers and Thanks,

GAAH. I specifically verified before hitting send that the attachment
was listed. Nevertheless, it isn't there.

Note to self: stop using gmail offline to compose mail with
attachments to send later, it prevaricates. Attempted again with
regular gmail this time.

Cheers,

Jeff

Attachment Content-Type Size
search_path_complete_v2.patch text/x-patch 637 bytes

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Kevin Grittner <kgrittn(at)ymail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ian Barwick <ian(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-07-07 11:51:50
Message-ID: CAHGQGwEphPWToZ18xnGH53YH6E3JKs_C3jvrQPMMVQb8ccAGAA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Jun 24, 2014 at 11:57 AM, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
> On Mon, Jun 23, 2014 at 6:25 PM, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
>> On Mon, Jun 23, 2014 at 3:53 PM, Andres Freund <andres(at)2ndquadrant(dot)com>
>> wrote:
>>> On 2014-06-23 13:10:34 -0400, Robert Haas wrote:
>>>> On Mon, Jun 23, 2014 at 9:10 AM, Kevin Grittner <kgrittn(at)ymail(dot)com>
>>>> wrote:
>>>> > I would be for excluding the pg_toast, pg_toast_temp_n, and
>>>> > pg_temp_n schemas, and including public and pg_catalog.
>>>>
>>>> +1.
>>>
>>> Jeff, are you willing to update the patch that way? Seems we have
>>> something several people can live with ;)
>>
>> I was hoping not to add a third set of filters (separate from the ones
>> already implicit in either \dn or \dnS), but that's OK; as long as I get a
>> doghouse I won't worry much about the color.
>>
>> I've included information_schema as well, in analogy to the inclusion of
>> pg_catalog.

Is there any blocker on this patch? The patch looks good to me.

Regards,

--
Fujii Masao


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Kevin Grittner <kgrittn(at)ymail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ian Barwick <ian(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-07-08 01:29:44
Message-ID: CAHGQGwHjbTsQgwPM1yRbVCbw=u91W+sHNSj86GM-5YPQ=fH2SQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jul 7, 2014 at 8:51 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> On Tue, Jun 24, 2014 at 11:57 AM, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
>> On Mon, Jun 23, 2014 at 6:25 PM, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
>>> On Mon, Jun 23, 2014 at 3:53 PM, Andres Freund <andres(at)2ndquadrant(dot)com>
>>> wrote:
>>>> On 2014-06-23 13:10:34 -0400, Robert Haas wrote:
>>>>> On Mon, Jun 23, 2014 at 9:10 AM, Kevin Grittner <kgrittn(at)ymail(dot)com>
>>>>> wrote:
>>>>> > I would be for excluding the pg_toast, pg_toast_temp_n, and
>>>>> > pg_temp_n schemas, and including public and pg_catalog.
>>>>>
>>>>> +1.
>>>>
>>>> Jeff, are you willing to update the patch that way? Seems we have
>>>> something several people can live with ;)
>>>
>>> I was hoping not to add a third set of filters (separate from the ones
>>> already implicit in either \dn or \dnS), but that's OK; as long as I get a
>>> doghouse I won't worry much about the color.
>>>
>>> I've included information_schema as well, in analogy to the inclusion of
>>> pg_catalog.
>
> Is there any blocker on this patch? The patch looks good to me.

The patch makes the tab-completion on search_path display the existing
schemas, additionally what about displaying "$user", too? I think that
some users would want to include "$user" variable in search_path.

Regards,

--
Fujii Masao


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Kevin Grittner <kgrittn(at)ymail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ian Barwick <ian(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-07-12 13:51:28
Message-ID: 20140712135128.GD3494@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

On 2014-06-23 19:57:21 -0700, Jeff Janes wrote:
> diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
> new file mode 100644
> index be5c3c5..dcd1b7d
> *** a/src/bin/psql/tab-complete.c
> --- b/src/bin/psql/tab-complete.c
> *************** psql_completion(const char *text, int st
> *** 3342,3347 ****
> --- 3342,3354 ----
>
> 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[] =

I don't particularly like the explicit comparisons using LIKE, but we
can't really do better as we only have pg_my_temp_schema(),
pg_is_other_temp_schema() right now. I was tempted to just add
pg_is_temp_schema() and pg_is_toast_schema(), but we couldn't rely on
them for now anyway due to cross version compatibility.

We really should add those functions independently of this though.

I'm also not really happy with the fact that we only complete a single
search_path item. But it's not easy to do better and when looking around
other places (e.g. DROP TABLE) don't support it either.

I've thought about adding "$user" to the set of completed things as
Fujii wondered about it, but it turns out completions containing $ don't
work really great because $ is part of WORD_BREAKS.
E.g. check out what happens if you do
CREATE TABLE "foo$01"();
CREATE TABLE "foo$02"();
DROP TABLE "foo$<tab>
which means that a single schema that requires quoting will break
completion of "$user".

Pushed.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Christoph Berg <cb(at)df7cb(dot)de>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tab completion for setting search_path
Date: 2014-07-14 19:20:18
Message-ID: 20140714192018.GE14198@msg.df7cb.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Re: Andres Freund 2014-07-12 <20140712135128(dot)GD3494(at)awork2(dot)anarazel(dot)de>
> I'm also not really happy with the fact that we only complete a single
> search_path item. But it's not easy to do better and when looking around
> other places (e.g. DROP TABLE) don't support it either.

The difference is that the other places don't really need it, i.e. you
can just issue two DROP TABLE. (And I wasn't even aware that DROP
TABLE a, b; exists specifically).

That said, it's great to have the feature, though I'd say making
search_path list-aware should be much higher on the todo list than a
generic solution for other cases.

> I've thought about adding "$user" to the set of completed things as

If we only support one item atm, $user isn't very relevant anyway.

> Fujii wondered about it, but it turns out completions containing $ don't
> work really great because $ is part of WORD_BREAKS.
> E.g. check out what happens if you do
> CREATE TABLE "foo$01"();
> CREATE TABLE "foo$02"();
> DROP TABLE "foo$<tab>
> which means that a single schema that requires quoting will break
> completion of "$user".

Schemas requiring quoting should be rare, so that wouldn't be a big
problem. (Or at least it could solve the problem for most users.)

Christoph
--
cb(at)df7cb(dot)de | http://www.df7cb.de/