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

Started by Dagfinn Ilmari Mannsåkerover 9 years ago6 messageshackers
Jump to latest

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

Attachments:

0001-Add-psql-tab-completion-for-ALTER-TYPE-RENAME-VALUE.patchtext/x-diffDownload+55-3
In reply to: Dagfinn Ilmari Mannsåker (#1)
Re: [PATCH] Tab completion for ALTER TYPE … RENAME VALUE …

ilmari@ilmari.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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Arthur Zakirov
a.zakirov@postgrespro.ru
In reply to: Dagfinn Ilmari Mannsåker (#2)
Re: [HACKERS] Re: [PATCH] Tab completion for ALTER TYPE … RENAME VALUE …

Hello,

2016-09-12 16:16 GMT+03:00 Dagfinn Ilmari Mannsåker <ilmari@ilmari.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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

In reply to: Arthur Zakirov (#3)
Re: Re: [PATCH] Tab completion for ALTER TYPE … RENAME VALUE …

Artur Zakirov <a.zakirov@postgrespro.ru> writes:

Hello,

Hi Artur,

2016-09-12 16:16 GMT+03:00 Dagfinn Ilmari Mannsåker <ilmari@ilmari.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

Attachments:

0001-Add-psql-tab-completion-for-ALTER-TYPE-RENAME-VALUE-v2.patchtext/x-diffDownload+54-5
#5Robert Haas
robertmhaas@gmail.com
In reply to: Dagfinn Ilmari Mannsåker (#4)
Re: [HACKERS] Re: [PATCH] Tab completion for ALTER TYPE … RENAME VALUE …

On Tue, Nov 8, 2016 at 8:53 AM, Dagfinn Ilmari Mannsåker
<ilmari@ilmari.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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

In reply to: Robert Haas (#5)
Re: Re: [PATCH] Tab completion for ALTER TYPE … RENAME VALUE …

Robert Haas <robertmhaas@gmail.com> writes:

On Tue, Nov 8, 2016 at 8:53 AM, Dagfinn Ilmari Mannsåker
<ilmari@ilmari.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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers