Re: Improved tab completion for FDW DDL

Lists: pgsql-hackers
From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Improved tab completion for FDW DDL
Date: 2015-12-30 12:21:06
Message-ID: 5683CC32.1020006@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

Here is a patch which adds the below missing tab completions for the FDW
DDL commands. I noticed these were missing while playing around with
FDWs a while ago.

"ALTER SERVER <name>" with "RENAME TO"
"CREATE SERVER <name> FOREIGN DATA WRAPPER" with fdw name
"CREATE|ALTER USER MAPPING FOR <name> SERVER <name>" with "OPTIONS ("

Another completion which is currently missing but I am not sure if we
should add or not is completing "ALTER|CREATE|DROP USER" with "MAPPING
FOR", but since it might interfere with completing to username for
"ALTER|DROP USER" I am not sure we want it. What do you think?

Andreas

Attachment Content-Type Size
fdw-ddl-tab-completion.patch text/x-diff 1.7 KB

From: David Fetter <david(at)fetter(dot)org>
To: Andreas Karlsson <andreas(at)proxel(dot)se>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improved tab completion for FDW DDL
Date: 2016-01-04 00:09:26
Message-ID: 20160104000926.GG30007@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Dec 30, 2015 at 01:21:06PM +0100, Andreas Karlsson wrote:
> Hi,
>
> Here is a patch which adds the below missing tab completions for the FDW DDL
> commands. I noticed these were missing while playing around with FDWs a
> while ago.
>
> "ALTER SERVER <name>" with "RENAME TO"
> "CREATE SERVER <name> FOREIGN DATA WRAPPER" with fdw name
> "CREATE|ALTER USER MAPPING FOR <name> SERVER <name>" with "OPTIONS ("
>
> Another completion which is currently missing but I am not sure if we should
> add or not is completing "ALTER|CREATE|DROP USER" with "MAPPING FOR", but
> since it might interfere with completing to username for "ALTER|DROP USER" I
> am not sure we want it. What do you think?

Is there a way to require some reasonable chunk--say, one that's
disambiguated from the name any known ROLE with LOGIN--of MAPPING
before completing with MAPPING FOR? I confess to not knowing how the
new system works in enough detail to know that off the top of my head.

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Andreas Karlsson <andreas(at)proxel(dot)se>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improved tab completion for FDW DDL
Date: 2016-01-04 06:26:56
Message-ID: CAB7nPqQ25fFeXgK3DoC8OuosEFjr1m4xVbsdDB8wFCTwA=vU_A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Dec 30, 2015 at 9:21 PM, Andreas Karlsson <andreas(at)proxel(dot)se> wrote:
> Hi,
>
> Here is a patch which adds the below missing tab completions for the FDW DDL
> commands. I noticed these were missing while playing around with FDWs a
> while ago.
>
> "ALTER SERVER <name>" with "RENAME TO"
> "CREATE SERVER <name> FOREIGN DATA WRAPPER" with fdw name
> "CREATE|ALTER USER MAPPING FOR <name> SERVER <name>" with "OPTIONS ("
>
> Another completion which is currently missing but I am not sure if we should
> add or not is completing "ALTER|CREATE|DROP USER" with "MAPPING FOR", but
> since it might interfere with completing to username for "ALTER|DROP USER" I
> am not sure we want it. What do you think?

You may want to use Matches() instead of TailMatches() for performance reasons.
--
Michael


From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improved tab completion for FDW DDL
Date: 2016-01-04 16:36:02
Message-ID: 568A9F72.60206@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 01/04/2016 07:26 AM, Michael Paquier wrote:
> You may want to use Matches() instead of TailMatches() for performance reasons.

Probably, but if so should we not also change the surrounding rules to
also use Matches()? I imitated the surrounding code to keep code
consistency and avoid errors.

I thought I saw some patch from you changing many of the rules from
TailMatches() to Matches(). Perhaps I should just update my patch after
your patch has been applied.

Andreas


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andreas Karlsson <andreas(at)proxel(dot)se>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improved tab completion for FDW DDL
Date: 2016-01-04 16:42:36
Message-ID: 18167.1451925756@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andreas Karlsson <andreas(at)proxel(dot)se> writes:
> I thought I saw some patch from you changing many of the rules from
> TailMatches() to Matches(). Perhaps I should just update my patch after
> your patch has been applied.

Yes, I think it's important to get that set of patches from Michael
into the tree ASAP so that they can be precedent for the other tab
completion patches that are floating around. I am under the gun for
9.5.0 release today but will review and hopefully push Michael's
changes soon.

regards, tom lane


From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improved tab completion for FDW DDL
Date: 2016-01-06 09:18:20
Message-ID: 568CDBDC.802@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 01/04/2016 07:26 AM, Michael Paquier wrote:
> You may want to use Matches() instead of TailMatches() for performance reasons.

Here is an updated version which uses Matches().

Andreas

