Fix backstop in gin test if injection point is not reached
authorHeikki Linnakangas <[email protected]>
Fri, 15 Mar 2024 15:55:12 +0000 (17:55 +0200)
committerHeikki Linnakangas <[email protected]>
Fri, 15 Mar 2024 15:55:12 +0000 (17:55 +0200)
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

src/test/modules/gin/expected/gin_incomplete_splits.out
src/test/modules/gin/sql/gin_incomplete_splits.sql

index 9a60f8c128afd6f0733287615778f09389530bac..822b78cffc41dc42f6f49266c31ceb55b5fe3af0 100644 (file)
@@ -45,6 +45,7 @@ declare
   i integer;
 begin
   -- Insert arrays with 'step' elements each, until an error occurs.
+  i := 0;
   loop
     begin
       select insert_n(next_i, step) into next_i;
@@ -53,12 +54,12 @@ begin
       exit;
     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
     -- attempts, so that we don't get stuck in an infinite loop.
     i := i + 1;
     if i = 10000 then
-      raise 'no error on inserts after ';
+      raise 'no error on inserts after % iterations', i;
     end if;
   end loop;
 
index 4e180b251954747e563abeb0c0f7c65b8252c28a..71253b71f3d0132081dfd95c2dcc4560f68acbab 100644 (file)
@@ -48,6 +48,7 @@ declare
   i integer;
 begin
   -- Insert arrays with 'step' elements each, until an error occurs.
+  i := 0;
   loop
     begin
       select insert_n(next_i, step) into next_i;
@@ -56,12 +57,12 @@ begin
       exit;
     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
     -- attempts, so that we don't get stuck in an infinite loop.
     i := i + 1;
     if i = 10000 then
-      raise 'no error on inserts after ';
+      raise 'no error on inserts after % iterations', i;
     end if;
   end loop;