pgsql: Teach psql's tab completion to consider the entire input string.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Teach psql's tab completion to consider the entire input string.
Дата
Msg-id E1aAiig-0007at-2k@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Teach psql's tab completion to consider the entire input string.

Up to now, the tab completion logic has only examined the last few words
of the current input line; "last few" being originally as few as four
words, but lately up to nine words.  Furthermore, it only looked at what
libreadline considers the current line of input, which made it rather
myopic if you split your command across lines.  This was tolerable,
sort of, so long as the match patterns were only designed to consider the
last few words of input; but with the recent addition of HeadMatches()
and Matches() matching rules, we really have to do better if we want
those to behave sanely.

Hence, change the code to break the entire line down into words, and to
include any previous lines in the command buffer along with the active
readline input buffer.

This will be a little bit slower than the previous coding, but some
measurements say that even a query of several thousand characters can be
parsed in a hundred or so microseconds on modern machines; so it's really
not going to be significant for interactive tab completion.  To reduce
the cost some, I arranged to avoid the per-word malloc calls that used
to occur: all the words are now kept in one malloc'd buffer.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/d854118c8df8c413d069f7e88bb01b9e18e4c8ed

Modified Files
--------------
src/bin/psql/input.c        |   13 ++-
src/bin/psql/input.h        |   14 +--
src/bin/psql/mainloop.c     |    2 +-
src/bin/psql/tab-complete.c |  208 ++++++++++++++++++++++++++-----------------
src/bin/psql/tab-complete.h |    8 +-
5 files changed, 150 insertions(+), 95 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: psql: Review of new help output strings
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Remove silly completion for "DELETE FROM tabname ...".