On Wed, Nov 4, 2015 at 5:27 PM, Kyotaro HORIGUCHI
<horiguchi.kyotaro@lab.ntt.co.jp> wrote:
> Hello, I found that a typo(?) in tab-complete.c.
>
>> /* ALTER TABLE,INDEX,MATERIALIZED VIEW xxx ALL IN TABLESPACE xxx OWNED BY */
>> else if (pg_strcasecmp(prev6_wd, "ALL") == 0 &&
>> pg_strcasecmp(prev5_wd, "IN") == 0 &&
>> pg_strcasecmp(prev4_wd, "TABLESPACE") == 0 &&
>> pg_strcasecmp(prev2_wd, "OWNED") == 0 &&
>> pg_strcasecmp(prev4_wd, "BY") == 0)
>
> "BY" is compared against the word in wrong position and it
> prevents this completion from matching.
>
> I also found some other bugs in psql-completion. The attached
> patch applied on master and fixes them all togher.
+ /* If we have INDEX CONCURRENTLY <sth>, then add exiting indexes */
+ else if (pg_strcasecmp(prev2_wd, "INDEX") == 0 &&
+ pg_strcasecmp(prev_wd, "CONCURRENTLY") == 0)
+ COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL);
Is this for DROP INDEX CONCURRENTLY case?
If yes, we should check that prev3_wd is "DROP".
+ /* If we have CREATE|UNIQUE INDEX [CONCURRENTLY] <sth>, then add "ON" */
+ else if (((pg_strcasecmp(prev3_wd, "CREATE") == 0 ||
+ pg_strcasecmp(prev3_wd, "UNIQUE") == 0) &&
+ pg_strcasecmp(prev2_wd, "INDEX") == 0 &&
+ pg_strcasecmp(prev_wd, "CONCURRENTLY") != 0) ||
The "!= 0" in the above last condition should be "== 0" ?
+ {"TABLE", "COLUMN", "AGGREGATE", "DATABASE", "DOMAIN",
+ "EVENT TRIGGER", "FOREIGN TABLE", "FUNCTION", "LARGE OBJECT",
+ "MATERIALIZED VIEW", "LANGUAGE", "ROLE", "SCHEMA",
+ "SEQUENCE", "TYPE", "VIEW", NULL};
TABLESPACE also should be added to the list?
Regards,
--
Fujii Masao