Attachment Content-Type Size
fdw-ddl-tab-completion-v2.patch text/x-diff 1.7 KB

From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: David Fetter <david(at)fetter(dot)org>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improved tab completion for FDW DDL
Date: 2016-01-07 13:37:02
Message-ID: 568E69FE.6080700@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 01/04/2016 01:09 AM, David Fetter wrote:
> On Wed, Dec 30, 2015 at 01:21:06PM +0100, Andreas Karlsson wrote:
>> Another completion which is currently missing but I am not sure if we should
>> add or not is completing "ALTER|CREATE|DROP USER" with "MAPPING FOR", but
>> since it might interfere with completing to username for "ALTER|DROP USER" I
>> am not sure we want it. What do you think?
>
> Is there a way to require some reasonable chunk--say, one that's
> disambiguated from the name any known ROLE with LOGIN--of MAPPING
> before completing with MAPPING FOR? I confess to not knowing how the
> new system works in enough detail to know that off the top of my head.

No, and while it would not be too hard to build it would not be worth
doing just for this use case.

Andreas


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andreas Karlsson <andreas(at)proxel(dot)se>
Cc: David Fetter <david(at)fetter(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improved tab completion for FDW DDL
Date: 2016-01-07 14:33:25
Message-ID: 11619.1452177205@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andreas Karlsson <andreas(at)proxel(dot)se> writes:
> On 01/04/2016 01:09 AM, David Fetter wrote:
>> On Wed, Dec 30, 2015 at 01:21:06PM +0100, Andreas Karlsson wrote:
>>> Another completion which is currently missing but I am not sure if we should
>>> add or not is completing "ALTER|CREATE|DROP USER" with "MAPPING FOR", but
>>> since it might interfere with completing to username for "ALTER|DROP USER" I
>>> am not sure we want it. What do you think?

>> Is there a way to require some reasonable chunk--say, one that's
>> disambiguated from the name any known ROLE with LOGIN--of MAPPING
>> before completing with MAPPING FOR? I confess to not knowing how the
>> new system works in enough detail to know that off the top of my head.

> No, and while it would not be too hard to build it would not be worth
> doing just for this use case.

The way we've solved other similar cases would translate like this:
instead of the "query for user names" just returning user names, add
on "UNION 'MAPPING FOR'". So if you do

# alter user <TAB>

where you're now offered

alice joe postgres

you'd instead get

alice joe postgres MAPPING FOR

Dunno if it's worth the trouble though.

regards, tom lane


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Andreas Karlsson <andreas(at)proxel(dot)se>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improved tab completion for FDW DDL
Date: 2016-01-11 01:39:08
Message-ID: 569307BC.7040103@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

The second part is not necessary, because there is already code that
completes FDW names after "FOREIGN DATA WRAPPER". So this already works.

The other two parts are valid improvements, but they should be done
consistently across commands. So please

- Also complete RENAME TO in ALTER FOREIGN DATA WRAPPER.

- Also complete OPTIONS in FOREIGN DATA WRAPPER and SERVER commands.


From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improved tab completion for FDW DDL
Date: 2016-01-19 01:36:32
Message-ID: 569D9320.3080203@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 01/11/2016 02:39 AM, Peter Eisentraut wrote:
> The second part is not necessary, because there is already code that
> completes FDW names after "FOREIGN DATA WRAPPER". So this already works.

Good spot, thanks. I have no idea why I did not think it worked. Maybe
it just did not work in 9.2 and I failed when trying to reproduce it on
master.

> - Also complete RENAME TO in ALTER FOREIGN DATA WRAPPER.

Done.

> - Also complete OPTIONS in FOREIGN DATA WRAPPER and SERVER commands.

Done.

Andreas

Attachment Content-Type Size
fdw-ddl-tab-completion-v3.patch text/x-diff 2.5 KB

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Andreas Karlsson <andreas(at)proxel(dot)se>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improved tab completion for FDW DDL
Date: 2016-01-23 12:03:30
Message-ID: 56A36C12.4000506@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 1/18/16 8:36 PM, Andreas Karlsson wrote:
> On 01/11/2016 02:39 AM, Peter Eisentraut wrote:
>> The second part is not necessary, because there is already code that
>> completes FDW names after "FOREIGN DATA WRAPPER". So this already works.
>
> Good spot, thanks. I have no idea why I did not think it worked. Maybe
> it just did not work in 9.2 and I failed when trying to reproduce it on
> master.
>
>> - Also complete RENAME TO in ALTER FOREIGN DATA WRAPPER.
>
> Done.
>
>> - Also complete OPTIONS in FOREIGN DATA WRAPPER and SERVER commands.
>
> Done.

committed


From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improved tab completion for FDW DDL
Date: 2016-01-25 15:00:22
Message-ID: 56A63886.6000003@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 01/23/2016 01:03 PM, Peter Eisentraut wrote:
> committed

Thanks!

Andreas