pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ilmari@ilmari.org
To: pgsql-hackers@lists.postgresql.org
Subject: Tab completion for CREATE SCHEMAAUTHORIZATION
Date: Fri, 09 Jul 2021 17:20:04 +0100
Message-ID: <8735snihmz.fsf@wibble.ilmari.org> (raw)

Hi Hackers,

I just noticed there's no tab completion for CREATE SCHEMA
AUTHORIZATION, nor for anything after CREATE SCHEMA <name>.

Please find attached a patch that adds this.

- ilmari

Attachments:

0001-Add-tab-completion-for-CREATE-SCHEMA.patch (text/x-diff, 2.1K) download From db02df7ea8d3a5db41268edd8c311a3631c9e9ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org> Date: Fri, 9 Jul 2021 17:15:00 +0100 Subject: [PATCH] Add tab completion for CREATE SCHEMA --- src/bin/psql/tab-complete.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 0ebd5aa41a..80f6001073 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -758,6 +758,13 @@ static const SchemaQuery Query_for_list_of_collations = { " FROM pg_catalog.pg_roles "\ " WHERE substring(pg_catalog.quote_ident(rolname),1,%d)='%s'" +#define Query_for_list_of_schema_roles \ +" SELECT pg_catalog.quote_ident(rolname) "\ +" FROM pg_catalog.pg_roles "\ +" WHERE substring(pg_catalog.quote_ident(rolname),1,%d)='%s'"\ +" UNION ALL SELECT 'CURRENT_USER'"\ +" UNION ALL SELECT 'SESSION_USER'" + #define Query_for_list_of_grant_roles \ " SELECT pg_catalog.quote_ident(rolname) "\ " FROM pg_catalog.pg_roles "\ @@ -2668,6 +2675,19 @@ psql_completion(const char *text, int start, int end) else if (TailMatches("AS", "ON", "SELECT|UPDATE|INSERT|DELETE", "TO")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); +/* CREATE SCHEMA [ <name> ] [ AUTHORIZATION ] */ + else if (Matches("CREATE", "SCHEMA")) + COMPLETE_WITH_QUERY(Query_for_list_of_schemas + " UNION ALL SELECT 'AUTHORIZATION'"); + else if (Matches("CREATE", "SCHEMA", "AUTHORIZATION")) + COMPLETE_WITH_QUERY(Query_for_list_of_schema_roles); + else if (Matches("CREATE", "SCHEMA", MatchAny, "AUTHORIZATION")) + COMPLETE_WITH_QUERY(Query_for_list_of_schema_roles); + else if (Matches("CREATE", "SCHEMA", MatchAny, "AUTHORIZATION", MatchAny)) + COMPLETE_WITH("CREATE", "GRANT"); + else if (Matches("CREATE", "SCHEMA", MatchAny)) + COMPLETE_WITH("AUTHORIZATION", "CREATE", "GRANT"); + /* CREATE SEQUENCE --- is allowed inside CREATE SCHEMA, so use TailMatches */ else if (TailMatches("CREATE", "SEQUENCE", MatchAny) || TailMatches("CREATE", "TEMP|TEMPORARY", "SEQUENCE", MatchAny)) -- 2.30.2

view thread (18+ messages)  latest in thread

Message-ID: <8735snihmz.fsf@wibble.ilmari.org>
Permalink:  ../8735snihmz.fsf@wibble.ilmari.org/
Also on:    postgresql.org/message-id/8735snihmz.fsf@wibble.ilmari.org

 ·  · 

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: ilmari@ilmari.org, pgsql-hackers@lists.postgresql.org
  Subject: Re: Tab completion for CREATE SCHEMAAUTHORIZATION
  In-Reply-To: <8735snihmz.fsf@wibble.ilmari.org>

* 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