Improve tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE

Lists: pgsql-hackers
From: vignesh C <vignesh21(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Improve tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE
Date: 2022-10-27 15:08:01
Message-ID: CALDaNm0s7GQmkLP_mx5Cvk=UzYMnjhPmXBxU8DsHEunFbC5sTg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

Tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE action was
missing, this patch adds the tab completion for the same.

Regards,
Vignesh

Attachment Content-Type Size
v1-0001-Tab-completion-for-ALTER-FUNCTION-PROCEDURE-ROUTI.patch text/x-patch 2.8 KB

From: Dong Wook Lee <sh95119(at)gmail(dot)com>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improve tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE
Date: 2022-10-28 02:32:20
Message-ID: CAAcByaKfB46d+H+j6G=wa3dJMLLGcAxn10Qd8N9LPsLo0HCxXg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Oct 28, 2022 at 12:08 AM vignesh C <vignesh21(at)gmail(dot)com> wrote:
>
> Hi,
>
> Tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE action was
> missing, this patch adds the tab completion for the same.
>
> Regards,
> Vignesh

Hi,
I applied your patch and did some tests.
Is it okay not to consider SET and RESET commands? (e.g ALTER FUNCTION)

---
Regards,
DongWook Lee.


From: vignesh C <vignesh21(at)gmail(dot)com>
To: Dong Wook Lee <sh95119(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improve tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE
Date: 2022-10-28 12:04:37
Message-ID: CALDaNm0HjHKnU3pXDg+UuNfTPymrftJsMU7+8uh0eJSOYh8y_w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, 28 Oct 2022 at 08:02, Dong Wook Lee <sh95119(at)gmail(dot)com> wrote:
>
> On Fri, Oct 28, 2022 at 12:08 AM vignesh C <vignesh21(at)gmail(dot)com> wrote:
> >
> > Hi,
> >
> > Tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE action was
> > missing, this patch adds the tab completion for the same.
> >
> > Regards,
> > Vignesh
>
> Hi,
> I applied your patch and did some tests.
> Is it okay not to consider SET and RESET commands? (e.g ALTER FUNCTION)

Those also should be handled, attached v2 version includes the changes
for the same.

Regards,
Vignesh

Attachment Content-Type Size
v2-0001-Tab-completion-for-ALTER-FUNCTION-PROCEDURE-ROUTI.patch text/x-patch 3.3 KB

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: Dong Wook Lee <sh95119(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improve tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE
Date: 2022-11-22 00:29:07
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Oct 28, 2022 at 05:34:37PM +0530, vignesh C wrote:
> Those also should be handled, attached v2 version includes the changes
> for the same.

The basic options supported by PROCEDURE are a subset of ROUTINE with a
difference of COST, IMMUTABLE, [NOT] LEAKPROOF, ROWS, STABLE
and VOLATILE.

The basic options supported by ROUTINE are a subset of FUNCTION with a
difference of { CALLED | RETURNS NULL } ON NULL INPUT, STRICT and
SUPPORT. Is it worth refactoring a bit with common lists?

+ "RESET", "RETURNS NULL ON NULL INPUT ", "ROWS",
Extra space after INPUT here, that's easy to miss.
--
Michael


From: vignesh C <vignesh21(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Dong Wook Lee <sh95119(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improve tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE
Date: 2022-11-22 06:18:58
Message-ID: CALDaNm3oLHTPJbtn3GQAQ+ki29HRf=JB3r6RfAN5u2ezn0N5Yw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 22 Nov 2022 at 05:59, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Fri, Oct 28, 2022 at 05:34:37PM +0530, vignesh C wrote:
> > Those also should be handled, attached v2 version includes the changes
> > for the same.
>
> The basic options supported by PROCEDURE are a subset of ROUTINE with a
> difference of COST, IMMUTABLE, [NOT] LEAKPROOF, ROWS, STABLE
> and VOLATILE.
>
> The basic options supported by ROUTINE are a subset of FUNCTION with a
> difference of { CALLED | RETURNS NULL } ON NULL INPUT, STRICT and
> SUPPORT. Is it worth refactoring a bit with common lists?

Modified

> + "RESET", "RETURNS NULL ON NULL INPUT ", "ROWS",
> Extra space after INPUT here, that's easy to miss.

Good catch, the attached v3 patch has the changes for the same.

Regards,
Vignesh

Attachment Content-Type Size
v3-0001-Tab-completion-for-ALTER-FUNCTION-PROCEDURE-ROUTI.patch text/x-patch 3.4 KB

From: Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Dong Wook Lee <sh95119(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improve tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE
Date: 2022-12-06 15:12:38
Message-ID: CAGPVpCTrRDho5xguMbsro-BhHoz94BLC52JXgzGWGPKFnTVcQg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi Vignesh,

Looks like the patch needs a rebase.

Also one little suggestion:

+ if (ends_with(prev_wd, ')'))
> + COMPLETE_WITH(Alter_routine_options, "CALLED ON NULL INPUT",
> + "RETURNS NULL ON NULL INPUT", "STRICT", "SUPPORT");

What do you think about gathering FUNCTION options as you did with ROUTINE
options.
Something like the following would seem nicer, I think.

#define Alter_function_options \
> Alter_routine_options, "CALLED ON NULL INPUT", \

"RETURNS NULL ON NULL INPUT", "STRICT", "SUPPORT"

Best,
--
Melih Mutlu
Microsoft


From: vignesh C <vignesh21(at)gmail(dot)com>
To: Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Dong Wook Lee <sh95119(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improve tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE
Date: 2022-12-06 19:11:49
Message-ID: CALDaNm2vsdn0ihSvYCTMBZkMWqQZ1jLYD+o5vqKULM0vRnjwxg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 6 Dec 2022 at 20:42, Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com> wrote:
>
> Hi Vignesh,
>
> Looks like the patch needs a rebase.

Rebased

> Also one little suggestion:
>
>> + if (ends_with(prev_wd, ')'))
>> + COMPLETE_WITH(Alter_routine_options, "CALLED ON NULL INPUT",
>> + "RETURNS NULL ON NULL INPUT", "STRICT", "SUPPORT");
>
>
> What do you think about gathering FUNCTION options as you did with ROUTINE options.
> Something like the following would seem nicer, I think.
>
>> #define Alter_function_options \
>> Alter_routine_options, "CALLED ON NULL INPUT", \
>>
>> "RETURNS NULL ON NULL INPUT", "STRICT", "SUPPORT"

I did not make it as a macro for alter function options as it is used
only in one place whereas the others were required in more than one
place.
The attached v4 patch is rebased on top of HEAD.

Regards,
Vignesh

Attachment Content-Type Size
v4-0001-Tab-completion-for-ALTER-FUNCTION-PROCEDURE-ROUTI.patch application/x-patch 3.4 KB

From: Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Dong Wook Lee <sh95119(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improve tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE
Date: 2022-12-07 08:55:24
Message-ID: CAGPVpCQDQh7tXtt-TL=bjVJS+qrM2NMg+5N9VWgdVYzPTT70-g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

vignesh C <vignesh21(at)gmail(dot)com>, 6 Ara 2022 Sal, 22:12 tarihinde şunu yazdı:

> I did not make it as a macro for alter function options as it is used
> only in one place whereas the others were required in more than one
> place.
>

Okay, makes sense.

I tested the patch and it worked for me.

Best,
--
Melih Mutlu
Microsoft


From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Dong Wook Lee <sh95119(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improve tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE
Date: 2023-01-05 12:52:30
Message-ID: CAEZATCWuvkKNgBhDBKc9NbUJY_RNr=abcMN456akf512Yu63Nw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 6 Dec 2022 at 19:12, vignesh C <vignesh21(at)gmail(dot)com> wrote:
>
> On Tue, 6 Dec 2022 at 20:42, Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com> wrote:
> >
> > Also one little suggestion:
> >
> >> + if (ends_with(prev_wd, ')'))
> >> + COMPLETE_WITH(Alter_routine_options, "CALLED ON NULL INPUT",
> >> + "RETURNS NULL ON NULL INPUT", "STRICT", "SUPPORT");
> >
> > What do you think about gathering FUNCTION options as you did with ROUTINE options.
> > Something like the following would seem nicer, I think.
> >
> >> #define Alter_function_options \
> >> Alter_routine_options, "CALLED ON NULL INPUT", \
> >> "RETURNS NULL ON NULL INPUT", "STRICT", "SUPPORT"
>
> I did not make it as a macro for alter function options as it is used
> only in one place whereas the others were required in more than one
> place.

My feeling is that having this macro somewhat improves readability and
consistency between the 3 cases, so I think it's worth it, even if
it's only used once.

I think it slightly improves readability to keep all the arguments to
Matches() on one line, and that seems to be the style elsewhere, even
if that makes the line longer than 80 characters.

Also in the interests of readability, I think it's slightly easier to
follow if the "ALTER PROCEDURE <name> (...)" and "ALTER ROUTINE <name>
(...)" cases are made to immediately follow the "ALTER FUNCTION <name>
(...)" case, with the longer/more complex cases following on from
that.

That leads to the attached, which barring objections, I'll push shortly.

While playing around with this, I noticed that the "... SET SCHEMA"
case offers "FROM CURRENT" and "TO" as completions, which is
incorrect. It should really offer to complete with a list of schemas.
However, since that's a pre-existing bug in a different region of the
code, I think it's best addressed in a separate patch, which probably
ought to be back-patched.

Regards,
Dean

Attachment Content-Type Size
v5-Tab-completion-for-ALTER-FUNCTION-PROCEDURE-ROUTINE.patch text/x-patch 3.1 KB

From: vignesh C <vignesh21(at)gmail(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Dong Wook Lee <sh95119(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improve tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE
Date: 2023-01-06 02:37:58
Message-ID: CALDaNm23oMmg3yvaPakjFASiRFK5MQAV3FK-HDcLcsrRWhX0Ow@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, 5 Jan 2023 at 18:22, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
>
> On Tue, 6 Dec 2022 at 19:12, vignesh C <vignesh21(at)gmail(dot)com> wrote:
> >
> > On Tue, 6 Dec 2022 at 20:42, Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com> wrote:
> > >
> > > Also one little suggestion:
> > >
> > >> + if (ends_with(prev_wd, ')'))
> > >> + COMPLETE_WITH(Alter_routine_options, "CALLED ON NULL INPUT",
> > >> + "RETURNS NULL ON NULL INPUT", "STRICT", "SUPPORT");
> > >
> > > What do you think about gathering FUNCTION options as you did with ROUTINE options.
> > > Something like the following would seem nicer, I think.
> > >
> > >> #define Alter_function_options \
> > >> Alter_routine_options, "CALLED ON NULL INPUT", \
> > >> "RETURNS NULL ON NULL INPUT", "STRICT", "SUPPORT"
> >
> > I did not make it as a macro for alter function options as it is used
> > only in one place whereas the others were required in more than one
> > place.
>
> My feeling is that having this macro somewhat improves readability and
> consistency between the 3 cases, so I think it's worth it, even if
> it's only used once.
>
> I think it slightly improves readability to keep all the arguments to
> Matches() on one line, and that seems to be the style elsewhere, even
> if that makes the line longer than 80 characters.
>
> Also in the interests of readability, I think it's slightly easier to
> follow if the "ALTER PROCEDURE <name> (...)" and "ALTER ROUTINE <name>
> (...)" cases are made to immediately follow the "ALTER FUNCTION <name>
> (...)" case, with the longer/more complex cases following on from
> that.
>
> That leads to the attached, which barring objections, I'll push shortly.

The changes look good to me.

Regards,
Vignesh


From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Dong Wook Lee <sh95119(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improve tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE
Date: 2023-01-06 10:03:22
Message-ID: CAEZATCX_-z+HjVem6E9Qm=zqFUoyPdUaQJ33-008P1++N-59JQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, 6 Jan 2023 at 02:38, vignesh C <vignesh21(at)gmail(dot)com> wrote:
>
> On Thu, 5 Jan 2023 at 18:22, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
> >
> > That leads to the attached, which barring objections, I'll push shortly.
>
> The changes look good to me.
>

Pushed.

Regards,
Dean


From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Dong Wook Lee <sh95119(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improve tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE
Date: 2023-01-06 11:28:10
Message-ID: CAEZATCWFSKG83ZFJ4KG-aJ58hmRh=dUhhn0=W0Xu+xSNhtU0kQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, 5 Jan 2023 at 12:52, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
>
> While playing around with this, I noticed that the "... SET SCHEMA"
> case offers "FROM CURRENT" and "TO" as completions, which is
> incorrect. It should really offer to complete with a list of schemas.
> However, since that's a pre-existing bug in a different region of the
> code, I think it's best addressed in a separate patch, which probably
> ought to be back-patched.
>

OK, I've pushed and back-patched a fix for that issue too.

Regards,
Dean


From: vignesh C <vignesh21(at)gmail(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Dong Wook Lee <sh95119(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improve tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE
Date: 2023-01-07 12:26:34
Message-ID: CALDaNm1-_hnWx0rU+zRor1ZzLeMcMhbLA-xLrt7q9VwRDxL+wg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, 6 Jan 2023 at 15:33, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
>
> On Fri, 6 Jan 2023 at 02:38, vignesh C <vignesh21(at)gmail(dot)com> wrote:
> >
> > On Thu, 5 Jan 2023 at 18:22, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
> > >
> > > That leads to the attached, which barring objections, I'll push shortly.
> >
> > The changes look good to me.
> >
>
> Pushed.

Thanks for pushing this.

Regards,
Vignesh