Re: COPY (... tab completion

Lists: Postg토토 결과SQL
From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: COPY (... tab completion
Date: 2015-12-29 16:22:42
Message-ID: 5682B352.2000502@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

Here is a patch which adds tab completion for COPY with a query.
Currently there is only completion for COPY with a relation.

Andreas

Attachment Content-Type Size
copy-tab-compleition.patch text/x-diff 1.2 KB

From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY (... tab completion
Date: 2016-01-06 09:20:13
Message-ID: 568CDC4D.7010202@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

I have an updated patch which uses Matches() rather than TailMatches().

Andreas

Attachment Content-Type Size
copy-tab-compleition-v2.patch text/x-diff 1.3 KB

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Andreas Karlsson <andreas(at)proxel(dot)se>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY (... tab completion
Date: 2016-01-11 01:01:33
Message-ID: 5692FEED.2080802@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I think this would be a useful addition. A couple of problems:

This change in the comment doesn't make sense to me and doesn't seem to
match the code:

- /* If we have COPY [BINARY] <sth>, complete it with "TO" or "FROM" */
+ /* If we have COPY|BINARY <sth>, complete it with "TO" or "FROM" */

The list of commands to allow as the "query" inside the parentheses is
documented to be: SELECT, VALUES, INSERT, UPDATE or DELETE; and actually
TABLE should also work. Your list doesn't include all of those. So
please adjust that.


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Andreas Karlsson <andreas(at)proxel(dot)se>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY (... tab completion
Date: 2016-01-11 01:19:13
Message-ID: 56930311.8010007@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 1/10/16 8:01 PM, Peter Eisentraut wrote:
> The list of commands to allow as the "query" inside the parentheses is
> documented to be: SELECT, VALUES, INSERT, UPDATE or DELETE; and actually
> TABLE should also work. Your list doesn't include all of those.

To be fair, this is actually a recent new feature.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Andreas Karlsson <andreas(at)proxel(dot)se>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY (... tab completion
Date: 2016-01-11 01:23:06
Message-ID: 24816.1452475386@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: Postg토토 결과SQL

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> I think this would be a useful addition. A couple of problems:
> This change in the comment doesn't make sense to me and doesn't seem to
> match the code:

> - /* If we have COPY [BINARY] <sth>, complete it with "TO" or "FROM" */
> + /* If we have COPY|BINARY <sth>, complete it with "TO" or "FROM" */

Offhand, that looks like an accidental reversion of a change made in
9b181b0363deb65b15a9feaf3eb74f86707498a9.

regards, tom lane


From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY (... tab completion
Date: 2016-01-19 00:57:08
Message-ID: 569D89E4.6090008@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 01/11/2016 02:01 AM, Peter Eisentraut wrote:
> I think this would be a useful addition. A couple of problems:

Thanks for the review. A new version is attached.

> This change in the comment doesn't make sense to me and doesn't seem to
> match the code:
>
> - /* If we have COPY [BINARY] <sth>, complete it with "TO" or "FROM" */
> + /* If we have COPY|BINARY <sth>, complete it with "TO" or "FROM" */

Fixed. As Tom correctly guessed this was the result of a mistake when
rebasing.

> The list of commands to allow as the "query" inside the parentheses is
> documented to be: SELECT, VALUES, INSERT, UPDATE or DELETE; and actually
> TABLE should also work. Your list doesn't include all of those. So
> please adjust that.

Fixed. And TABLE works too.

Andreas

Attachment Content-Type Size
copy-tab-compleition-v2.patch text/x-diff 1.3 KB

From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY (... tab completion
Date: 2016-01-19 01:12:00
Message-ID: 569D8D60.8080508@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 01/19/2016 01:57 AM, Andreas Karlsson wrote:
> Thanks for the review. A new version is attached.

Whops, attached the wrong file.

Andreas

Attachment Content-Type Size
copy-tab-compleition-v3.patch text/x-diff 1.2 KB

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Andreas Karlsson <andreas(at)proxel(dot)se>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY (... tab completion
Date: 2016-01-19 06:55:11
Message-ID: CAB7nPqSDfnsfYo1CwUAkmpOs3-rpoUCx9SWQsRXfLGhvwZr9YQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Jan 19, 2016 at 10:12 AM, Andreas Karlsson <andreas(at)proxel(dot)se> wrote:
> On 01/19/2016 01:57 AM, Andreas Karlsson wrote:
>>
>> Thanks for the review. A new version is attached.
>
>
> Whops, attached the wrong file.

+ /* If we have COPY BINARY, compelete with list of tables */
s/compelete/complete

+ else if (TailMatches2("COPY|\\copy", "("))
+ COMPLETE_WITH_LIST7("SELECT", "TABLE", "VALUES", "INSERT",
"UPDATE", "DELETE", "WITH");
This one should be Matches, no?
--
Michael


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

On 01/19/2016 07:55 AM, Michael Paquier wrote:
> + /* If we have COPY BINARY, compelete with list of tables */
> s/compelete/complete

Fixed.

> + else if (TailMatches2("COPY|\\copy", "("))
> + COMPLETE_WITH_LIST7("SELECT", "TABLE", "VALUES", "INSERT",
> "UPDATE", "DELETE", "WITH");
> This one should be Matches, no?

Yep, fixed.

Andreas

Attachment Content-Type Size
copy-tab-compleition-v4.patch text/x-diff 1.2 KB

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Andreas Karlsson <andreas(at)proxel(dot)se>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY (... tab completion
Date: 2016-01-19 12:00:08
Message-ID: CAB7nPqRQvKxbrr1qnwxdz6FOkx_5ffQ3dySxffF_Af4o70J4Mw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Jan 19, 2016 at 8:00 PM, Andreas Karlsson <andreas(at)proxel(dot)se> wrote:
> On 01/19/2016 07:55 AM, Michael Paquier wrote:
>>
>> + /* If we have COPY BINARY, compelete with list of tables */
>> s/compelete/complete
>
> Fixed.
>
>> + else if (TailMatches2("COPY|\\copy", "("))
>> + COMPLETE_WITH_LIST7("SELECT", "TABLE", "VALUES", "INSERT",
>> "UPDATE", "DELETE", "WITH");
>> This one should be Matches, no?
>
> Yep, fixed.

Marked as ready for committer.

This patch makes me wonder: are we going to nuke the grammar "COPY [
BINARY ] table_name" at some point? This was used up to 7.3.
--
Michael


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Andreas Karlsson <andreas(at)proxel(dot)se>, Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY (... tab completion
Date: 2016-01-19 14:38:42
Message-ID: 20429.1453214322@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Michael Paquier <michael(dot)paquier(at)gmail(dot)com> writes:
> This patch makes me wonder: are we going to nuke the grammar "COPY [
> BINARY ] table_name" at some point? This was used up to 7.3.

I'm not particularly in a hurry to remove obsolete syntaxes, as long as
they're not blocking forward progress in some way. However, it seems
to me that it would certainly make sense to remove tab-completion support
for long-deprecated syntax.

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: COPY (... tab completion
Date: 2016-01-21 02:32:25
Message-ID: 56A04339.1040908@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 1/19/16 6:00 AM, Andreas Karlsson wrote:
> On 01/19/2016 07:55 AM, Michael Paquier wrote:
>> + /* If we have COPY BINARY, compelete with list of tables */
>> s/compelete/complete
>
> Fixed.
>
>> + else if (TailMatches2("COPY|\\copy", "("))
>> + COMPLETE_WITH_LIST7("SELECT", "TABLE", "VALUES", "INSERT",
>> "UPDATE", "DELETE", "WITH");
>> This one should be Matches, no?
>
> Yep, fixed.

Committed v4, thanks.