On Fri, Dec 11, 2015 at 8:12 AM, Michael Paquier <michael.paqu...@gmail.com> wrote: > Also, if > we prioritize a dynamically generated tab completion using gram.y, so > be it and let's reject both patches then...
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. (Unless we can get new API methods added to bison which is not entirely unreasonable). The problem is that bison is only a small part of the problem. You would need a) A new protocol message to send the partial query to the server and get back a list of completions b) Machinery in bison to return both all terminals that could come next as well as all possible terminals it could reduce to c) Some kind of reverse lexer to determine for each terminal what the current partial input would have to match to be accepted 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 The machinery to do (b) is actually there in bison for the error reporting. It's currently hard coded to limit the output to 5 and there's no API for it, just a function that returns an error string. But it might be possible to get bison to add an API method for it. But that's as far as I got. I have no idea what (c) and (d) would look like. So I don't think it makes sense to hold up improvements today hoping for something like this. What might be more realistic is making sure to design the minilanguage to be easily generated by perl scripts or the like and then write something picking up easy patterns in gram.y or possibly poking through the bison table to generate a table of minilanguage matchers. My instinct is that would be easier to do with a real minilanguage instead of a regular expression system. -- greg -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers