Re: why semicolon after begin is not allowed in postgresql?
От | Kevin Grittner |
---|---|
Тема | Re: why semicolon after begin is not allowed in postgresql? |
Дата | |
Msg-id | 1385160186.72261.YahooMailNeo@web162902.mail.bf1.yahoo.com обсуждение исходный текст |
Ответ на | why semicolon after begin is not allowed in postgresql? (AK <alkuzo@gmail.com>) |
Ответы |
Re: why semicolon after begin is not allowed in postgresql?
|
Список | pgsql-hackers |
AK <alkuzo@gmail.com> 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? I think it only seems confusing because PostgreSQL also uses BEGIN as a synonym for START TRANSACTION (and people tend to use the shorter synonym to save keystrokes). In plpgsql BEGIN is not a command, it is part of declaring a code block. Wouldn't these look funny to you?: IF x = 1 THEN; ... END IF; CASE; WHEN x = 1 THEN ... WHEN x = 2 THEN ... ELSE ... END; LOOP; ... END LOOP; etc. Why should BEGIN be different from the above when it is not a command, but part of declaring a code block? In the nearest analog in the SQL standard, the BEGIN/END block is called a compound statement, and like any other statement it is ended by a semicolon; the standard does not allow a semicolon after the BEGIN. -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
В списке pgsql-hackers по дате отправления: