Re: [PATCH] support tab-completion for single quote input with equal sign

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [PATCH] support tab-completion for single quote input with equal sign
Дата
Msg-id 403383.1673404136@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [PATCH] support tab-completion for single quote input with equal sign  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [PATCH] support tab-completion for single quote input with equal sign  (torikoshia <torikoshia@oss.nttdata.com>)
Список pgsql-hackers
I wrote:
> I've spent some effort previously on getting tab-completion to deal
> sanely with single-quoted strings, but everything I've tried has
> crashed and burned :-(, mainly because it's not clear when to take
> the whole literal as one "word" and when not.

After a little further thought, a new idea occurred to me: maybe
we could push some of the problem down into the Matches functions.
Consider inventing a couple of new match primitives:

* MatchLiteral matches one or more parse tokens that form a single
complete, valid SQL literal string (either single-quoted or dollar
style).  Use it like

    else if (Matches("CREATE", "SUBSCRIPTION", MatchAny, "CONNECTION", MatchLiteral))
         COMPLETE_WITH("PUBLICATION");

I think there's no question that most Matches calls that might subsume
a quoted literal would prefer to treat the literal as a single word,
and this'd let them do that correctly.

* MatchLiteralBegin matches the opening of a literal string (either '
or $...$).  Handwaving freely, we might do

    else if (Matches("CREATE", "SUBSCRIPTION", MatchAny, "CONNECTION", MatchLiteralBegin))
         COMPLETE_WITH(List_of_connection_keywords);

This part of the idea still needs some thought, because it remains
unclear how we might offer completion for connection keywords
after the first one.

Implementing these primitives might be a little tricky too.
If memory serves, readline and libedit have different behaviors
around quote marks.  But at least it seems like a framework
that could solve a number of problems, if we can make it go.

            regards, tom lane



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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: pgsql: Add new GUC createrole_self_grant.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pgsql: Add new GUC createrole_self_grant.