Thread: psql stops completion for the only matching schema name.

psql stops completion for the only matching schema name.

From
Kyotaro HORIGUCHI
Date:
Hello, I found that COMPLETE_SCHEMA_QUERY doesn't complete
only-one-matching schema names.

=# alter foreign table <tab>
information_schema.  pg_temp_1.           pg_toast_temp_1.
pg_catalog.          pg_toast.            public.
=# alter foreign table i<tab>
<no complition>

or 

=# alter foreign table pu<tab>
<no complition>

This makes more perplexing behavior with addon query.

=# create schema alpha;
=# alter table <tab>
ALL IN TABLESPACE    pg_catalog.          pg_toast_temp_1.
alpha.               pg_temp_1.           public.
information_schema.  pg_toast.            
=# alter table a<tab>
=# alter table ALL IN TABLESPACE _

Where my alpha has gone?

_complete_from_query adds schema names only if more than one
shcmea names match the current input. The 'i' matches only one
schema name. The reason for the behavior seems not to add a
schema name when qualified names in the schema is added. So the
attached patch does exactly the thing to do. psql behaves as the
following with this patch.

=# create schema alpha;
=# create table alpha.a (a int);
=# create table alpha.b (a int);
=# alter table <tab>
ALL IN TABLESPACE    pg_catalog.          pg_toast_temp_1.
alpha.               pg_temp_1.           public.
information_schema.  pg_toast.            
=# alter table al<tab>
ALL IN TABLESPACE  alpha.a            alpha.b            
=# alter table alp<tab>
=# alter table alpha.
alpha.a  alpha.b  

This seems to me the intended behavior here.

Any comments?

regards,

-- 
Kyotaro Horiguchi
NTT Open Source Software Center