1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-21 12:05:57 +03:00

Fix backstop in gin test if injection point is not reached

Per Tom Lane's observation that the test got stuck in infinite loop if
the injection_points module was not loaded. It was supposed to give up
after 10000 iterations, but the backstop was broken.

Discussion: https://www.postgresql.org/message-id/2498595.1710511222%40sss.pgh.pa.us
This commit is contained in:
Heikki Linnakangas 2024-03-15 17:55:12 +02:00
parent 85f65d7a26
commit d802ff06d0
2 changed files with 6 additions and 4 deletions

View File

@ -45,6 +45,7 @@ declare
i integer; i integer;
begin begin
-- Insert arrays with 'step' elements each, until an error occurs. -- Insert arrays with 'step' elements each, until an error occurs.
i := 0;
loop loop
begin begin
select insert_n(next_i, step) into next_i; select insert_n(next_i, step) into next_i;
@ -53,12 +54,12 @@ begin
exit; exit;
end; end;
-- The caller is expected to set an injection point that eventuall -- The caller is expected to set an injection point that eventually
-- causes an error. But bail out if still no error after 10000 -- causes an error. But bail out if still no error after 10000
-- attempts, so that we don't get stuck in an infinite loop. -- attempts, so that we don't get stuck in an infinite loop.
i := i + 1; i := i + 1;
if i = 10000 then if i = 10000 then
raise 'no error on inserts after '; raise 'no error on inserts after % iterations', i;
end if; end if;
end loop; end loop;

View File

@ -48,6 +48,7 @@ declare
i integer; i integer;
begin begin
-- Insert arrays with 'step' elements each, until an error occurs. -- Insert arrays with 'step' elements each, until an error occurs.
i := 0;
loop loop
begin begin
select insert_n(next_i, step) into next_i; select insert_n(next_i, step) into next_i;
@ -56,12 +57,12 @@ begin
exit; exit;
end; end;
-- The caller is expected to set an injection point that eventuall -- The caller is expected to set an injection point that eventually
-- causes an error. But bail out if still no error after 10000 -- causes an error. But bail out if still no error after 10000
-- attempts, so that we don't get stuck in an infinite loop. -- attempts, so that we don't get stuck in an infinite loop.
i := i + 1; i := i + 1;
if i = 10000 then if i = 10000 then
raise 'no error on inserts after '; raise 'no error on inserts after % iterations', i;
end if; end if;
end loop; end loop;