Re: PSQL/pgAdmin - Column Completion

From: dvlsg <dave(at)clubspeed(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: PSQL/pgAdmin - Column Completion
Date: 2014-12-31 20:01:36
Message-ID: CAFzXWmu2sRb=9f7y7r_HP1UnSUfX2-_xuca=9x63gPFykuF3VA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yeah, I think that would be problematic. All other sql query applications
I've used in the past with autocomplete seem to parse the entire query and
find table references for autocompletion based on the whole query, whereas
psql seems to typically base autocomplete off of the current cursor
location and strings behind it without any lookaheads (as far as I can tell
-- I only took a brief look, and it's been a long time since I've had to
write C code).

I suppose what I would really be looking for is something like the vastly
simplified query below, where pressing Ctrl+Space after each "a." would
provide a list of columns only for the table alias.

SELECT
a.Column1,
a.Column2,
a.Column3
FROM
public.a_table_for_querying a

It looks like that would take a fairly significant bit of work/overhaul to
make the autocomplete parser look at the entire query to find a list of
used tables, and then find the list of available columns based on that, if
I'm reading the code correctly.

I agree with that last sentiment, though -- I don't think a list of every
column from every table would be very helpful.

Dave Lesage
*Club **Speed, Inc.*
*Software Engineer*
4740 Green River Road, Suite #308
Corona, CA 92880
Email: dave(at)clubspeed(dot)com
24 Hour Support: (877) 751-3200
International Support: (951) 817-7073

This e-mail is covered by the Electronic Communications Privacy Act, 18 USC
§§ 2510-2521 and is legally privileged. This communication and any
accompanying document(s) are confidential and privileged. They are intended
for the sole use of the addressee. If you receive this transmission in
error, you are advised that any disclosure, copying, distribution, or the
taking of any action in reliance upon the communication is strictly
prohibited. If you have received this communication in error, please
contact Club Speed, Inc. at (877) 751-3200.

On Wed, Dec 31, 2014 at 11:51 AM, Tom Lane-2 [via PostgreSQL] <
ml-node+s1045698n5832576h4(at)n5(dot)nabble(dot)com> wrote:

> dvlsg <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5832576&i=0>> writes:
> > I have been having issues with autocomplete in pgAdmin. After some
> searching,
> > I found it was my mistake and that pgAdmin doesn't actually support
> column
> > autocompletion in select statements. I found that pgAdmin uses the
> > autocomplete code directly from psql's tab-complete.c, which contains
> these
> > comments in the current version starting on line 3387:
>
> > /* SELECT */
> > /* naah . . . */
>
> > Is there any talk of this functionality being added in the future?
>
> No. What would the autocompletion be based on? You don't know any
> referenced table names at that point, for instance.
>
> > I find it
> > a bit disappointing that other applications such as HeidiSQL can
> > autocomplete column names from tables/aliases/etc, but pgAdmin cannot.
>
> The only algorithm I can imagine using would be to autocomplete every
> column and function name existing in the database. While this might be
> helpful in toy databases, it's hard to imagine it being very convenient,
> or performant, in real-world situations.
>
> regards, tom lane
>
>
> --
> Sent via pgsql-general mailing list ([hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5832576&i=1>)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://postgresql.nabble.com/PSQL-pgAdmin-Column-Completion-tp5832573p5832576.html
> To unsubscribe from PSQL/pgAdmin - Column Completion, click here
> <http://postgresql.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5832573&code=ZGF2ZUBjbHVic3BlZWQuY29tfDU4MzI1NzN8LTE2MzE3NzAwNjg=>
> .
> NAML
> <http://postgresql.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>

--
View this message in context: http://postgresql.nabble.com/PSQL-pgAdmin-Column-Completion-tp5832573p5832578.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2014-12-31 20:55:58 Re: PSQL/pgAdmin - Column Completion
Previous Message Rob Sargent 2014-12-31 19:56:52 Re: PSQL/pgAdmin - Column Completion