semicolon not required on END statement

Started by Hussein Patniover 21 years ago6 messagesbugs
Jump to latest
#1Hussein Patni
security@cosbit.com

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

#2Neil Conway
neilc@samurai.com
In reply to: Hussein Patni (#1)
Re: semicolon not required on END statement

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

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Neil Conway (#2)
Re: semicolon not required on END statement

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

#4Neil Conway
neilc@samurai.com
In reply to: Tom Lane (#3)
Re: semicolon not required on END statement

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
#5Bruce Momjian
bruce@momjian.us
In reply to: Neil Conway (#4)
Re: semicolon not required on END statement

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
#6Neil Conway
neilc@samurai.com
In reply to: Bruce Momjian (#5)
Re: semicolon not required on END statement

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