[PATCH] Tab completion for ALTER DATABASE … SETTABLESPACE - Mailing list pgsql-hackers

From ilmari@ilmari.org (Dagfinn Ilmari Mannsåker)
Subject [PATCH] Tab completion for ALTER DATABASE … SETTABLESPACE
Date
Msg-id d8jo9djvm7h.fsf@dalvik.ping.uio.no
Whole thread Raw
Responses Re: [PATCH] Tab completion for ALTER DATABASE …SET TABLESPACE
List pgsql-hackers
Hi hackers,

I just noticed that psql's tab completion for ALTER TABLE … SET
TABLESPACE was treating it as any other configuration parameter and
completing with FROM DEFAULT or TO after it, instead of a list of
tablespaces.

PFA a patch that fixes this.

- ilmari
-- 
"A disappointingly low fraction of the human race is,
 at any given time, on fire." - Stig Sandbeck Mathisen

From a72d9dc1f38606a0bca8ff29b561915b8cbe9d5c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
Date: Thu, 30 Aug 2018 17:36:16 +0100
Subject: [PATCH] =?UTF-8?q?Fix=20tab=20completion=20for=20ALTER=20TABLE=20?=
 =?UTF-8?q?=E2=80=A6=20SET=20TABLESPACE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It was being treated as any other configuration parameter.
---
 src/bin/psql/tab-complete.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index bb696f8ee9..f107ffb027 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1783,6 +1783,10 @@ psql_completion(const char *text, int start, int end)
                             "IS_TEMPLATE", "ALLOW_CONNECTIONS",
                             "CONNECTION LIMIT");
 
+    /* ALTER DATABASE <name> SET TABLESPACE */
+    else if (Matches5("ALTER", "DATABASE", MatchAny, "SET", "TABLESPACE"))
+        COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces);
+
     /* ALTER EVENT TRIGGER */
     else if (Matches3("ALTER", "EVENT", "TRIGGER"))
         COMPLETE_WITH_QUERY(Query_for_list_of_event_triggers);
-- 
2.18.0


pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: "Write amplification" is made worse by "getting tired" whileinserting into nbtree secondary indexes (Was: Why B-Tree suffix truncation matters)
Next
From: Peter Eisentraut
Date:
Subject: Re: Hint to set owner for tablespace directory