From: | Tels <nospam-pg-abuse(at)bloodgate(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, "Shinoda, Noriyoshi (PN Japan FSI)" <noriyoshi(dot)shinoda(at)hpe(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Tab complete for CREATE OR REPLACE TRIGGER statement |
Date: | 2020-11-19 17:19:44 |
Message-ID: | fababdb8ad8f5fd1385601f9e8340559@bloodgate.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello Tom,
On 2020-11-18 16:49, Tom Lane wrote:
> Tels <nospam-pg-abuse(at)bloodgate(dot)com> writes:
>> On 2020-11-18 06:06, Michael Paquier wrote:
>>> On Mon, Nov 16, 2020 at 10:14:10PM -0500, Tom Lane wrote:
>>>> Agreed, I'm not trying to block this patch. Just wishing
>>>> there were a better way.
>
>> To me the code looks like a prime candidate for "data-driven"
>> refactoring.
>> It should be redone as generic code that reads a table of rules with
>> params and then checks and applies each. Thus the repetitive code
>> would
>> be replaced by a bit more generic code and a lot of code-free data.
>
> In the past I've looked into whether the rules could be autogenerated
> from the backend's grammar. It did not look very promising though.
> The grammar isn't really factorized appropriately -- for instance,
> tab-complete has a lot of knowledge about which kinds of objects can
> be named in particular places, while the Bison productions only know
> that's a "name". Still, the precedent of ECPG suggests it might be
> possible to process the grammar rules somehow to get to a useful
> result.
Hm, that would be even better, for now I was just thinking that
code like this:
IF RULE_A_MATCHES THEN
DO STUFF A
ELSE IF RULE_B_MATCHES THEN
DO_STUFF_B
ELSE IF RULE_C_MATCHES THEN
DO_STUFF_C
...
should be replaced by
RULE_A MATCH STUFF
RULE_B MATCH STUFF
RULE_C MATCH STUFF
...
FOREACH RULE DO
IF RULE.MATCH THEN
DO RULE.STUFF
END FOREACH
Even if the rules would be manually created (converted from the current
code), that would be more compact and probably less error-prone.
Creating the rule automatically turns this into a completely different
story.
--
Best regards,
Tels
From | Date | Subject | |
---|---|---|---|
Next Message | Justin Pryzby | 2020-11-19 17:38:48 | Re: error_severity of brin work item |
Previous Message | Tom Lane | 2020-11-19 17:08:20 | Re: Should we document IS [NOT] OF? |