Thread: Type Ahead Issue

Type Ahead Issue

From
Carlos Mennens
Date:
I don't know if this is an issue with my client (Psql) or if it's
something I'm doing wrong but I've noticed this issue before and can't
figure it out. When I'm using the psql client, I really rely on the
tab / type ahead auto completion. When I run my command on one single
line, it works fine but when I break my line up into segments, it
doesn't understand what I'm trying to do:

ALTER TABLE meh ALTER C (if you press 'tab' after the 'c', psql knows
the only logical option is 'COLUMN'.

When I do the following, I don't get the same results:

ALTER TABLE meh
ALTER C (when I press 'tab' after 'C' to auto complete 'COLUMN', I get
the options only for 'COLLATION' or 'CONVERSION'. Why does it do this?
Am I missing something here? When the command is on one line, auto
complete works fine but when I break it up as show above in the 2nd
example, it acts like 'COLUMN' isn't even a valid option but if I
manually type the word 'COLUMN' and finish the command, it works. Why
is this acting this way?


Re: Type Ahead Issue

From
Tom Lane
Date:
Carlos Mennens <carlos.mennens@gmail.com> writes:
> Am I missing something here? When the command is on one line, auto
> complete works fine but when I break it up as show above in the 2nd
> example, it acts like 'COLUMN' isn't even a valid option but if I
> manually type the word 'COLUMN' and finish the command, it works.

Yeah, the autocompletion logic can only "see" the current line of input,
so in your second example it has no idea that this is an ALTER TABLE
command.  My recollection is that there's no very nice way around that
given the limitations of the readline callback interface, though maybe
if somebody got ambitious they could improve it.
        regards, tom lane