2015-08-17 6:19 GMT+02:00 Jim Nasby <jim.na...@bluetreble.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@decina.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@decina.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@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

Reply via email to