Re: Some bugs in psql_complete of psql - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: Some bugs in psql_complete of psql
Date
Msg-id CAHGQGwHyyD2RTuaTSry6-Xu0Mjr4Vneifknn2jdgp43g+yjV8Q@mail.gmail.com
Whole thread Raw
In response to Some bugs in psql_complete of psql  (Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>)
Responses Re: Some bugs in psql_complete of psql  (Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>)
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Marko Tiikkaja
Date:
Subject: Re: WIP: Fix parallel workers connection bug in pg_dump (Bug #13727)
Next
From: Fabien COELHO
Date:
Subject: Re: pgbench gaussian/exponential docs improvements