Re: Error message with plpgsql CONTINUE

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Error message with plpgsql CONTINUE
Date: 2015-08-17 06:46:46
Message-ID: CAFj8pRAcEiBxLiYW-UkuSYDX4J-Fx8ohs16n-cFiT9ngE0PjOg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2015-08-17 6:19 GMT+02:00 Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>:

> Calling CONTINUE with a label that's not a loop produces an error message
> with no context info [1]. This is because of
>
> rc = exec_stmt_block(&estate, func->action);
> if (rc != PLPGSQL_RC_RETURN)
> {
> estate.err_stmt = NULL;
> estate.err_text = NULL;
>
> I trawled through git blame a bit and it looks like it's been that way for
> a very long time.
>
> I think err_stmt should probably only be reset in the non-return case a
> bit below that. I'm not sure about err_text though. Also, the code treats
> PLPGSQL_RC_OK and PLPGSQL_RC_EXIT the same, which seems like a bug; I would
> think PLPGSQL_RC_EXIT should be handled the same way as CONTINUE.
>
> If someone can confirm this and tell me what to do about err_text I'll
> submit a patch.
>

maybe "during function exit" ?

Regards

Pavel

>
> [1]
> decibel(at)decina(dot)attlocal/50703=# do $$
> begin
> <<outer>>
> for a in 1..3 loop
> <<sub>>
> BEGIN
> <<inner>>
> for b in 8..9 loop
> if a=2 then
> continue sub;
> end if;
> raise notice '% %', a, b;
> end loop inner;
> END sub;
> end loop outer;
> end;
> $$;
> NOTICE: 1 8
> NOTICE: 1 9
> ERROR: CONTINUE cannot be used outside a loop
> CONTEXT: PL/pgSQL function inline_code_block
> decibel(at)decina(dot)attlocal/50703=#
>
> [2]
> https://github.com/postgres/postgres/blob/83604cc42353b6c0de2a3f3ac31f94759a9326ae/src/pl/plpgsql/src/pl_exec.c#L438
> --
> Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
> Data in Trouble? Get it in Treble! http://BlueTreble.com
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2015-08-17 06:49:35 Re: Potential GIN vacuum bug
Previous Message Heikki Linnakangas 2015-08-17 06:36:28 Re: Configure checks and optimizations/crc32 tests