From: | Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com> |
---|---|
To: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Error message with plpgsql CONTINUE |
Date: | 2015-08-17 04:19:13 |
Message-ID: | 55D160C1.6040508@BlueTreble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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.
[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
From | Date | Subject | |
---|---|---|---|
Next Message | Neil Conway | 2015-08-17 06:29:57 | Memory allocation in spi_printtup() |
Previous Message | Michael Paquier | 2015-08-17 00:30:50 | Re: TAP tests are badly named |