Re: proposal: psql autocomplete for casting

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: psql autocomplete for casting
Date: 2016-03-04 07:11:16
Message-ID: CAFj8pRCxP-MQ+CGhbdn2BtX+c=Xxj71B3Ryq68mGfaGnS4cAuA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2016-03-04 5:29 GMT+01:00 Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp
>:

> At Thu, 3 Mar 2016 12:15:13 +0100, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote in <
> CAFj8pRDB2PpESLxnwNDXmhvTS9VL0NMeAnUdv_hps9WzYwXLjw(at)mail(dot)gmail(dot)com>
> pavel.stehule> 2016-03-03 12:06 GMT+01:00 Kyotaro HORIGUCHI <
> > the requirement of space before is not good :( - It should be any
> different
> > than operator chars. Not only space.
> >
> > all other is perfect :)
>
> Yeah, I fortunately agree with you:p
>
> But the things are not so simple. readline can handle single
> prefix characters but cannot not handle prefix strings.
>
> The new diff adds ':' to WORD_BREAKS and adjusts related codes.
> As far as I can see, colons are used only for variable prefix,
> type casts and named parameter assignments in function
> calls. This covers the first two and the last wouldn't be a
> matter of tab-completion. This works as the following.
>
> > =# select now()::t<tab>
> > text trigger
> > tid tsm_handler
> > ...
> > tinterval txid_snapshot
> > =# select now()::te<tab>
> > =# select now()::text
>
> As an inevitable side effect, this makes completion for ": :"
> with types (which results in an syntax error) but I believe it
> won't be a matter.
>
> I'm quite unpleasant that the additional conditional expressions
> use bare previous_words but found no good solution.
>
> > else if (previous_words_count >= 2 &&
> > previous_words[1][strlen(previous_words[1])-1] == ':' &&
> > TailMatches1(":"))
>
> It is good if we could limit the candidate types by knowing the
> operand type but it seems a bit complicated.
>
> Some familiar type names won't come as candidates. They are
> "int", "float", "decimal", "dec", which are known only to gram.y
> but it does't seem to matter, too.
>
> Thoughts? Opinions?
>

It works. I found only one issue with multi word named types

I have not any complete option for select 1::timestamp with

maybe it is another limit of readline

Regards

Pavel

> regards,
>
> --
> Kyotaro Horiguchi
> NTT Open Source Software Center
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2016-03-04 07:52:52 Re: raw output from copy
Previous Message Michael Paquier 2016-03-04 06:54:44 Re: VS 2015 support in src/tools/msvc