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@$><=;|&{() "
+#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