Neil Conway writes:
> Well, I won't pretend to understand the psql command parsing code (hand
> parsing w/o flex: yuck!) -- but it seems to me that when it returns the
> "invalid command" error, it should reset the environment: the previous
> command failed, so the user should get an error and a chance to enter a
> new command.
The backslash commands are separate from the SQL commands. The reason is
that the backslash commands may actually operate on the buffer where the
SQL commands are being entered.
For instance, say I start entering a command and then decide not to do it
and reset the buffer.
delete from table1
\R
Instead of \r I entered \R, as a typo. There is no \R command, so what do
you do?
1. What you proposed: Execute the command as is and reset the buffer. --
I think not.
2. Clear the buffer. This might be reasonable, but I find it totally
unnecessary. Maybe I wanted to type \p or \e because my buffer is
already 23 lines long.
3. Ignore the failed backslash command and keep going. This is what it's
doing.
Think of psql as an editor and (some of) the backslash commands as editor
commands. When you enter a wrong command in your editor, what does it do?
--
Peter Eisentraut peter_e@gmx.net