Skip to content

Commit 8109a3c

Browse files
committed
Fix bogus list-iteration code in pg_regress.c, affecting ecpg tests only.
While looking at a recent buildfarm failure in the ecpg tests, I wondered why the pg_regress output claimed the stderr part of the test failed, when the regression diffs were clearly for the stdout part. Looking into it, the reason is that pg_regress.c's logic for iterating over three parallel lists is wrong, and has been wrong since it was written: it advances the "tag" pointer at a different place in the loop than the other two pointers. Fix that.
1 parent 59c2df3 commit 8109a3c

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/test/regress/pg_regress.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,14 +1899,11 @@ run_schedule(const char *schedule, test_function tfunc)
18991899
*/
19001900
for (rl = resultfiles[i], el = expectfiles[i], tl = tags[i];
19011901
rl != NULL; /* rl and el have the same length */
1902-
rl = rl->next, el = el->next)
1902+
rl = rl->next, el = el->next,
1903+
tl = tl ? tl->next : NULL)
19031904
{
19041905
bool newdiff;
19051906

1906-
if (tl)
1907-
tl = tl->next; /* tl has the same length as rl and el
1908-
* if it exists */
1909-
19101907
newdiff = results_differ(tests[i], rl->str, el->str);
19111908
if (newdiff && tl)
19121909
{
@@ -1986,14 +1983,11 @@ run_single_test(const char *test, test_function tfunc)
19861983
*/
19871984
for (rl = resultfiles, el = expectfiles, tl = tags;
19881985
rl != NULL; /* rl and el have the same length */
1989-
rl = rl->next, el = el->next)
1986+
rl = rl->next, el = el->next,
1987+
tl = tl ? tl->next : NULL)
19901988
{
19911989
bool newdiff;
19921990

1993-
if (tl)
1994-
tl = tl->next; /* tl has the same length as rl and el if it
1995-
* exists */
1996-
19971991
newdiff = results_differ(test, rl->str, el->str);
19981992
if (newdiff && tl)
19991993
{

0 commit comments

Comments
 (0)