Re: replication connection and multi-command queries

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Rychlewski <greg(dot)rychlewski(at)gmail(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, pgsql-novice <pgsql-novice(at)lists(dot)postgresql(dot)org>
Subject: Re: replication connection and multi-command queries
Date: 2022-01-24 02:06:41
Message-ID: 1786010.1642990001@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Greg Rychlewski <greg(dot)rychlewski(at)gmail(dot)com> writes:
> On Sun, Jan 23, 2022 at 7:37 PM David G. Johnston <
> david(dot)g(dot)johnston(at)gmail(dot)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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Innis 2022-02-08 18:50:46 How does Postgres support backwards compatibility
Previous Message Greg Rychlewski 2022-01-24 00:43:44 Re: replication connection and multi-command queries