Обсуждение: Placement of block label in plpgsql block with DECLARE

Поиск
Список
Период
Сортировка

Placement of block label in plpgsql block with DECLARE

От
Tom Lane
Дата:
There's a novice question here
http://archives.postgresql.org/pgsql-novice/2010-03/msg00005.php
that shows up a problem in plpgsql's grammar.  The documentation
states that when a block is labeled, the label must precede the
DECLARE keyword if any:
http://developer.postgresql.org/pgdocs/postgres/plpgsql-structure.html
In the aforementioned question, the user tried to put the label just
before BEGIN, after some variable declarations.  So how come it didn't
throw a syntax error?  Well, when you dig into the grammar, you find out
that it contains an extremely lame attempt to allow the label to be
placed there.  The code doesn't actually work; the label is swallowed
and effectively ignored, as the user's question indicates.  Some quick
testing shows that it never has worked in any version back to 7.0, so
this isn't recent breakage.  If it did work it would create an ambiguity
because there would be multiple possible labels.  As the grammar stands
you can write
<<a>>DECLARE<<b>>x int;<<c>>BEGIN

Try to guess which label is actually active.

Rather than trying to fix this, I think we should just rip it out and
allow only the documented syntax.  Objections?
        regards, tom lane


Re: Placement of block label in plpgsql block with DECLARE

От
"David E. Wheeler"
Дата:
On Mar 2, 2010, at 5:14 PM, Tom Lane wrote:

> Rather than trying to fix this, I think we should just rip it out and
> allow only the documented syntax.  Objections?

+1 If it never worked, seems like a no-brainer.

Best,

David

PS: Do you have builds of 7.0 laying around? Sheesh!



Re: Placement of block label in plpgsql block with DECLARE

От
Tom Lane
Дата:
"David E. Wheeler" <david@kineticode.com> writes:
> PS: Do you have builds of 7.0 laying around? Sheesh!

Use it for testing pg_dump back that far ...
        regards, tom lane