public inbox for [email protected]  
help / color / mirror / Atom feed
From: [email protected] <[email protected]>
To: [email protected] <[email protected]>
Subject: [PATCH]Add tab completion for foreigh table
Date: Tue, 11 Jan 2022 12:43:21 +0000
Message-ID: <OS0PR01MB61137E96E0551278782D11CDFB519@OS0PR01MB6113.jpnprd01.prod.outlook.com> (raw)

Hi

Attached a patch to improve the tab completion for foreigh table.

Also modified some DOC description of ALTER TABLE at [1] in according with CREATE INDEX at [2].

In [1], we use "ALTER INDEX ATTACH PARTITION"
In [2], we use "ALTER INDEX ... ATTACH PARTITION"

I think the format in [2] is better.

[1] https://www.postgresql.org/docs/devel/sql-altertable.html
[2] https://www.postgresql.org/docs/devel/sql-createindex.html

Regards,
Tang


Attachments:

  [application/octet-stream] v1-0001-add-tab-completion-for-PARTITION-OF-when-creating.patch (2.3K, ../OS0PR01MB61137E96E0551278782D11CDFB519@OS0PR01MB6113.jpnprd01.prod.outlook.com/2-v1-0001-add-tab-completion-for-PARTITION-OF-when-creating.patch)
  download | inline diff:
From 8f976659b98202c30e90c701698cd54957794e3f Mon Sep 17 00:00:00 2001
From: tanghy <[email protected]>
Date: Tue, 11 Jan 2022 17:28:15 +0900
Subject: [PATCH v1] add tab completion for PARTITION OF when creating foreign
 table


diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml
index a76e2e7322..93031968c8 100644
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -723,7 +723,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       separately with additional <literal>SET TABLESPACE</literal> commands.
       When applied to a partitioned table, nothing is moved, but any
       partitions created afterwards with
-      <command>CREATE TABLE PARTITION OF</command> will use that tablespace,
+      <command>CREATE TABLE ... PARTITION OF</command> will use that tablespace,
       unless overridden by a <literal>TABLESPACE</literal> clause.
      </para>
 
@@ -956,7 +956,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       For each index in the target table, a corresponding
       one will be created in the attached table; or, if an equivalent
       index already exists, it will be attached to the target table's index,
-      as if <command>ALTER INDEX ATTACH PARTITION</command> had been executed.
+      as if <command>ALTER INDEX ... ATTACH PARTITION</command> had been executed.
       Note that if the existing table is a foreign table, it is currently not
       allowed to attach the table as a partition of the target table if there
       are <literal>UNIQUE</literal> indexes on the target table.  (See also
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 39be6f556a..46f05b90cf 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -2636,6 +2636,10 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("CREATE", "FOREIGN", "DATA", "WRAPPER", MatchAny))
 		COMPLETE_WITH("HANDLER", "VALIDATOR", "OPTIONS");
 
+	/* CREATE FOREIGN TABLE*/
+	else if (Matches("CREATE", "FOREIGN", "TABLE", MatchAny))
+		COMPLETE_WITH("PARTITION OF");
+
 	/* CREATE INDEX --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* First off we complete CREATE UNIQUE with "INDEX" */
 	else if (TailMatches("CREATE", "UNIQUE"))
-- 
2.33.0.windows.2



view thread (4+ messages)  latest in thread

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: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: [PATCH]Add tab completion for foreigh table
  In-Reply-To: <OS0PR01MB61137E96E0551278782D11CDFB519@OS0PR01MB6113.jpnprd01.prod.outlook.com>

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

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox