From: | Peter Smith <smithpb2250(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | tab-complete COMPLETE_WITH_ATTR can become confused by table-lists. |
Date: | 2022-01-19 00:16:20 |
Message-ID: | CAHut+PvUShR5SHgm2pUj_8xcH=8CmqBjFcOdvjx+1j6b=_K2DQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi.
I stumbled onto a small quirk/bug in the tab-complete code.
There are some places that suggest tab completions using the current
table columns. These are coded like:
COMPLETE_WITH_ATTR(prev2_wd, "");
The assumption is that the prev2_wd represents the table to select from.
Normally, this works fine. However, there are also cases where a
table-list can be specified (not just a single table) and in this
scenario, the 'prev2_wd' can sometimes become confused about what is
table name to use.
e.g.
If there are spaces in the table-list like "t1, t2" then the word is
recognized as "t2" and it works as expected.
But, if there are no spaces in the table-list like "t1,t2" then the
word is recognized as "t1,t2", and since that is no such table name
the COMPLETE_WITH_ATTR does nothing.
~~
Examples (press <tab> after the "(")
// setup
test=# create table t1(a int, b int, c int);
test=# create table t2(d int, e int, f int);
// test single table --> OK
test=# analyze t1 (
a b c
test=# analyze t2 (
d e f
// test table-list with spaces --> OK
test=# analyze t1, t2 (
d e f
test=# analyze t2, t1 (
a b c
// test table-list without spaces --> does not work
test=# analyze t2,t1 (
~~
I found that this is easily fixed just by adding a comma to the
WORD_BREAKS. Then words all get tokenized properly and so 'prev2_wd'
is what you'd like it to be.
/* word break characters */
-#define WORD_BREAKS "\t\n(at)$><=;|&{() "
+#define WORD_BREAKS "\t\n,@$><=;|&{() "
OTOH, this seemed a pretty fundamental change to the 12-year-old (!!)
code so I don't know if it may be too risky and/or could adversely
affect something else?
The tests are all still passing, but there aren't so many tab-complete
tests anyway so that might not mean much.
Thoughts?
------
Kind Regards,
Peter Smith.
Fujitsu Australia
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-01-19 00:18:11 | Re: Replace uses of deprecated Python module distutils.sysconfig |
Previous Message | Andrew Dunstan | 2022-01-18 23:35:39 | Re: Extend compatibility of PostgreSQL::Test::Cluster |