Re: [PATCH] Tab completion for ALTER DATABASE …SET TABLESPACE - Mailing list pgsql-hackers

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

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

And just after hitting send, I noticed I'd typed ALTER TABLE instead of
ALTER DATABASE, including in the commit message :(

Fixed patch attached.

- ilmari 
-- 
"I use RMS as a guide in the same way that a boat captain would use
 a lighthouse.  It's good to know where it is, but you generally
 don't want to find yourself in the same spot." - Tollef Fog Heen

From e5ff67c3284dd456fe80ed8a8927e12665d68fea 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=20DATABASE?=
 =?UTF-8?q?=20=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 Eisentraut
Date:
Subject: Re: Hint to set owner for tablespace directory
Next
From: Alvaro Herrera
Date:
Subject: Re: Use C99 designated initializers for some structs