Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nBoku-0007lm-1D for pgsql-novice@arkaria.postgresql.org; Mon, 24 Jan 2022 02:06:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nBokr-00086m-Ps for pgsql-novice@arkaria.postgresql.org; Mon, 24 Jan 2022 02:06:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nBokr-00086d-HC for pgsql-novice@lists.postgresql.org; Mon, 24 Jan 2022 02:06:49 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nBokl-0002r4-1E for pgsql-novice@lists.postgresql.org; Mon, 24 Jan 2022 02:06:48 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 20O26f2B1786011; Sun, 23 Jan 2022 21:06:41 -0500 From: Tom Lane To: Greg Rychlewski cc: "David G. Johnston" , pgsql-novice Subject: Re: replication connection and multi-command queries In-reply-to: References: Comments: In-reply-to Greg Rychlewski message dated "Sun, 23 Jan 2022 19:43:44 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1786009.1642990001.1@sss.pgh.pa.us> Date: Sun, 23 Jan 2022 21:06:41 -0500 Message-ID: <1786010.1642990001@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Greg Rychlewski 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