Re: proposal: alternative psql commands quit and exit
От | Bruce Momjian |
---|---|
Тема | Re: proposal: alternative psql commands quit and exit |
Дата | |
Msg-id | 20180128233506.GD5022@momjian.us обсуждение исходный текст |
Ответ на | Re: proposal: alternative psql commands quit and exit (Bruce Momjian <bruce@momjian.us>) |
Ответы |
Re: proposal: alternative psql commands quit and exit
Re: proposal: alternative psql commands quit and exit |
Список | pgsql-hackers |
On Thu, Jan 25, 2018 at 03:46:30PM -0500, Bruce Momjian wrote: > On Mon, Jan 15, 2018 at 11:10:44AM -0500, Robert Haas wrote: > > prompt_status does seem to be available in psql's MainLoop(), so I > > think that could be done, but the problem is that I don't know exactly > > what message would be useful to print when we're in a "in quotes" > > state. If I had a good message text for that state, I might just > > choose to use it always rather than multiplying the number of > > messages. > > > > More broadly, I think what is needed here is less C-fu than > > English-fu. If we come up with something good, we can make it print > > that thing. > > I just read this thread and have some ideas. First, the reason 'help' > was added so easily is because it pointed users at getting more > information, and it required to be the first command in the query > buffer. > > I realize we are now considering allowing 'help', 'quit', and 'exit' to > appear alone on a line with whitespace before it, and remove the > requirement that it be the first thing in the query buffer. > > I think there are a few things to consider. > > First, allowing whitespace to be before the keyword --- do we really > think that typing <space>exit will more likely be typed by a user trying > to exit than part of an SQL query? I think requiring no space around > the keyword would reduce the number of false hints. > > Second, I am thinking we can check prompt_status and report "Use \q" if > we are not in a quoted string, and suggest "Use Control-D then \q" (or > "Use Control-C then \q" on Windows) and be done with it. By printing > the Control-D only when we are in a quoted strong, we minimize the > number of times that we are wrong due to stty changes. I used Robert's patch and modified it to match the ideas I had above. Specifically no white space can be before 'help', 'exit' or 'quit' and prompt_status is used to adjust the suggestion. Here is the visible behavior: test=> exit (exits) test=> SELECT test-> exit --> Use \q to quit. test-> \q test=> SELECT ' test'> exit --> Use control-D to quit. test'> \q test=> SELECT " test"> exit --> Use control-D to quit. test"> \q test=> SELECT /* test*> exit --> Use control-D to quit. test*> \q test=> SELECT 'asbs' AS test-> exit --> Use \q to quit. test-> \q test=> SELECT 'asbs' AS test-> exit test-> ; exit ------ asbs (1 row) One open issue is the existing help display is inaccurate on Windows: Use \\? for help or press control-C to clear the input buffer. Oh, it clears the input buffer alright, _and_ exits psql. This patch also removes the control-C mention on Windows. -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription +
Вложения
В списке pgsql-hackers по дате отправления: