Re: BUG #18403: PL/pgSQL is reporting unexpected errors when processing DECLARE blocks with <<label>>

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: jiangshan(dot)liu(at)tju(dot)edu(dot)cn, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18403: PL/pgSQL is reporting unexpected errors when processing DECLARE blocks with <<label>>
Date: 2024-03-20 20:37:00
Message-ID: CAFj8pRAzg6E+6Wwxo+WfoYdDAg1Eb=fR_wvJWZa_7hZwvUX0MQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

st 20. 3. 2024 v 20:59 odesílatel PG Bug reporting form <
noreply(at)postgresql(dot)org> napsal:

> The following bug has been logged on the website:
>
> Bug reference: 18403
> Logged by: Jiangshan Liu
> Email address: jiangshan(dot)liu(at)tju(dot)edu(dot)cn
> PostgreSQL version: 15.2
> Operating system: Ubuntu
> Description:
>
> Hi, I think PL/pgSQL is reporting unexpected errors when dealing with
> DECLARE blocks paired with <<label>>.
> I have approximated the program to a clean situation. When I execute this
> program, the PL/pgSQL engine does not report errors to me:
>
> DO $$
> DECLARE
> DECLARE
> var1 INT = 1;
> BEGIN
> RAISE NOTICE '%', var1;
> END;
> $$;
>
> But when I try to add <<label>> before the second DECLARE block, the
> PL/pgSQL engine prompts me with this error message:
>
> DO $$
> DECLARE
> <<label>>
> DECLARE
> var1 INT = 1;
> BEGIN
> RAISE NOTICE '%', var1;
> END;
> $$;
>
> > ERROR: block label must be placed before DECLARE, not after
> LINE 3: <<label>>
> ^
>
> It seems to think that I am adding <<label>> after the first DECLARE block,
> which is not my intention. I do add the <<label>> before the second DECLARE
> block. Why is this program being reported as an error? Is this a bug in
> PL/pgSQL's handling of <<label>>?
>
> Looking forward and thank you for your response to this question.
>

There cannot be labels between DECLARE keywords. The label in this case is
not related to DECLARE, but to the following BEGIN END block.

Regards

Pavel

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2024-03-20 20:47:52 BUG #18403: PL/pgSQL is reporting unexpected errors when processing DECLARE blocks with <<label>>
Previous Message Bruce Momjian 2024-03-20 19:42:16 Re: Regression tests fail with musl libc because libpq.so can't be loaded