Thread

Commits

  1. psql: Add tab completion for VACUUM and ANALYZE ... ONLY option.

  1. Add missing tab completion for VACUUM and ANALYZE with ONLY option

    Umar Hayat <postgresql.wizard@gmail.com> — 2025-02-06T10:58:40Z

    Hi,
    Recently the ONLY option is introduced [1] for VACUUM and ANALYZE
    commands. Attach provides improved tab completion for this new option
    for both commands.
    
    Along with this also added starting parenthesis "(" auto-complete as
    multiple existing commands provide it and it makes it easier to
    separate command options (VERBOSE, FREEZE, ... ) from table list.
    
    [1] https://www.postgresql.org/message-id/flat/CADofcAWATx_haD%3DQkSxHbnTsAe6%2Be0Aw8Eh4H8cXyogGvn_kOg%40mail.gmail.com
    
    Regards
    -- 
    Umar Hayat
    Bitnine (https://bitnine.net/)
    
  2. Re: Add missing tab completion for VACUUM and ANALYZE with ONLY option

    vignesh C <vignesh21@gmail.com> — 2025-02-27T06:12:37Z

    On Thu, 6 Feb 2025 at 16:29, Umar Hayat <postgresql.wizard@gmail.com> wrote:
    >
    > Hi,
    > Recently the ONLY option is introduced [1] for VACUUM and ANALYZE
    > commands. Attach provides improved tab completion for this new option
    > for both commands.
    >
    > Along with this also added starting parenthesis "(" auto-complete as
    > multiple existing commands provide it and it makes it easier to
    > separate command options (VERBOSE, FREEZE, ... ) from table list.
    
    This will include "ONLY" also when we display the tables too:
    +       else if (HeadMatches("ANALYZE"))
    +
    COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_analyzables,
    "ONLY");
    
    like below:
    postgres=# analyze only t1
    information_schema.  ONLY                 public.              t1
    
    The same issue exists with vacuum too:
    postgres=# vacuum only t1
    information_schema.  ONLY                 public.              t1
    
    Regards,
    Vignesh
    
    
    
    
  3. Re: Add missing tab completion for VACUUM and ANALYZE with ONLY option

    vignesh C <vignesh21@gmail.com> — 2025-03-18T12:25:07Z

    On Thu, 27 Feb 2025 at 11:42, vignesh C <vignesh21@gmail.com> wrote:
    >
    > On Thu, 6 Feb 2025 at 16:29, Umar Hayat <postgresql.wizard@gmail.com> wrote:
    >
    > This will include "ONLY" also when we display the tables too:
    > +       else if (HeadMatches("ANALYZE"))
    > +
    > COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_analyzables,
    > "ONLY");
    >
    > like below:
    > postgres=# analyze only t1
    > information_schema.  ONLY                 public.              t1
    >
    > The same issue exists with vacuum too:
    > postgres=# vacuum only t1
    > information_schema.  ONLY                 public.              t1
    
    The attached patch has the fixes for the above issue.
    
    Regards,
    Vignesh
    
  4. Re: Add missing tab completion for VACUUM and ANALYZE with ONLY option

    Ilia Evdokimov <ilya.evdokimov@tantorlabs.com> — 2025-03-18T14:57:19Z

    On 18.03.2025 15:25, vignesh C wrote:
    > On Thu, 27 Feb 2025 at 11:42, vignesh C <vignesh21@gmail.com> wrote:
    >> On Thu, 6 Feb 2025 at 16:29, Umar Hayat <postgresql.wizard@gmail.com> wrote:
    >>
    >> This will include "ONLY" also when we display the tables too:
    >> +       else if (HeadMatches("ANALYZE"))
    >> +
    >> COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_analyzables,
    >> "ONLY");
    >>
    >> like below:
    >> postgres=# analyze only t1
    >> information_schema.  ONLY                 public.              t1
    >>
    >> The same issue exists with vacuum too:
    >> postgres=# vacuum only t1
    >> information_schema.  ONLY                 public.              t1
    > The attached patch has the fixes for the above issue.
    >
    > Regards,
    > Vignesh
    
    
    Hi,
    
    Thank you for the patch. However, Is it ok if I can't tab 'ONLY' in 
    VACUUM ANALYZE command?
    
    CREATE TABLE only_parted (a int, b text) PARTITION BY LIST (a);
    CREATE TABLE only_parted1 PARTITION OF only_parted FOR VALUES IN (1);
    INSERT INTO only_parted VALUES (1, 'a');
    
    VACUUM ANALYZE {Press Tab}
    
    information_schema.  only_parted          only_parted1 public.
    
    -----------------------------------------------------------------------------
    
    Although it works:
    
    postgres=# VACUUM ANALYZE ONLY only_parted;
    WARNING:  VACUUM ONLY of partitioned table "only_parted" has no effect
    VACUUM
    postgres=#
    
    --
    Best regards,
    Ilia Evdokimov,
    Tantor Labs LLC.
    
    
    
    
    
  5. Re: Add missing tab completion for VACUUM and ANALYZE with ONLY option

    Ilia Evdokimov <ilya.evdokimov@tantorlabs.com> — 2025-03-18T15:13:21Z

    On 18.03.2025 17:57, Ilia Evdokimov wrote:
    > Hi,
    >
    > Thank you for the patch. However, Is it ok if I can't tab 'ONLY' in 
    > VACUUM ANALYZE command?
    >
    > CREATE TABLE only_parted (a int, b text) PARTITION BY LIST (a);
    > CREATE TABLE only_parted1 PARTITION OF only_parted FOR VALUES IN (1);
    > INSERT INTO only_parted VALUES (1, 'a');
    >
    > VACUUM ANALYZE {Press Tab}
    >
    > information_schema.  only_parted          only_parted1 public.
    >
    > ----------------------------------------------------------------------------- 
    >
    >
    > Although it works:
    >
    > postgres=# VACUUM ANALYZE ONLY only_parted;
    > WARNING:  VACUUM ONLY of partitioned table "only_parted" has no effect
    > VACUUM
    > postgres=#
    >
    > -- 
    > Best regards,
    > Ilia Evdokimov,
    > Tantor Labs LLC.
    >
    
    Umar, Vignesh, sorry for not adding you to CC earlier!
    
    --
    Best regards,
    Ilia Evdokimov,
    Tantor Labs LLC.
    
    
    
    
    
  6. Re: Add missing tab completion for VACUUM and ANALYZE with ONLY option

    vignesh C <vignesh21@gmail.com> — 2025-03-19T05:12:38Z

    On Tue, 18 Mar 2025 at 20:43, Ilia Evdokimov
    <ilya.evdokimov@tantorlabs.com> wrote:
    >
    >
    > On 18.03.2025 17:57, Ilia Evdokimov wrote:
    > > Hi,
    > >
    > > Thank you for the patch. However, Is it ok if I can't tab 'ONLY' in
    > > VACUUM ANALYZE command?
    
    How about we handle it like in the attached patch?
    Apart from this, similar handling was required for "ANALYZE VERBOSE" also.
    
    Regards,
    Vignesh
    
  7. Re: Add missing tab completion for VACUUM and ANALYZE with ONLY option

    Ilia Evdokimov <ilya.evdokimov@tantorlabs.com> — 2025-03-19T07:57:00Z

    On 19.03.2025 08:12, vignesh C wrote:
    > How about we handle it like in the attached patch?
    > Apart from this, similar handling was required for "ANALYZE VERBOSE" also.
    >
    > Regards,
    > Vignesh
    
    
    It would be nice if this works with VACUUM VERBOSE ANALYZE ONLY table;
    
    --
    Best regards,
    Ilia Evdokimov,
    Tantor Labs LLC.
    
  8. Re: Add missing tab completion for VACUUM and ANALYZE with ONLY option

    vignesh C <vignesh21@gmail.com> — 2025-03-19T08:25:19Z

    On Wed, 19 Mar 2025 at 13:27, Ilia Evdokimov
    <ilya.evdokimov@tantorlabs.com> wrote:
    >
    > It would be nice if this works with VACUUM VERBOSE ANALYZE ONLY table;
    
    Thanks for the comment, here is an updated v3 version with the change
    for the same.
    
    Regards,
    Vignesh
    
  9. Re: Add missing tab completion for VACUUM and ANALYZE with ONLY option

    Ilia Evdokimov <ilya.evdokimov@tantorlabs.com> — 2025-03-19T09:16:01Z

    On 19.03.2025 08:12, vignesh C wrote:
    > How about we handle it like in the attached patch?
    > Apart from this, similar handling was required for "ANALYZE VERBOSE" also.
    
    
    Looks good overall. However, after pressing Tab, ONLY appears in the 
    completion list, but it doesn't autocomplete after typing the first letter.
    
    --
    Best regards,
    Ilia Evdokimov,
    Tantor Labs LLC.
    
  10. Re: Add missing tab completion for VACUUM and ANALYZE with ONLY option

    vignesh C <vignesh21@gmail.com> — 2025-03-19T09:55:27Z

    On Wed, 19 Mar 2025 at 14:46, Ilia Evdokimov
    <ilya.evdokimov@tantorlabs.com> wrote:
    >
    > Looks good overall. However, after pressing Tab, ONLY appears in the completion list, but it doesn't autocomplete after typing the first letter.
    
    In which case you noticed this?
    
    Regards,
    Vignesh
    
    
    
    
  11. Re: Add missing tab completion for VACUUM and ANALYZE with ONLY option

    Ilia Evdokimov <ilya.evdokimov@tantorlabs.com> — 2025-03-19T10:21:54Z

    On 19.03.2025 12:55, vignesh C wrote:
    >> Looks good overall. However, after pressing Tab, ONLY appears in the completion list, but it doesn't autocomplete after typing the first letter.
    > In which case you noticed this?
    
    
    Ah, I just tested it using these examples from the regression tests:
    
    CREATE TABLE only_parted (a int, b text) PARTITION BY LIST (a);
    CREATE TABLE only_parted1 PARTITION OF only_parted FOR VALUES IN (1);
    
    ONLY doesn't autocomplete here because the table names begin with 
    "only...", which conflicts with autocompletion—this was my oversight.
    
    ----------
    
    Everything seems fine with the ANALYZE command autocompletion. Regarding 
    VACUUM, I'm not entirely convinced we should provide autocompletion in 
    every case. I'd prefer to keep the behavior from the v3 patch because 
    the original intention behind adding the ONLY keyword was specifically 
    for collecting statistics exclusively from parent tables. Therefore, 
    autocompletion makes sense primarily for the ANALYZE case.
    
    Any thoughts?
    
    --
    Best regaards,
    Ilia Evdokimov,
    Tantor Labs LLC.
    
  12. Re: Add missing tab completion for VACUUM and ANALYZE with ONLY option

    David Rowley <dgrowleyml@gmail.com> — 2025-03-19T12:41:51Z

    On Wed, 19 Mar 2025 at 23:22, Ilia Evdokimov
    <ilya.evdokimov@tantorlabs.com> wrote:
    > Everything seems fine with the ANALYZE command autocompletion. Regarding VACUUM, I'm not entirely convinced we should provide autocompletion in every case. I'd prefer to keep the behavior from the v3 patch because the original intention behind adding the ONLY keyword was specifically for collecting statistics exclusively from parent tables. Therefore, autocompletion makes sense primarily for the ANALYZE case.
    
    While VACUUM ONLY on a partitioned table has no effect, the same isn't
    true for inheritance parents. 62ddf7ee9 did change the behaviour of
    VACUUM for these so that vacuuming the inheritance parent now vacuums
    all of its children, unless ONLY is used. So, I'd say if the tab
    completion is only added to ANALYZE, then it'd be incomplete still.
    (I've not looked at the v3 patch to see which of those it handles.)
    
    David
    
    
    
    
  13. Re: Add missing tab completion for VACUUM and ANALYZE with ONLY option

    vignesh C <vignesh21@gmail.com> — 2025-03-20T03:37:56Z

    On Wed, 19 Mar 2025 at 18:12, David Rowley <dgrowleyml@gmail.com> wrote:
    >
    > On Wed, 19 Mar 2025 at 23:22, Ilia Evdokimov
    > <ilya.evdokimov@tantorlabs.com> wrote:
    > > Everything seems fine with the ANALYZE command autocompletion. Regarding VACUUM, I'm not entirely convinced we should provide autocompletion in every case. I'd prefer to keep the behavior from the v3 patch because the original intention behind adding the ONLY keyword was specifically for collecting statistics exclusively from parent tables. Therefore, autocompletion makes sense primarily for the ANALYZE case.
    >
    > While VACUUM ONLY on a partitioned table has no effect, the same isn't
    > true for inheritance parents. 62ddf7ee9 did change the behaviour of
    > VACUUM for these so that vacuuming the inheritance parent now vacuums
    > all of its children, unless ONLY is used. So, I'd say if the tab
    > completion is only added to ANALYZE, then it'd be incomplete still.
    > (I've not looked at the v3 patch to see which of those it handles.)
    
    I also felt it is necessary for both ANALYZE and VACUUM, and the v3
    patch includes changes for both.
    
    Regards,
    Vignesh
    
    
    
    
  14. Re: Add missing tab completion for VACUUM and ANALYZE with ONLY option

    Tom Lane <tgl@sss.pgh.pa.us> — 2025-03-23T21:20:52Z

    vignesh C <vignesh21@gmail.com> writes:
    > On Wed, 19 Mar 2025 at 18:12, David Rowley <dgrowleyml@gmail.com> wrote:
    >> While VACUUM ONLY on a partitioned table has no effect, the same isn't
    >> true for inheritance parents. 62ddf7ee9 did change the behaviour of
    >> VACUUM for these so that vacuuming the inheritance parent now vacuums
    >> all of its children, unless ONLY is used. So, I'd say if the tab
    >> completion is only added to ANALYZE, then it'd be incomplete still.
    >> (I've not looked at the v3 patch to see which of those it handles.)
    
    > I also felt it is necessary for both ANALYZE and VACUUM, and the v3
    > patch includes changes for both.
    
    Agreed.
    
    Pushed with some cosmetic adjustments.  I made the order of the
    options match the syntax diagrams in the comments, which is just
    neatnik-ism (it changes no behavior) but seemed to read better.
    I also realized that we could simplify the match patterns for the
    various VACUUM cases by using MatchAnyN --- the existing code was
    getting rather contorted there.  That wasn't something your patch
    introduced, but might as well fix it while we're here.
    
    			regards, tom lane