]> granicus.if.org Git - postgresql/commitdiff
Fix bogus list-iteration code in pg_regress.c, affecting ecpg tests only.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 30 Apr 2018 01:56:27 +0000 (21:56 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 30 Apr 2018 01:56:27 +0000 (21:56 -0400)
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.

src/test/regress/pg_regress.c

index abb742b1ed1dec866bb946df46281d3713674ecf..17e982edca9ef5569a977826665719b44aec6979 100644 (file)
@@ -1742,14 +1742,11 @@ run_schedule(const char *schedule, test_function tfunc)
                         */
                        for (rl = resultfiles[i], el = expectfiles[i], tl = tags[i];
                                 rl != NULL;    /* rl and el have the same length */
-                                rl = rl->next, el = el->next)
+                                rl = rl->next, el = el->next,
+                                tl = tl ? tl->next : NULL)
                        {
                                bool            newdiff;
 
-                               if (tl)
-                                       tl = tl->next;  /* tl has the same length as rl and el if
-                                                                        * it exists */
-
                                newdiff = results_differ(tests[i], rl->str, el->str);
                                if (newdiff && tl)
                                {
@@ -1829,14 +1826,11 @@ run_single_test(const char *test, test_function tfunc)
         */
        for (rl = resultfiles, el = expectfiles, tl = tags;
                 rl != NULL;                    /* rl and el have the same length */
-                rl = rl->next, el = el->next)
+                rl = rl->next, el = el->next,
+                tl = tl ? tl->next : NULL)
        {
                bool            newdiff;
 
-               if (tl)
-                       tl = tl->next;          /* tl has the same length as rl and el if it
-                                                                * exists */
-
                newdiff = results_differ(test, rl->str, el->str);
                if (newdiff && tl)
                {