Greg Rychlewski <greg.rychlewski@gmail.com> writes:
> On Sun, Jan 23, 2022 at 7:37 PM David G. Johnston <
> david.g.johnston@gmail.com> wrote:
>> Or a -bug report. It would be good to show the code you are using to
>> provoke the error. But I do see where we document the Simple Query
>> Protocol and do not qualify it such that it doesn't take a multi-command
>> message.
> Thank you. I will give those lists a shot. Apologies for the top-posting.
This does seem like a bug, and I concur with David that it doesn't belong
on the novice list anyway.
I noticed that repl_gram.y's make_sqlcmd() tries to skip over the rest
of a plain-SQL command, but stops at the first semicolon. I'm not quite
sure why that leads to a syntax error, because it looks like the grammar
shouldn't really care what follows the leading keyword. I took that
out (forcing the loop to run till the lexer returns zero), and this
problem went away, but there are still others. Notably:
1. This solution requires the repl_scanner.l lexer to be able to lex
everything that can appear in a plain-SQL command, which it is just
a thousand or so lines short of being able to do :-(. The cheesy
substitute of returning "T_WORD" for "." doesn't work well, for
example
$ psql "dbname=postgres replication=database"
psql (15devel)
Type "help" for help.
postgres=# select $x$ " $x$;
ERROR: unterminated quoted string
2. There is something seriously wrong with the error recovery
in repl_gram/repl_scanner, because if I try that repeatedly,
the results change:
postgres=# select $x$ " $x$;
?column?
----------
"
(1 row)
postgres=# select $x$ " $x$;
ERROR: unterminated quoted string
So we need some work there, but you ought to file this as
a bug report or start a -hackers thread; it's way out of
scope here.
regards, tom lane