pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: miyake_kouta <miyake_kouta@oss.nttdata.com>
To: pgsql-hackers@postgresql.org
Subject: [PATCH] Feature improvement for TRUNCATE tab completion.
Date: Mon, 22 Feb 2021 16:04:10 +0900
Message-ID: <f5d30053d00dcafda3280c9e267ecb0f@oss.nttdata.com> (raw)

Hi.

I created a patch which improves psql's TRUNCATE tab completion.
Current tab completion can complement only a table name to be truncated.
This patch enables psql to complement other keywords related to 
TRUNCATE.

Regards.
Kota Miyake

Attachments:

truncate_tab_completion.patch (text/x-diff, 1.0K) download diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 1e1c315bae..ef9ef4cb25 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -3799,7 +3799,20 @@ psql_completion(const char *text, int start, int end) /* TRUNCATE */ else if (Matches("TRUNCATE")) + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, + " UNION SELECT 'TABLE'" + " UNION SELECT 'ONLY'"); + else if (Matches("TRUNCATE", "TABLE")) + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, + " UNION SELECT 'ONLY'"); + else if (HeadMatches("TRUNCATE") && TailMatches("ONLY")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); + else if (Matches("TRUNCATE", MatchAny) || + Matches("TRUNCATE", "TABLE|ONLY", MatchAny) || + Matches("TRUNCATE", "TABLE", "ONLY", MatchAny)) + COMPLETE_WITH("RESTART IDENTITY", "CONTINUE IDENTITY", "CASCADE", "RESTRICT"); + else if (HeadMatches("TRUNCATE") && TailMatches("IDENTITY")) + COMPLETE_WITH("CASCADE", "RESTRICT"); /* UNLISTEN */ else if (Matches("UNLISTEN"))

view thread (4+ messages)  latest in thread

Message-ID: <f5d30053d00dcafda3280c9e267ecb0f@oss.nttdata.com>
Permalink:  ../f5d30053d00dcafda3280c9e267ecb0f@oss.nttdata.com/
Also on:    postgresql.org/message-id/f5d30053d00dcafda3280c9e267ecb0f@oss.nttdata.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: miyake_kouta@oss.nttdata.com
  Subject: Re: [PATCH] Feature improvement for TRUNCATE tab completion.
  In-Reply-To: <f5d30053d00dcafda3280c9e267ecb0f@oss.nttdata.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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