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 1lqHAM-0004ih-HK for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Jun 2021 15:27:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lqHAL-0002il-8A for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Jun 2021 15:27:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lqHAL-0002id-0b for pgsql-hackers@lists.postgresql.org; Mon, 07 Jun 2021 15:27:49 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lqHAI-0001Ho-Rw for pgsql-hackers@lists.postgresql.org; Mon, 07 Jun 2021 15:27: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 157FRfrt878525; Mon, 7 Jun 2021 11:27:41 -0400 From: Tom Lane To: Julien Rouhaud cc: Peter Eisentraut , Noah Misch , Jaime Casanova , PostgreSQL Hackers Subject: Re: SQL-standard function body In-reply-to: References: <20210315080344.wed62yy54fuse7jg@nol> <20210315081448.63vagqr3ly45l74i@nol> <20210331101256.d7h7d74o4celskt4@nol> <9277ef6a-bfa8-9c06-8e91-16c2892120cc@2ndquadrant.com> <20210403033943.dp6um65shvrovoj5@nol> <01c65ea6-e5bf-22f4-cacc-6d0f6853a965@2ndquadrant.com> <20210606044418.GA297923@rfd.leadboat.com> <20210606073220.42ytzr6r5bbhqh3q@nol> <993a2fe6-93b9-3364-21bb-6e2d8c0fde13@enterprisedb.com> Comments: In-reply-to Julien Rouhaud message dated "Mon, 07 Jun 2021 17:10:50 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <878523.1623079661.1@sss.pgh.pa.us> Date: Mon, 07 Jun 2021 11:27:41 -0400 Message-ID: <878524.1623079661@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Julien Rouhaud writes: > On Mon, Jun 7, 2021 at 4:52 PM Peter Eisentraut > wrote: >> Your patch filters out empty statements at the parse transformation >> phase, so they are no longer present when you dump the body back out. >> So your edits in the test expected files don't fit. > Oh, somehow the tests aren't failing here, I'm not sure what I did wrong. Modulo getting the tests right ... >> I suggest we just prohibit empty statements at the parse stage. I don't >> see a strong reason to allow them, and if we wanted to, we'd have to do >> more work, e.g., in ruleutils.c to print them back out correctly. > I always thought extraneous semicolons were tokens to be ignored, ... I tend to agree with Julien's position here. It seems really ugly to prohibit empty statements just for implementation convenience. However, the way I'd handle it is to have the grammar remove them, which is what it does in other contexts. I don't think there's any need to preserve them in ruleutils output --- there's a lot of other normalization we do on the way to that, and this seems to fit in. BTW, is it just me, or does SQL:2021 fail to permit multiple statements in a procedure at all? After much searching, I found the BEGIN ATOMIC ... END syntax, but it's in , in other words the body of a trigger not a procedure. I cannot find any production that connects a to that. There's an example showing use of BEGIN ATOMIC as a procedure statement, so they clearly *meant* to allow it, but it looks like somebody messed up the grammar. regards, tom lane