public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Greg Rychlewski <[email protected]>
Cc: David G. Johnston <[email protected]>
Cc: pgsql-novice <[email protected]>
Subject: Re: replication connection and multi-command queries
Date: Sun, 23 Jan 2022 21:06:41 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAKemG7WFJyv5crvXAJJYJOtAa-+odONeR0YaSa+szSk3f3XKww@mail.gmail.com>
References: <CAKemG7Vejiga7yx5qM9MO+9HXzuE4RJ4gcf1VXeXQfCY3tKPEw@mail.gmail.com>
	<CAKFQuwasupXG-4FNdge0wvDDxdJbH=kJia7Pi=6rZdgGMRyVmA@mail.gmail.com>
	<CAKemG7Xx01ZQ9NWTWtsQJBjzWZbHjPEhq6=gptq9aUh7skm8wg@mail.gmail.com>
	<CAKFQuwZ-t-oMRwf+MZ5rtHyuJ6yhjJkiHWQ0jiOKHMt-oX-H8Q@mail.gmail.com>
	<CAKFQuwaE6QhRrSPQoncxM5UtrikykW7Zjkx9RuNjyr7VmB0X2Q@mail.gmail.com>
	<CAKemG7WFJyv5crvXAJJYJOtAa-+odONeR0YaSa+szSk3f3XKww@mail.gmail.com>

Greg Rychlewski <[email protected]> writes:
> On Sun, Jan 23, 2022 at 7:37 PM David G. Johnston <
> [email protected]> 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






view thread (7+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: replication connection and multi-command queries
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox