pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed[PATCH] Improve tab completion for ALTER TABLE on identity columns
6+ messages / 3 participants
[nested] [flat]
* [PATCH] Improve tab completion for ALTER TABLE on identity columns
@ 2022-10-12 14:18 Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
0 siblings, 2 replies; 6+ messages in thread
From: Dagfinn Ilmari Mannsåker @ 2022-10-12 14:18 UTC (permalink / raw)
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Hi Hackers,
I noticed that psql has no tab completion around identity columns in
ALTER TABLE, so here's some patches for that.
In passing, I also added completion for ALTER SEQUECNE … START, which was
missing for some reason.
- ilmari
Attachments:
[text/x-diff] 0001-psql-Add-tab-completion-for-ALTER-SEQUENCE-START.patch (1.1K, ../../87mta1jfax.fsf@wibble.ilmari.org/2-0001-psql-Add-tab-completion-for-ALTER-SEQUENCE-START.patch)
download | inline diff:
From 4dad38d17e82b2efafe3666a0a92aa248cfc5e60 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
Date: Wed, 12 Oct 2022 14:17:12 +0100
Subject: [PATCH 1/4] =?UTF-8?q?psql:=20Add=20tab=20completion=20for=20ALTE?=
=?UTF-8?q?R=20SEQUENCE=20=E2=80=A6=20START=20=E2=80=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/bin/psql/tab-complete.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 584d9d5ae6..24a5f1f62b 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -2104,7 +2104,7 @@ psql_completion(const char *text, int start, int end)
/* ALTER SEQUENCE <name> */
else if (Matches("ALTER", "SEQUENCE", MatchAny))
COMPLETE_WITH("AS", "INCREMENT", "MINVALUE", "MAXVALUE", "RESTART",
- "NO", "CACHE", "CYCLE", "SET", "OWNED BY",
+ "START", "NO", "CACHE", "CYCLE", "SET", "OWNED BY",
"OWNER TO", "RENAME TO");
/* ALTER SEQUENCE <name> AS */
else if (TailMatches("ALTER", "SEQUENCE", MatchAny, "AS"))
--
2.34.1
[text/x-diff] 0002-psql-Add-tab-completion-for-ALTER-COLUMN-SET-GENERAT.patch (2.1K, ../../87mta1jfax.fsf@wibble.ilmari.org/3-0002-psql-Add-tab-completion-for-ALTER-COLUMN-SET-GENERAT.patch)
download | inline diff:
From 59b0ab0159ad941dbc39b22aabb07e82c814612d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
Date: Wed, 12 Oct 2022 14:03:52 +0100
Subject: [PATCH 2/4] =?UTF-8?q?psql:=20Add=20tab=20completion=20for=20ALTE?=
=?UTF-8?q?R=20COLUMN=20=E2=80=A6=20SET=20GENERATED=20=E2=80=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/bin/psql/tab-complete.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 24a5f1f62b..1d4f1fd794 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -2381,7 +2381,7 @@ psql_completion(const char *text, int start, int end)
/* ALTER TABLE ALTER [COLUMN] <foo> SET */
else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET") ||
Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET"))
- COMPLETE_WITH("(", "COMPRESSION", "DEFAULT", "NOT NULL", "STATISTICS", "STORAGE");
+ COMPLETE_WITH("(", "COMPRESSION", "DEFAULT", "GENERATED", "NOT NULL", "STATISTICS", "STORAGE");
/* ALTER TABLE ALTER [COLUMN] <foo> SET ( */
else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "(") ||
Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "("))
@@ -2390,6 +2390,10 @@ psql_completion(const char *text, int start, int end)
else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "COMPRESSION") ||
Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "COMPRESSION"))
COMPLETE_WITH("DEFAULT", "PGLZ", "LZ4");
+ /* ALTER TABLE ALTER [COLUMN] <foo> SET GENERATED */
+ else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "GENERATED") ||
+ Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "GENERATED"))
+ COMPLETE_WITH("ALWAYS", "BY DEFAULT");
/* ALTER TABLE ALTER [COLUMN] <foo> SET STORAGE */
else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "STORAGE") ||
Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "STORAGE"))
--
2.34.1
[text/x-diff] 0003-psql-Add-tab-completion-for-ALTER-COLUMN-SET-sequenc.patch (2.2K, ../../87mta1jfax.fsf@wibble.ilmari.org/4-0003-psql-Add-tab-completion-for-ALTER-COLUMN-SET-sequenc.patch)
download | inline diff:
From 45c3d606f7d19fcee8223618ace7907b197401e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
Date: Wed, 12 Oct 2022 14:21:24 +0100
Subject: [PATCH 3/4] =?UTF-8?q?psql:=20Add=20tab=20completion=20for=20ALTE?=
=?UTF-8?q?R=20COLUMN=20=E2=80=A6=20SET=20<sequence=20option>?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/bin/psql/tab-complete.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 1d4f1fd794..009b6a7265 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -2381,7 +2381,9 @@ psql_completion(const char *text, int start, int end)
/* ALTER TABLE ALTER [COLUMN] <foo> SET */
else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET") ||
Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET"))
- COMPLETE_WITH("(", "COMPRESSION", "DEFAULT", "GENERATED", "NOT NULL", "STATISTICS", "STORAGE");
+ COMPLETE_WITH("(", "COMPRESSION", "DEFAULT", "GENERATED", "NOT NULL", "STATISTICS", "STORAGE",
+ /* a subset of ALTER SEQUENCE options */
+ "INCREMENT", "MINVALUE", "MAXVALUE", "START", "NO", "CACHE", "CYCLE");
/* ALTER TABLE ALTER [COLUMN] <foo> SET ( */
else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "(") ||
Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "("))
@@ -2394,6 +2396,10 @@ psql_completion(const char *text, int start, int end)
else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "GENERATED") ||
Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "GENERATED"))
COMPLETE_WITH("ALWAYS", "BY DEFAULT");
+ /* ALTER TABLE ALTER [COLUMN] <foo> SET NO */
+ else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "NO") ||
+ Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "NO"))
+ COMPLETE_WITH("MINVALUE", "MAXVALUE", "CYCLE");
/* ALTER TABLE ALTER [COLUMN] <foo> SET STORAGE */
else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "STORAGE") ||
Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "STORAGE"))
--
2.34.1
[text/x-diff] 0004-psql-Add-tab-completion-for-ALTER-COLUMN-ADD-GENERAT.patch (2.2K, ../../87mta1jfax.fsf@wibble.ilmari.org/5-0004-psql-Add-tab-completion-for-ALTER-COLUMN-ADD-GENERAT.patch)
download | inline diff:
From 47661c1c5d866816af3b898fe5d20137f6497780 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
Date: Wed, 12 Oct 2022 15:07:13 +0100
Subject: [PATCH 4/4] =?UTF-8?q?psql:=20Add=20tab=20completion=20for=20ALTE?=
=?UTF-8?q?R=20COLUMN=20=E2=80=A6=20ADD=20GENERATED=20=E2=80=A6=20AS=20IDE?=
=?UTF-8?q?NTITY?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/bin/psql/tab-complete.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 009b6a7265..525bcf9d57 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -2378,6 +2378,20 @@ psql_completion(const char *text, int start, int end)
else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny) ||
Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny))
COMPLETE_WITH("TYPE", "SET", "RESET", "RESTART", "ADD", "DROP");
+ /* ALTER TABLE ALTER [COLUMN] <foo> ADD */
+ else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "ADD") ||
+ Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "ADD"))
+ COMPLETE_WITH("GENERATED");
+ /* ALTER TABLE ALTER [COLUMN] <foo> ADD GENERATED */
+ else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "ADD", "GENERATED") ||
+ Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "ADD", "GENERATED"))
+ COMPLETE_WITH("ALWAYS", "BY DEFAULT");
+ /* ALTER TABLE ALTER [COLUMN] <foo> ADD GENERATED */
+ else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "ADD", "GENERATED", "ALWAYS") ||
+ Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "ADD", "GENERATED", "ALWAYS") ||
+ Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "ADD", "GENERATED", "BY", "DEFAULT") ||
+ Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "ADD", "GENERATED", "BY", "DEFAULT"))
+ COMPLETE_WITH("AS IDENTITY");
/* ALTER TABLE ALTER [COLUMN] <foo> SET */
else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET") ||
Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET"))
--
2.34.1
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [PATCH] Improve tab completion for ALTER TABLE on identity columns
@ 2022-10-14 14:31 Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
parent: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
1 sibling, 1 reply; 6+ messages in thread
From: Dagfinn Ilmari Mannsåker @ 2022-10-14 14:31 UTC (permalink / raw)
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> writes:
> Hi Hackers,
>
> I noticed that psql has no tab completion around identity columns in
> ALTER TABLE, so here's some patches for that.
Added to the next commit fest:
https://commitfest.postgresql.org/40/3947/
- ilmari
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [PATCH] Improve tab completion for ALTER TABLE on identity columns
@ 2022-10-25 22:45 Matheus Alcantara <mths.dev@pm.me>
parent: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
1 sibling, 1 reply; 6+ messages in thread
From: Matheus Alcantara @ 2022-10-25 22:45 UTC (permalink / raw)
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>; +Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
> Hi Hackers,
>
> I noticed that psql has no tab completion around identity columns in
> ALTER TABLE, so here's some patches for that.
>
> In passing, I also added completion for ALTER SEQUECNE … START, which was
> missing for some reason.
>
> - ilmari
Hi ilmari
I've tested all 4 of your patches, and all of them seem to work as expected.
This is my first time reviewing a patch, so let's see if more experience
hackers has anything more to say about these patches, but at first they
seem correct to me.
--
Matheus Alcantara
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [PATCH] Improve tab completion for ALTER TABLE on identity columns
@ 2022-11-01 11:19 Peter Eisentraut <peter.eisentraut@enterprisedb.com>
parent: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
0 siblings, 1 reply; 6+ messages in thread
From: Peter Eisentraut @ 2022-11-01 11:19 UTC (permalink / raw)
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
On 14.10.22 16:31, Dagfinn Ilmari Mannsåker wrote:
>> I noticed that psql has no tab completion around identity columns in
>> ALTER TABLE, so here's some patches for that.
>
> Added to the next commit fest:
>
> https://commitfest.postgresql.org/40/3947/
Committed.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [PATCH] Improve tab completion for ALTER TABLE on identity columns
@ 2022-11-01 11:20 Peter Eisentraut <peter.eisentraut@enterprisedb.com>
parent: Matheus Alcantara <mths.dev@pm.me>
0 siblings, 0 replies; 6+ messages in thread
From: Peter Eisentraut @ 2022-11-01 11:20 UTC (permalink / raw)
To: Matheus Alcantara <mths.dev@pm.me>; Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>; +Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
On 26.10.22 00:45, Matheus Alcantara wrote:
>> I noticed that psql has no tab completion around identity columns in
>> ALTER TABLE, so here's some patches for that.
>>
>> In passing, I also added completion for ALTER SEQUECNE … START, which was
>> missing for some reason.
> I've tested all 4 of your patches, and all of them seem to work as expected.
>
> This is my first time reviewing a patch, so let's see if more experience
> hackers has anything more to say about these patches, but at first they
> seem correct to me.
This was sensible for a first review. Thanks for you help.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [PATCH] Improve tab completion for ALTER TABLE on identity columns
@ 2022-11-01 11:29 Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
parent: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
0 siblings, 0 replies; 6+ messages in thread
From: Dagfinn Ilmari Mannsåker @ 2022-11-01 11:29 UTC (permalink / raw)
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>; +Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes:
> On 14.10.22 16:31, Dagfinn Ilmari Mannsåker wrote:
>>> I noticed that psql has no tab completion around identity columns in
>>> ALTER TABLE, so here's some patches for that.
>> Added to the next commit fest:
>> https://commitfest.postgresql.org/40/3947/
>
> Committed.
Thanks!
- ilmari
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2022-11-01 11:29 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-10-12 14:18 [PATCH] Improve tab completion for ALTER TABLE on identity columns Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
2022-10-14 14:31 ` Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
2022-11-01 11:19 ` Peter Eisentraut <peter.eisentraut@enterprisedb.com>
2022-11-01 11:29 ` Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
2022-10-25 22:45 ` Matheus Alcantara <mths.dev@pm.me>
2022-11-01 11:20 ` Peter Eisentraut <peter.eisentraut@enterprisedb.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox