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 1pbZgO-0007rw-6Y for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Mar 2023 04:21:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pbZgN-0002O0-0u for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Mar 2023 04:21:11 +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 1pbZgM-0002Nr-MS for pgsql-bugs@lists.postgresql.org; Mon, 13 Mar 2023 04:21:10 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pbZgK-00023c-3c for pgsql-bugs@lists.postgresql.org; Mon, 13 Mar 2023 04:21:10 +0000 Received: by mail-ed1-x533.google.com with SMTP id ek18so12381717edb.6 for ; Sun, 12 Mar 2023 21:21:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678681265; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=mDbGJNnumibRkszO0ScMwYZC5hlKclnTV16k+YnDSZE=; b=VxSfq6UDbDMGt22kRyw98dG0ZaPToeQJ1q1T2XqtF+E8LrOgrTEjWEKQq5ww4lICE3 xXoJ2HFMteUFcaUS2ysbh0xfIeajGGBMwd6keq30/5d9LxNfj692zgDZMgHZuB2036ra siPOd/hjx5koP008HjnUvK7xIzpMZF9WD41yKQe9G7J3HSw6d+lE6vZodb1l2Etb1S0G MhUMfbaT0f8uptBG2XQft8/dSPJb9UG0isC9thJjnI0zEmgreH+99IN5mYemIdeholyI 2VQFdZyPeW369tC0VaoDQ470l5bxVScBvUjqrjtSIGziRSAbv86uQqn7tHTbbe7JviBp BRAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678681265; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=mDbGJNnumibRkszO0ScMwYZC5hlKclnTV16k+YnDSZE=; b=FQYMFn0ifrZYkkRQSNaLhZfEuQnXYQAB/+z143yaqds9fj3lKWE5zdKSeg1X9aRokz CuitFaZqQgg061N6y1zKiRyqG7QPfPpMDs11JOrYceMx3Nt1wwr0x9QdlpYQ6dg5ExZ9 Vzh8vWd0AaazbGcHG+3Ka3O4YoWPsTA3xMeMosHm7C6hVnPovqJEqsTmNheBp5VNdSoc aeDB8l/T35gGcFooJsbEwacXB4mnKvV30GfSSZc6nBzzSv2BwOpJ+71lHMekG9ua8+md fjGlveieNi6IppS5ICr5AqOBe/b8lXLFCZENzUjC/T/4jfNBIHtiYt54HfjQ91i7DONP xI/g== X-Gm-Message-State: AO0yUKXqKc79R6zKpB5hfKRfhj7dLUx7gIby4NFcdf5V1/9eS3b2VPDo 7Nr+o2oRNjlpqt4N404csL9jFk/w9LHyNZZiSEWx0IqjZcBJHw== X-Google-Smtp-Source: AK7set+alkRNDLN7d4V57ekN25Xv0YcN2yzpHMxgfCrFkhdDoi7O5av+IvStn23varpy4S1zDBL/KIeRdAr/HsHhFBY= X-Received: by 2002:a17:906:7151:b0:922:cb10:ace3 with SMTP id z17-20020a170906715100b00922cb10ace3mr2119014ejj.5.1678681265339; Sun, 12 Mar 2023 21:21:05 -0700 (PDT) MIME-Version: 1.0 From: David Adams Date: Mon, 13 Mar 2023 15:20:28 +1100 Message-ID: Subject: psql 14.7/15.2 report a bogus syntax error on function and procedure files that use BEGIN ATOMIC To: pgsql-bugs@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000083031d05f6c0708e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000083031d05f6c0708e Content-Type: text/plain; charset="UTF-8" BEGIN ATOMIC is one of my favorite additions ot Postgres 14, and I use it widely. Mostly with CREATE FUNCTION, and sometimes with CREATE PROCEDURE. It's reassuring to have table and column references baked in as referenced, rather than stored as text. I can't count how many times the dependency tracking on views has stopped me from putting things into an inconsistent state. I've found a fair few 3rd party tools have, or have had, trouble parsing and processing functions and procedures that use BEGIN ATOMIC. And, unfortunately, this seems to be the case with psql too. My working routines are fairly long, so I've built out a toy example that I think illustrates the problem. Below are two function definitions, entered and run from a GUI console: DROP FUNCTION IF EXISTS tell_me_how_plain(); CREATE OR REPLACE FUNCTION tell_me_how_plain() RETURNS text LANGUAGE SQL return 'plain'; END; DROP FUNCTION IF EXISTS tools.tell_me_how_atomic(); CREATE OR REPLACE FUNCTION tools.tell_me_how_atomic() RETURNS text LANGUAGE SQL BEGIN ATOMIC return 'atomic'; END; select * from tell_me_how_plain(); -- plain select * from tell_me_how_atomic(); -- atomic If I run the script files from the command line with psql, the tell_me_how_plain.sql function builds fine, and the tell_me_how_atomic.sql throws a bogus syntax error: ERROR: syntax error at end of input LINE 5: return 'atomic'; ^ I've tried using both the -f flag and the path, and the < path option, like so: psql -p 5555 -U postgres -d squid -w -v --echo-all -f "/Users/dpadams2/Desktop/PG_Bug_Tell_Me_How/tell_me_how_atomic.sql" psql -p 5555 -U postgres -d squid -w -v --echo-all < "/Users/dpadams2/Desktop/PG_Bug_Tell_Me_How/tell_me_how_atomic.sql" I really hope that this is *not a bug*, and that I'm missing something obvious that gets around this error. I noticed in the release notes for 14.7 and 15.2 that there were changes to psql related to BEGIN ATOMIC on a few flags, but not -f. Any help appreciated, or a confirmation so that I can stop trying to fix this on my own. Thanks. --00000000000083031d05f6c0708e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
BEGIN ATOMIC is one of my = favorite additions ot Postgres 14, and I use it widely. Mostly with CREATE FUNCTION, and sometimes with CREATE PROCEDURE.=C2=A0 It's reassuring to have table= and column references baked in as referenced, rather than stored as text. = I can't count how many times the dependency tracking on views has stopp= ed me from putting things into an inconsistent state.

I&= #39;ve found a fair few 3rd party tools have, or have had, trouble parsing = and processing functions and procedures that use=C2=A0BEGIN ATOMIC. And, unfortunately, this seems to be = the case with psql too.

My working routines are fairly long, so I've built out a toy exam= ple that I think illustrates the problem. Below are two function definition= s, entered and run from a GUI console:


<= div>
DROP FUNCTION IF EXISTS tell_me_how_plain();
CREATE OR = REPLACE FUNCTION tell_me_how_plain()

RETURNS text

LANGUAGE
S= QL

return 'plain';

END;



DROP FUNCTION
IF EXISTS tools.tell_me_how_atomic();
CREATE OR REPLACE FU= NCTION tools.tell_me_how_atomic()
RETURNS text


LANGUAGE SQL
=
BEGIN ATOMIC

= return 'atomic';
END;

select= * from tell_me_how_plain()= ; -- plain
select * = from tell_me_how_atomic(); -- atomi= c
If I run the script fil=
es from the command line with psql, the tell_me_how_plain.sql function buil=
ds fine, and the tell_me_how_atomic.sql throws a bogus syntax error:
ERROR: =C2=A0syntax error at end of input
LINE 5: return 'at= omic';
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 ^

I've tried usin= g both the -f flag and the path, and the < path option, like so:

=
psql -p 5555 -U postgres -d squid -w -v --echo-all -f "/Use= rs/dpadams2/Desktop/PG_Bug_Tell_Me_How/tell_me_how_atomic.sql"

= psql -p 5555 -U postgres -d squid -w -v --echo-all < "/Users/dpadam= s2/Desktop/PG_Bug_Tell_Me_How/tell_me_how_atomic.sql"

=
I really hope=
 that this is not a bug, and that I'm missing something obvious =
that gets around this error. I noticed in the release notes for 14.7 and 15=
.2
 that there=
 were changes to psql related to BEGIN ATOM=
IC=C2=A0on a =
few flags, but not -f.

Any help appreciated, or a conf=
irmation so that I can stop trying to fix this on my own.

Thanks.

--00000000000083031d05f6c0708e--