Add psql tab compression for ALTER TABLE .. { OF | NOT OF }
authorMichael Paquier <michael@paquier.xyz>
Sat, 10 Sep 2022 08:22:29 +0000 (17:22 +0900)
committerMichael Paquier <michael@paquier.xyz>
Sat, 10 Sep 2022 08:22:29 +0000 (17:22 +0900)
ALTER TABLE .. OF is now able to complete with the list of available
composite types that can be used with the query.

Author: Aleksander Alekseev
Reviewed-by: Shinya Kato
Discussion: https://postgr.es/m/47b71e0c523b30357208e79786161281@oss.nttdata.com

src/bin/psql/tab-complete.c

index a7eccc75d26fe7d075c91b4b7a0fb022a577bdb3..f3465adb85551a1e3227fa56f3daf673a1922a7d 100644 (file)
@@ -2240,7 +2240,8 @@ psql_completion(const char *text, int start, int end)
                      "ENABLE", "INHERIT", "NO", "RENAME", "RESET",
                      "OWNER TO", "SET", "VALIDATE CONSTRAINT",
                      "REPLICA IDENTITY", "ATTACH PARTITION",
-                     "DETACH PARTITION", "FORCE ROW LEVEL SECURITY");
+                     "DETACH PARTITION", "FORCE ROW LEVEL SECURITY",
+                     "OF", "NOT OF");
    /* ALTER TABLE xxx ADD */
    else if (Matches("ALTER", "TABLE", MatchAny, "ADD"))
    {
@@ -2473,6 +2474,10 @@ psql_completion(const char *text, int start, int end)
    else if (Matches("ALTER", "TABLE", MatchAny, "DETACH", "PARTITION", MatchAny))
        COMPLETE_WITH("CONCURRENTLY", "FINALIZE");
 
+   /* ALTER TABLE <name> OF */
+   else if (Matches("ALTER", "TABLE", MatchAny, "OF"))
+       COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_composite_datatypes);
+
    /* ALTER TABLESPACE <foo> with RENAME TO, OWNER TO, SET, RESET */
    else if (Matches("ALTER", "TABLESPACE", MatchAny))
        COMPLETE_WITH("RENAME TO", "OWNER TO", "SET", "RESET");