Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m1tEj-0006gC-2M for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Jul 2021 16:20:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m1tEi-0005TA-0q for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Jul 2021 16:20:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m1tEg-0005T2-ID for pgsql-hackers@lists.postgresql.org; Fri, 09 Jul 2021 16:20:19 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m1tEZ-00043j-0u for pgsql-hackers@lists.postgresql.org; Fri, 09 Jul 2021 16:20:18 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id DB1F53200934 for ; Fri, 9 Jul 2021 12:20:06 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 09 Jul 2021 12:20:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h= from:to:subject:date:message-id:mime-version:content-type; s= fm2; bh=9SVZZJ6lCnv0p0ECiOaN4p8P7e4iK1IhKP2XlUASDHo=; b=eynGTNEU uWwg8DAZdpe2iP/AK3OoDQhwDFsQFjwVe3euUJtjlYTUZi5D9oxB9ZkNRZXMgljQ 423tx+wGTEx5efp5QYM2/QEJko7pBaWkWt0jXoyRjuokK9hQcivzxOnVj8d9n55v eDDQ9bdxH/stD87Ze2jkSlzK89RaIqTvIDN01qMbeKjbQH5wHWETCVOLLTjQ9yUF ujQ/pD8ezSRvO2ewlfBXQB0xjZ+tLkRhSvgJZ9c4I9empIBhSh0/t9mqwmuu+SEp 1+JFmeAeD7cUeuhAzizW2G4eqj7zZ+iFgOLXH5YP6SWqdR0dCEEzC59GpGiM/BUb binJzCI+Rr136w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=9SVZZJ6lCnv0p0ECiOaN4p8P7e4iK 1IhKP2XlUASDHo=; b=RYeQS2abL00BggwTWX3T7ETc6bJ7/UOTA3B8nFGM3kVzm 12I2Zz0dHtZVEviHYx+p26bbo11rHyfifs1r6V4HNng0+9JRVFnqZ1W8kjwbd9cW sckOdctbRbhigumDmDFRVIyQr4bs34sx2aueDTSpr70I4cVHlHVRT6oURmFHjdT0 IwijZdewmILfg0ARdGOpaDwb8E1MY64u2mZFk2L7wohZQHWw2cNsW+Vl448hGbh9 xGVD5pMWJYVGE33wS3/d/1Igxlz3xu604PKrCqmlcMknmN5i5fNWcVIL0GE89WHl j09puzzcCZr3pdQtN2o2uSAzploX18GVNw0RQOYaA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrtdeigdeliecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkfgfgggtsehmtderredtre ejnecuhfhrohhmpehilhhmrghrihesihhlmhgrrhhirdhorhhgucdlffgrghhfihhnnhcu kfhlmhgrrhhiucforghnnhhsnohkvghrmdenucggtffrrghtthgvrhhnpeeliefguddtue fgueethfdvvdduvdetieevvddtgfdtffeivdeivdehieehvdevffenucevlhhushhtvghr ufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehilhhmrghrihesihhlmhgrrh hirdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 9 Jul 2021 12:20:05 -0400 (EDT) From: ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) 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> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-=-= Content-Type: text/plain Hi Hackers, I just noticed there's no tab completion for CREATE SCHEMA AUTHORIZATION, nor for anything after CREATE SCHEMA . Please find attached a patch that adds this. - ilmari --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-tab-completion-for-CREATE-SCHEMA.patch From db02df7ea8d3a5db41268edd8c311a3631c9e9ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= 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 [ ] [ 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 --=-=-=--