Commit e6b8e83b authored by Michael Paquier's avatar Michael Paquier

Add psql completion for [ NO ] DEPENDS ON EXTENSION

ALTER INDEX was able to handle that already.  This adds tab completion
for all the remaining commands that support this grammar:
- ALTER FUNCTION
- ALTER PROCEDURE
- ALTER ROUTINE
- ALTER TRIGGER
- ALTER MATERIALIZED VIEW

Author: Ian Lawrence Barwick
Discussion: https://postgr.es/m/CAB8KJ=iypYudXuMOAMOP4BpkaYbXxk=a2cdJppX0e9mJXWtuig@mail.gmail.com
parent 38bb3aef
...@@ -1614,14 +1614,24 @@ psql_completion(const char *text, int start, int end) ...@@ -1614,14 +1614,24 @@ psql_completion(const char *text, int start, int end)
/* ALTER AGGREGATE,FUNCTION,PROCEDURE,ROUTINE <name> */ /* ALTER AGGREGATE,FUNCTION,PROCEDURE,ROUTINE <name> */
else if (Matches("ALTER", "AGGREGATE|FUNCTION|PROCEDURE|ROUTINE", MatchAny)) else if (Matches("ALTER", "AGGREGATE|FUNCTION|PROCEDURE|ROUTINE", MatchAny))
COMPLETE_WITH("("); COMPLETE_WITH("(");
/* ALTER AGGREGATE,FUNCTION,PROCEDURE,ROUTINE <name> (...) */ /* ALTER AGGREGATE <name> (...) */
else if (Matches("ALTER", "AGGREGATE|FUNCTION|PROCEDURE|ROUTINE", MatchAny, MatchAny)) else if (Matches("ALTER", "AGGREGATE", MatchAny, MatchAny))
{ {
if (ends_with(prev_wd, ')')) if (ends_with(prev_wd, ')'))
COMPLETE_WITH("OWNER TO", "RENAME TO", "SET SCHEMA"); COMPLETE_WITH("OWNER TO", "RENAME TO", "SET SCHEMA");
else else
COMPLETE_WITH_FUNCTION_ARG(prev2_wd); COMPLETE_WITH_FUNCTION_ARG(prev2_wd);
} }
/* ALTER FUNCTION,PROCEDURE,ROUTINE <name> (...) */
else if (Matches("ALTER", "FUNCTION|PROCEDURE|ROUTINE", MatchAny, MatchAny))
{
if (ends_with(prev_wd, ')'))
COMPLETE_WITH("OWNER TO", "RENAME TO", "SET SCHEMA",
"DEPENDS ON EXTENSION", "NO DEPENDS ON EXTENSION");
else
COMPLETE_WITH_FUNCTION_ARG(prev2_wd);
}
/* ALTER PUBLICATION <name> */ /* ALTER PUBLICATION <name> */
else if (Matches("ALTER", "PUBLICATION", MatchAny)) else if (Matches("ALTER", "PUBLICATION", MatchAny))
COMPLETE_WITH("ADD TABLE", "DROP TABLE", "OWNER TO", "RENAME TO", "SET"); COMPLETE_WITH("ADD TABLE", "DROP TABLE", "OWNER TO", "RENAME TO", "SET");
...@@ -1735,7 +1745,8 @@ psql_completion(const char *text, int start, int end) ...@@ -1735,7 +1745,8 @@ psql_completion(const char *text, int start, int end)
/* ALTER INDEX <name> */ /* ALTER INDEX <name> */
else if (Matches("ALTER", "INDEX", MatchAny)) else if (Matches("ALTER", "INDEX", MatchAny))
COMPLETE_WITH("ALTER COLUMN", "OWNER TO", "RENAME TO", "SET", COMPLETE_WITH("ALTER COLUMN", "OWNER TO", "RENAME TO", "SET",
"RESET", "ATTACH PARTITION", "DEPENDS", "NO DEPENDS", "RESET", "ATTACH PARTITION",
"DEPENDS ON EXTENSION", "NO DEPENDS ON EXTENSION",
"ALTER COLLATION"); "ALTER COLLATION");
else if (Matches("ALTER", "INDEX", MatchAny, "ATTACH")) else if (Matches("ALTER", "INDEX", MatchAny, "ATTACH"))
COMPLETE_WITH("PARTITION"); COMPLETE_WITH("PARTITION");
...@@ -1782,10 +1793,6 @@ psql_completion(const char *text, int start, int end) ...@@ -1782,10 +1793,6 @@ psql_completion(const char *text, int start, int end)
"buffering =", /* GiST */ "buffering =", /* GiST */
"pages_per_range =", "autosummarize =" /* BRIN */ "pages_per_range =", "autosummarize =" /* BRIN */
); );
else if (Matches("ALTER", "INDEX", MatchAny, "NO", "DEPENDS"))
COMPLETE_WITH("ON EXTENSION");
else if (Matches("ALTER", "INDEX", MatchAny, "DEPENDS"))
COMPLETE_WITH("ON EXTENSION");
/* ALTER INDEX <name> ALTER COLLATION */ /* ALTER INDEX <name> ALTER COLLATION */
else if (Matches("ALTER", "INDEX", MatchAny, "ALTER", "COLLATION")) else if (Matches("ALTER", "INDEX", MatchAny, "ALTER", "COLLATION"))
{ {
...@@ -1920,7 +1927,8 @@ psql_completion(const char *text, int start, int end) ...@@ -1920,7 +1927,8 @@ psql_completion(const char *text, int start, int end)
/* ALTER MATERIALIZED VIEW <name> */ /* ALTER MATERIALIZED VIEW <name> */
else if (Matches("ALTER", "MATERIALIZED", "VIEW", MatchAny)) else if (Matches("ALTER", "MATERIALIZED", "VIEW", MatchAny))
COMPLETE_WITH("ALTER COLUMN", "CLUSTER ON", "DEPENDS ON EXTENSION", COMPLETE_WITH("ALTER COLUMN", "CLUSTER ON", "DEPENDS ON EXTENSION",
"OWNER TO", "RENAME", "RESET (", "SET"); "NO DEPENDS ON EXTENSION", "OWNER TO", "RENAME",
"RESET (", "SET");
/* ALTER MATERIALIZED VIEW xxx RENAME */ /* ALTER MATERIALIZED VIEW xxx RENAME */
else if (Matches("ALTER", "MATERIALIZED", "VIEW", MatchAny, "RENAME")) else if (Matches("ALTER", "MATERIALIZED", "VIEW", MatchAny, "RENAME"))
COMPLETE_WITH_ATTR(prev2_wd, " UNION SELECT 'COLUMN' UNION SELECT 'TO'"); COMPLETE_WITH_ATTR(prev2_wd, " UNION SELECT 'COLUMN' UNION SELECT 'TO'");
...@@ -1997,7 +2005,8 @@ psql_completion(const char *text, int start, int end) ...@@ -1997,7 +2005,8 @@ psql_completion(const char *text, int start, int end)
/* ALTER TRIGGER <name> ON <name> */ /* ALTER TRIGGER <name> ON <name> */
else if (Matches("ALTER", "TRIGGER", MatchAny, "ON", MatchAny)) else if (Matches("ALTER", "TRIGGER", MatchAny, "ON", MatchAny))
COMPLETE_WITH("RENAME TO"); COMPLETE_WITH("RENAME TO", "DEPENDS ON EXTENSION",
"NO DEPENDS ON EXTENSION");
/* /*
* If we detect ALTER TABLE <name>, suggest sub commands * If we detect ALTER TABLE <name>, suggest sub commands
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment