pgsql-server/src/bin/psql tab-complete.c - Mailing list pgsql-committers

From momjian@postgresql.org (Bruce Momjian - CVS)
Subject pgsql-server/src/bin/psql tab-complete.c
Date
Msg-id 20030327164501.4EC3D476317@postgresql.org
Whole thread Raw
List pgsql-committers
CVSROOT:    /cvsroot
Module name:    pgsql-server
Changes by:    momjian@postgresql.org    03/03/27 11:45:01

Modified files:
    src/bin/psql   : tab-complete.c

Log message:
    Attached are two patches for psql's tab-completion.c.

    The first cleans up a couple of minor errors and ommissions
    and adds tab completion support to more slash commands, e.g.
    \dv.

    The second is an attempt to add tab completion for schemas
    and fully qualified relation names (e.g. public.mytable ).
    I think this covers the TODO-item:
    "Allow psql to do table completion for SELECT * FROM schema_part and table
    completion for SELECT * FROM schema_name."

    This happens via union selects querying:
    - relation_name in current search path;
    - schema_name;
    - schema.relation_name
    matching the current input string.

    E.g:
    SELECT p[TAB]
    will produce a list of all appropriate relation names in the current search
    path which begin with 'p', and also all schema names which begin with 'p';
    \d pub[TAB]
    will produce any relation names in the current search path and also
    any schema names beginning with 'pub';
    \d public.[TAB]
    will produce a list of all relations in the schema 'public';
    \d public.my[TAB]
    produces all relation names beginning with 'my' in schema 'public'.

    It seems to work for me; comments, suggestions, particularly regarding
    the coding and queries, are very welcome.

    Note that tables, indexes, views and sequences relations in the
    'pg_catalog' namespace are excluded even though they are in
    the current search path. I found not doing this produced annoying behaviour
    when expanding names beginning with 'p'. People who work with system
    tables a lot may not like this though; I can look for another solution
    if necessary.

    Ian Barwick


pgsql-committers by date:

Previous
From: momjian@postgresql.org (Bruce Momjian - CVS)
Date:
Subject: pgsql-server/src/bin/pg_dump pg_dump.c
Next
From: momjian@postgresql.org (Bruce Momjian - CVS)
Date:
Subject: pgsql-server/doc/src/sgml func.sgml