Improve tab completion of CREATE EVENT TRIGGER in psql

This adds tab completion of the clauses WHEN and EXECUTE
FUNCTION|PROCEDURE clauses to CREATE EVENT TRIGGER, similar to CREATE
TRIGGER in the previous commit.  This has version-dependent logic so as
FUNCTION is chosen over PROCEDURE for 11 and newer versions.

Author: Dagfinn Ilmari Mannsåker
Reviewed-by: Tom Lane, Michael Paquier
Discussion: https://postgr.es/m/d8jmur4q4yc.fsf@dalvik.ping.uio.no
This commit is contained in:
Michael Paquier 2018-10-26 13:46:20 +09:00
parent 292ef6e277
commit 5953c99697

View File

@ -2608,6 +2608,29 @@ psql_completion(const char *text, int start, int end)
/* Complete CREATE EVENT TRIGGER <name> ON with event_type */
else if (Matches("CREATE", "EVENT", "TRIGGER", MatchAny, "ON"))
COMPLETE_WITH("ddl_command_start", "ddl_command_end", "sql_drop");
/*
* Complete CREATE EVENT TRIGGER <name> ON <event_type>. EXECUTE FUNCTION
* is the recommended grammar instead of EXECUTE PROCEDURE in version 11
* and upwards.
*/
else if (Matches("CREATE", "EVENT", "TRIGGER", MatchAny, "ON", MatchAny))
{
if (pset.sversion >= 110000)
COMPLETE_WITH("WHEN TAG IN (", "EXECUTE FUNCTION");
else
COMPLETE_WITH("WHEN TAG IN (", "EXECUTE PROCEDURE");
}
else if (HeadMatches("CREATE", "EVENT", "TRIGGER") &&
TailMatches("WHEN|AND", MatchAny, "IN", "(*)"))
{
if (pset.sversion >= 110000)
COMPLETE_WITH("EXECUTE FUNCTION");
else
COMPLETE_WITH("EXECUTE PROCEDURE");
}
else if (HeadMatches("CREATE", "EVENT", "TRIGGER") &&
TailMatches("EXECUTE", "FUNCTION|PROCEDURE"))
COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(Query_for_list_of_functions, NULL);
/* DEALLOCATE */
else if (Matches("DEALLOCATE"))