Re: PSQL/pgAdmin - Column Completion - Mailing list pgsql-general

From dvlsg
Subject Re: PSQL/pgAdmin - Column Completion
Date
Msg-id CAFzXWmu2sRb=9f7y7r_HP1UnSUfX2-_xuca=9x63gPFykuF3VA@mail.gmail.com
Whole thread Raw
In response to Re: PSQL/pgAdmin - Column Completion  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: PSQL/pgAdmin - Column Completion  (Adrian Klaver <adrian.klaver@aklaver.com>)
List 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
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] <[hidden email]> wrote:
dvlsg <[hidden email]> 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])
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.
NAML



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

pgsql-general by date:

Previous
From: Rob Sargent
Date:
Subject: Re: PSQL/pgAdmin - Column Completion
Next
From: John R Pierce
Date:
Subject: Re: PSQL/pgAdmin - Column Completion