From: Tom Lane <tgl@sss.pgh.pa.us>
To: Greg Stark <stark@mit.edu>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: David Fetter <david@fetter.org>
Cc: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Jeff Janes <jeff.janes@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Subject: Re: Making tab-complete.c easier to maintain
Date: Fri, 11 Dec 2015 10:00:20 -0500
Message-ID: <32220.1449846020@sss.pgh.pa.us> (raw)
In-Reply-To: <CAM-w4HOhQvCAMfK+em-wLAp3xpk0C517Vvw+7bBRdRJd+-E+5A@mail.gmail.com>
References: <20151209142709.GA7050@fetter.org>
<CAM-w4HO_1Qw-Ph8E75hp7A7mNyKnhnNMvmhK2Pv2SqJGoebNxQ@mail.gmail.com>
<20151209183106.GC10778@fetter.org>
<20151210.173846.28949785.horiguchi.kyotaro@lab.ntt.co.jp>
<CAB7nPqSd3gFi7DSEQCPepj1H7AYtHr3UB-TVm_rhpZuVqWAcEQ@mail.gmail.com>
<CAM-w4HOhQvCAMfK+em-wLAp3xpk0C517Vvw+7bBRdRJd+-E+5A@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Greg Stark <stark@mit.edu> writes:
> Fwiw I poked at the bison output to see if it would be possible to do.
> I think it's theoretically possible but a huge project and would
> create dependencies on bison internals that we would be unlikelly to
> accept.
That's the impression I got when I looked at it briefly, too. Without
some new APIs from bison it seems like it'd be way too messy/fragile.
> You would need
> a) A new protocol message to send the partial query to the server and
> get back a list of completions
As far as that goes, I'd imagined the functionality continuing to be
on the psql side. If we make it wait for a protocol upgrade, that
makes it even more improbable that it will ever happen. psql already
has its own copy of the lexer, so making it have something derived
from the grammar doesn't seem like a maintainability problem.
> b) Machinery in bison to return both all terminals that could come
> next as well as all possible terminals it could reduce to
Yeah, this is the hard part.
> d) Some way to deal with the partially parsed query to find out what
> schemas, tables, column aliases, etc should be considered for possible
> completion
I was imagining that some of that knowledge could be pushed back into the
grammar. That is, instead of just using generic nonterminals like ColId,
we'd need to have TableId, SchemaId, etc and be careful to use the
appropriate one(s) in each production of the grammar. Then, psql would
know which completion query to issue by noting which of these particular
nonterminals is a candidate for the next token right now. However, that
moves the goalposts in terms of what we'd have to be able to get back from
the alternate bison machinery.
Also, it's not just a SMOP to modify the grammar like that: it's not
at all unlikely that attempting to introduce such a finer categorization
would lead to a broken grammar, ie shift/reduce or reduce/reduce
conflicts. We couldn't be sure it would work till we've tried it.
> So I don't think it makes sense to hold up improvements today hoping
> for something like this.
Yeah, it's certainly a wishlist item rather than something that should
block shorter-term improvements.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, stark@mit.edu, michael.paquier@gmail.com, horiguchi.kyotaro@lab.ntt.co.jp, david@fetter.org, thomas.munro@enterprisedb.com, alvherre@2ndquadrant.com, jeff.janes@gmail.com
Subject: Re: Making tab-complete.c easier to maintain
In-Reply-To: <32220.1449846020@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox