mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-11 23:07:45 +08:00
Fix bug in CONTINUE statement for PL/pgSQL: when we continue a loop,
we need to be careful to reset rc to PLPGSQL_RC_OK, depending on how the loop's logic is structured. If we continue a loop but it then exits without executing the loop's body again, we want to return PLPGSQL_RC_OK to our caller. Enhance the regression tests to catch this problem. Per report from Michael Fuhr.
This commit is contained in:
@ -2169,7 +2169,33 @@ begin
|
||||
for _r in execute 'select * from conttesttbl' loop
|
||||
continue when _r.v <= 20;
|
||||
raise notice '%', _r.v;
|
||||
end loop;
|
||||
end loop;
|
||||
|
||||
raise notice '---7---';
|
||||
for _i in 1..3 loop
|
||||
raise notice '%', _i;
|
||||
continue when _i = 3;
|
||||
end loop;
|
||||
|
||||
raise notice '---8---';
|
||||
_i := 1;
|
||||
while _i <= 3 loop
|
||||
raise notice '%', _i;
|
||||
_i := _i + 1;
|
||||
continue when _i = 3;
|
||||
end loop;
|
||||
|
||||
raise notice '---9---';
|
||||
for _r in select * from conttesttbl order by v limit 1 loop
|
||||
raise notice '%', _r.v;
|
||||
continue;
|
||||
end loop;
|
||||
|
||||
raise notice '---10---';
|
||||
for _r in execute 'select * from conttesttbl order by v limit 1' loop
|
||||
raise notice '%', _r.v;
|
||||
continue;
|
||||
end loop;
|
||||
end; $$ language plpgsql;
|
||||
|
||||
select continue_test1();
|
||||
|
||||
Reference in New Issue
Block a user