[PATCH] Tab completion for ALTER TYPE … RENAME VALUE …

Lists: pgsql-hackers
From: ilmari(at)ilmari(dot)org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=)
To: pgsql-hackers(at)postgresql(dot)org
Subject: [PATCH] Tab completion for ALTER TYPE … RENAME VALUE …
Date: 2016-09-12 11:28:18
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi hackers,

Here's a patch to add psql tab completion for the recently-added ALTER
TYPE … RENAME VALUE feature (thanks to Tom for fixing it up and
committing it).

It's modelled on the ALTER TYPE … RENAME ATTRIBUTE completion, but
tweaked to return string literals instead of identifiers.

- ilmari

Attachment Content-Type Size
0001-Add-psql-tab-completion-for-ALTER-TYPE-RENAME-VALUE.patch text/x-diff 4.2 KB

From: ilmari(at)ilmari(dot)org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=)
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Tab completion for ALTER TYPE … RENAME VALUE …
Date: 2016-09-12 13:16:52
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

ilmari(at)ilmari(dot)org (Dagfinn Ilmari Mannsåker) writes:

> Hi hackers,
>
> Here's a patch to add psql tab completion for the recently-added ALTER
> TYPE … RENAME VALUE feature (thanks to Tom for fixing it up and
> committing it).

I've added it to the 2016-11 commit fest:
https://commitfest.postgresql.org/11/795/

- ilmari

--
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
the consequences of." -- Skud's Meta-Law


From: Artur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
Subject: Re: [HACKERS] Re: [PATCH] Tab completion for ALTER TYPE … RENAME VALUE …
Date: 2016-11-06 17:48:18
Message-ID: CAKNkYnw8wVX5htytcQ8LGOuYY4kBbq7F4L5qsDOMkH6jm6-SsQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hello,

2016-09-12 16:16 GMT+03:00 Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>:
>
> I've added it to the 2016-11 commit fest:
> https://commitfest.postgresql.org/11/795/
>
> - ilmari

I've tested your patch.

Patch was applied to the master. It seems there is no need to rebase
it. PostgreSQL was compiled without errors with the patch.

I've tested the patch with type:

CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green',
'blue', 'purple');

And the following completions work as expected:

=> ALTER TYPE rainbow RENAME <tab>
ATTRIBUTE TO VALUE

=> ALTER TYPE rainbow RENAME VALUE <tab>
'blue' 'green' 'orange' 'purple' 'red' 'yellow'

It seems that the patch can be commited without any fixes. So I marked
it as "Ready for Committer".

--
Sincerely,
Artur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company


From: ilmari(at)ilmari(dot)org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=)
To: Artur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re: [PATCH] Tab completion for ALTER TYPE … RENAME VALUE …
Date: 2016-11-08 13:53:26
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Artur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru> writes:

> Hello,

Hi Artur,

> 2016-09-12 16:16 GMT+03:00 Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>:
>>
>> I've added it to the 2016-11 commit fest:
>> https://commitfest.postgresql.org/11/795/
>>
>> - ilmari
>
> I've tested your patch.
[...]
> It seems that the patch can be commited without any fixes. So I marked
> it as "Ready for Committer".

Thank you very much. I just looked at the patch again and realised the
completion of "TO" after RENAME VALUE <name> can be merged with the one
for RENAME ATTRIBUTE <name>. Attached is an updated and patch, which
only differs from the previous one as follows:

$ interdiff 0001-Add-psql-tab-completion-for-ALTER-TYPE-RENAME-VALUE{,-v2}.patch
diff -u b/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1918,11 +1918,8 @@ psql_completion(const char *text, int start, int end)
/* ALTER TYPE <foo> RENAME */
else if (Matches4("ALTER", "TYPE", MatchAny, "RENAME"))
COMPLETE_WITH_LIST3("ATTRIBUTE", "TO", "VALUE");
- /* ALTER TYPE xxx RENAME ATTRIBUTE yyy */
- else if (Matches6("ALTER", "TYPE", MatchAny, "RENAME", "ATTRIBUTE", MatchAny))
- COMPLETE_WITH_CONST("TO");
- /* ALTER TYPE xxx RENAME VALUE yyy */
- else if (Matches6("ALTER", "TYPE", MatchAny, "RENAME", "VALUE", MatchAny))
+ /* ALTER TYPE xxx RENAME (ATTRIBUTE|VALUE) yyy */
+ else if (Matches6("ALTER", "TYPE", MatchAny, "RENAME", "ATTRIBUTE|VALUE", MatchAny))
COMPLETE_WITH_CONST("TO");
/*
* If we have ALTER TYPE <sth> ALTER/DROP/RENAME ATTRIBUTE, provide list

Attachment Content-Type Size
0001-Add-psql-tab-completion-for-ALTER-TYPE-RENAME-VALUE-v2.patch text/x-diff 4.2 KB

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
Cc: Artur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Re: [PATCH] Tab completion for ALTER TYPE … RENAME VALUE …
Date: 2016-11-08 21:31:51
Message-ID: CA+Tgmoaffv1gc29braKrNu9BQhQ3aSSSMjaOVw4by3Ov8AUtjg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Nov 8, 2016 at 8:53 AM, Dagfinn Ilmari Mannsåker
<ilmari(at)ilmari(dot)org> wrote:
> Thank you very much. I just looked at the patch again and realised the
> completion of "TO" after RENAME VALUE <name> can be merged with the one
> for RENAME ATTRIBUTE <name>. Attached is an updated and patch

Committed.

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


From: ilmari(at)ilmari(dot)org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=)
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Artur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re: [PATCH] Tab completion for ALTER TYPE … RENAME VALUE …
Date: 2016-11-08 21:56:43
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:

> On Tue, Nov 8, 2016 at 8:53 AM, Dagfinn Ilmari Mannsåker
> <ilmari(at)ilmari(dot)org> wrote:
>> Thank you very much. I just looked at the patch again and realised the
>> completion of "TO" after RENAME VALUE <name> can be merged with the one
>> for RENAME ATTRIBUTE <name>. Attached is an updated and patch
>
> Committed.

Thanks!

--
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
the consequences of." -- Skud's Meta-Law