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 2696375.1630765104@sss.pgh.pa.us
обсуждение исходный текст
Ответ на RE: [PATCH] support tab-completion for single quote input with equal sign  ("tanghy.fnst@fujitsu.com" <tanghy.fnst@fujitsu.com>)
Ответы 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  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Список pgsql-hackers
"tanghy.fnst@fujitsu.com" <tanghy.fnst@fujitsu.com> writes:
> [ v2-0001-support-tab-completion-for-single-quote-input-wit.patch ]

Surely this patch is completely wrong?  It needs more thought about
the interaction with the existing logic for double quotes, ie single
quote inside double quotes is not special, nor the reverse; nor should
parentheses inside quotes be counted.  It also needs to be aware of
backslashes in escape-style strings.

I kind of doubt that it's actually possible to parse string literals
correctly when working backward, as this function does.  For starters,
you won't know whether the string starts with "E", so you won't know
whether backslashes are special.  We've got away with backwards
parsing so far because the syntax rules for double-quoted strings are
so much simpler.  But if you want to handle single quotes, I think
you'll have to start by rearranging the code to parse forward.  That's
likely to be fairly ticklish, see the comment about

     * backwards scan has some interesting but intentional properties
     * concerning parenthesis handling.

I wish that whoever wrote that (which I think was me :-() had been
more explicit.  But I think that the point is that we look for a place
that's at the same parenthesis nesting level as the completion point,
not necessarily one that's globally outside of any parens.  That will
be messy to handle if we want to convert to scanning forwards from
the start of the string.

I kind of wonder if it isn't time to enlist the help of psqlscan.l
instead of doubling down on the idea that tab-complete.c should have
its own half-baked SQL lexer.

            regards, tom lane



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

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: Postgres perl module namespace
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Column Filtering in Logical Replication