From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, David Fetter <david(at)fetter(dot)org>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH] Tab complete EXECUTE FUNCTION for CREATE (EVENT) TRIGGER |
Date: | 2018-10-25 11:39:09 |
Message-ID: | 20181025113909.GA1327@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2018-10-25 11:45:57 | Re: Using old master as new replica after clean switchover |
Previous Message | Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?= | 2018-10-25 11:34:29 | Re: [PATCH] Tab complete EXECUTE FUNCTION for CREATE (EVENT) TRIGGER |