Skip site navigation (1) Skip section navigation (2)

psql: missing tab completions for COMMENT ON

From: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: psql: missing tab completions for COMMENT ON
Date: 2011-05-29 02:38:01
Message-ID: BANLkTin0Nk7YN9naY9p+qdHUfPutz857MQ@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Hi all,

psql's auto-complete support for COMMENT ON was missing support for a
few object types:

1.) EXTENSION and PROCEDURAL LANGUAGE are now auto-complete candidates
for COMMENT ON [TAB]. Lists of extensions and procedural languages
should also be filled in when a user types
  COMMENT ON EXTENSION [TAB]
  COMMENT ON PROCEDURAL LANGUAGE [TAB]

2.) This part of tab-complete.c looked like a spurious leftover:

*************** psql_completion(char *text, int start, i
*** 1580,1592 ****

                COMPLETE_WITH_LIST(list_TRANS2);
        }
        else if ((pg_strcasecmp(prev4_wd, "COMMENT") == 0 &&
                          pg_strcasecmp(prev3_wd, "ON") == 0) ||
                         (pg_strcasecmp(prev6_wd, "COMMENT") == 0 &&
!                         pg_strcasecmp(prev5_wd, "ON") == 0) ||
!                        (pg_strcasecmp(prev5_wd, "ON") == 0 &&
!                         pg_strcasecmp(prev4_wd, "TEXT") == 0 &&
!                         pg_strcasecmp(prev3_wd, "SEARCH") == 0))
                COMPLETE_WITH_CONST("IS");

Since we want these choices to be filled in for COMMENT ON TEXT SEARCH [TAB]:
        {"CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE", NULL};

which were already being handled correctly in an above block.

One piece that I gave up on trying to fix is the auto-completion for
{OPERATOR, OPERATOR CLASS, OPERATOR FAMILY}, since getting it working
correctly would be a real hassle. There's the trouble of whether to
auto-complete operators for OPERATOR [TAB], or whether to fill in
{CLASS, FAMILY} instead. Plus the auto-completes for 'USING
index_method'.

While wasting time on OPERATOR [TAB], I realized we're being a bit
overeager with this bit:

    else if ((pg_strcasecmp(prev4_wd, "COMMENT") == 0 &&
              pg_strcasecmp(prev3_wd, "ON") == 0) ||
             (pg_strcasecmp(prev6_wd, "COMMENT") == 0 &&
              pg_strcasecmp(prev5_wd, "ON") == 0))
        COMPLETE_WITH_CONST("IS");

which will auto-complete e.g.
  COMMENT ON AGGREGATE avg [TAB]
with 'IS', when instead we'd want the possible argument types to avg,
or nothing at all. Same deal with a few other object types, but it's
probably not worth worrying about (at least, I'm not worrying about it
at the moment).

Barring objections, I can add this patch to the CF.

Josh

Attachment: tab_complete.v1.patch
Description: application/octet-stream (2.4 KB)

Responses

pgsql-hackers by date

Next:From: Greg StarkDate: 2011-05-29 02:42:51
Subject: Re: [ADMIN] pg_class reltuples/relpages not updated by autovacuum/vacuum
Previous:From: Greg SmithDate: 2011-05-29 02:01:11
Subject: Re: How can I check the treatment of bug fixes?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group