Re: [PATCH] Tab complete EXECUTE FUNCTION for CREATE (EVENT) TRIGGER
От | Michael Paquier |
---|---|
Тема | Re: [PATCH] Tab complete EXECUTE FUNCTION for CREATE (EVENT) TRIGGER |
Дата | |
Msg-id | 20181025113909.GA1327@paquier.xyz обсуждение исходный текст |
Ответ на | Re: [PATCH] Tab complete EXECUTE FUNCTION for CREATE (EVENT) TRIGGER (ilmari@ilmari.org (Dagfinn Ilmari Mannsåker)) |
Ответы |
Re: [PATCH] Tab complete EXECUTE FUNCTION for CREATE (EVENT) TRIGGER
|
Список | pgsql-hackers |
On Thu, Oct 25, 2018 at 12:25:33PM +0100, Dagfinn Ilmari Mannsåker wrote: > I did that initially, but because COMPLETE_WITH() requres constant > arguments, I had to repeat the whole list with just changing PROCEDURE > to FUNCTION, which I thought was undesirably repetitive. If there's a > more concise alternative to the below, or the consensus is that saving > one TAB press is worth it, I'll change it. > > else if (HeadMatches("CREATE", "TRIGGER") && TailMatches("ON", MatchAny)) > if (pset.sversion >= 110000) > COMPLETE_WITH("NOT DEFERRABLE", "DEFERRABLE", "INITIALLY", > "REFERENCING", "FOR", "WHEN (", "EXECUTE FUNCTION"); > else > COMPLETE_WITH("NOT DEFERRABLE", "DEFERRABLE", "INITIALLY", > "REFERENCING", "FOR", "WHEN (", "EXECUTE PROCEDURE"); [thinking] To keep the code simple, you could do something like that, by checking the head keywords for a match with CREATE TRIGGER, and then move all the existing conditions within it: else if (HeadMatches("CREATE", "TRIGGER", MatchAny)) { char *execute_keyword; if (pset.sversion >= 110000) execute_keyword = "EXECUTE FUNCTION"; else execute_keyword = "EXECUTE PROCEDURE"; if (TailMatches("CREATE", "TRIGGER", MatchAny)) COMPLETE_WITH("BEFORE", "AFTER", "INSTEAD OF"); [...] else if (the other existing conditions) blah and use execute_keyword in the lists; } If we do the automatic completion of both words at the same time, let's put only in a single place the version-based switch. This method costs an extra match check on the header keywords when CREATE TRIGGER matches, but it allows all the other checks to skip steps, which is actually a win for the rest. -- Michael
Вложения
В списке pgsql-hackers по дате отправления: