semicolon not required on END statement
Hello,
I noticed in plpgsql that a semi colon is not always required
after
the END statement. A contrived example:
CREATE sequence foo;
CREATE OR REPLACE FUNCTION bar() RETURNS VOID AS '
DECLARE
bar int;
BEGIN
SELECT INTO bar nextval(''foo'');
RETURN;
END
' LANGUAGE plpgsql;
--hussein
On Fri, 2004-10-01 at 01:11, Hussein Patni wrote:
I noticed in plpgsql that a semi colon is not always requiredafter
the END statement.
Yeah, I've noticed this as well (although it doesn't appear to be
documented). Would we gain anything by enforcing this restriction? IMHO
not a lot...
-Neil
Neil Conway <neilc@samurai.com> writes:
On Fri, 2004-10-01 at 01:11, Hussein Patni wrote:
I noticed in plpgsql that a semi colon is not always requiredafter
the END statement.
Yeah, I've noticed this as well (although it doesn't appear to be
documented). Would we gain anything by enforcing this restriction? IMHO
not a lot...
We specifically do not require a semicolon at the very end of the
function definition. My recollection is that the plpgsql grammar did
originally enforce that, and we relaxed it because it confused people.
You have to admit that
... END;';
is a bit odd-looking.
regards, tom lane
On Fri, 2004-10-01 at 13:46, Tom Lane wrote:
We specifically do not require a semicolon at the very end of the
function definition.
Yeah, makes sense. Attached is a doc patch. Barring any objections I'll
apply it to HEAD by end-of-day today.
-Neil
Attachments:
plpgsql-end-semicolon-doc-1.patchtext/x-patch; charset=iso-8859-1; name=plpgsql-end-semicolon-doc-1.patchDownload+4-4
Improved wording that doesn't telegraph, "Look at me!":
Each declaration and each statement within a block is terminated by a
semicolon, though the final <literal>END</literal> that concludes a
function does not require one.
---------------------------------------------------------------------------
Neil Conway wrote:
On Fri, 2004-10-01 at 13:46, Tom Lane wrote:
We specifically do not require a semicolon at the very end of the
function definition.Yeah, makes sense. Attached is a doc patch. Barring any objections I'll
apply it to HEAD by end-of-day today.-Neil
[ Attachment, skipping... ]
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Bruce Momjian wrote:
Improved wording that doesn't telegraph, "Look at me!":
Each declaration and each statement within a block is terminated by a
semicolon, though the final <literal>END</literal> that concludes a
function does not require one.
Patch applied.
-Neil