Re: why semicolon after begin is not allowed in postgresql?

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: AK <alkuzo(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: why semicolon after begin is not allowed in postgresql?
Date: 2013-11-22 22:44:48
Message-ID: 528FDE60.40300@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 11/22/2013 05:24 PM, AK wrote:
> I am reading the following in the documentation: "Tip: A common mistake is to
> write a semicolon immediately after BEGIN. This is incorrect and will result
> in a syntax error."
>
> So, "common mistake" means semicolons after BEGIN seem consistent to many
> people - it seems consistent to me as well. If PostgreSql allowed them, we
> would have one less rule to memorize, shorter documentation, less mistakes
> and so on. In other words, without this limitation PostgreSql would be
> slightly more useful, right?
>
> What am I missing? Why do we need this rule? How is it making PostgreSql
> better?
>
>
>

You're referring specifically to plpgsql, not to Postgres or SQL generally.

plpgsql is derived from PLSQL which is derived from Ada which has this
grammatical rule.

The explanation is this: only complete statements are followed by
semicolons. But in these languages, "begin" on its own is not a complete
statement. It's the start of a compound statement, the end of which will
be "end", which is indeed followed by a semicolon.

cheers

andrew

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2013-11-22 22:46:15 Re: Patch for fail-back without fresh backup
Previous Message Kevin Grittner 2013-11-22 22:43:06 Re: why semicolon after begin is not allowed in postgresql?