Bug #41913 mysqltest cannot source files from if inside while
Submitted: 7 Jan 2009 7:52 Modified: 18 Dec 2009 13:19
Reporter: Sven Sandberg Email Updates:
Status: Closed Impact on me:
None 
Category:Tools: MTR / mysql-test-run Severity:S7 (Test Cases)
Version:4.1+ OS:Any
Assigned to: Bjørn Munch CPU Architecture:Any
Tags: mysqltest

[7 Jan 2009 7:52] Sven Sandberg
Description:
If a test file contains a 'source' command inside an 'if' inside a 'while', and the 'if' evaluates to false the first loop iteration, and the 'if' evaluates to true later, then the 'source' command will be silently ignored.

The reason is that the condition 'parser.current_line < (parser.read_lines - 1)' in do_source() in mysqltest.cc evaluates to false inside loops, except the first iteration.

How to repeat:
$ cat t/bug.test

let $x= 2;
let $y= 1;
while ($x) {
  --echo x=$x y=$y
  if (!$y) {
    --echo will now source include/test.inc
    source include/test.inc;
    --echo done!
  }
  dec $x;
  dec $y;
}

$ cat include/test.inc

--echo testing

$ ./mtr bug
[...]
x=2 y=1
x=1 y=0
will now source include/test.inc
done!
[13 Jul 2009 12:39] Sven Sandberg
BUG#32296 seems related.
[28 Jul 2009 10:24] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/79391

2810 Bjorn Munch	2009-07-28
      Bug #41913 mysqltest cannot source files from if inside while
      Source within if within while is ignored if the if is false on first iteration
      Fixed by forcing source even if inside a false if
[29 Jul 2009 13:06] Bjørn Munch
It turned out that Bug #32296 needed almost the same change as this (plus some more), but it was better to do it in a different way. I will therefore commit a patch for that bug which includes the fix for this one. Currently being tested.
[29 Jul 2009 13:36] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/79530

2810 Bjorn Munch	2009-07-29
      Bug #32296 mysqltest fails to parse "append_file" inside a "while", it works inside a "if"
      Bug #41913 mysqltest cannot source files from if inside while
      Some commands require additional processing which only works first time
      Keep content for write_file or append_file with the st_command struct
[31 Aug 2009 12:06] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/81994

2826 Bjorn Munch	2009-08-31
      Bug #32296 mysqltest fails to parse "append_file" inside a "while", it works inside a "if"
      Bug #41913 mysqltest cannot source files from if inside while
      Some commands require additional processing which only works first time
      Keep content for write_file or append_file with the st_command struct
      Add tests for those cases to mysqltest.test
[2 Sep 2009 9:18] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/82187

2830 Bjorn Munch	2009-09-02
      Bug #32296 mysqltest fails to parse "append_file" inside a "while", it works inside
      a "if"
      Bug #41913 mysqltest cannot source files from if inside while
      Some commands require additional processing which only works first time
      Keep content for write_file or append_file with the st_command struct
      Add tests for those cases to mysqltest.test
[2 Sep 2009 10:46] Bjørn Munch
Patch was reviewed with Bug #32296.

Pushed to azalea-mtr (soon named next-mtr) and 5.1-mtr
[3 Sep 2009 17:12] Bugs System
Pushed into 5.1.40 (revid:bjorn.munch@sun.com-20090903170735-679d64zp580wl39j) (version source revid:bjorn.munch@sun.com-20090903170735-679d64zp580wl39j) (merge vers: 5.1.40) (pib:11)
[4 Sep 2009 0:49] Paul DuBois
Test suite change. No changelog entry needed.

Setting report to NDI pending push into 5.4.x.
[30 Sep 2009 8:16] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20090929093622-1mooerbh12e97zux) (version source revid:alik@sun.com-20090922182109-vs5ign07cwht12z6) (merge vers: 6.0.14-alpha) (pib:11)
[30 Sep 2009 8:20] Bugs System
Pushed into 5.4.5-beta (revid:alik@sun.com-20090925094254-tjl9eajkzwzgthoe) (version source revid:alik@sun.com-20090922142453-x275o41whpyezh4q) (merge vers: 5.4.4-beta) (pib:11)
[30 Sep 2009 19:37] Paul DuBois
Test suite change. No changelog entry needed.
[18 Dec 2009 10:34] Bugs System
Pushed into 5.1.41-ndb-7.1.0 (revid:jonas@mysql.com-20091218102229-64tk47xonu3dv6r6) (version source revid:jonas@mysql.com-20091218095730-26gwjidfsdw45dto) (merge vers: 5.1.41-ndb-7.1.0) (pib:15)
[18 Dec 2009 10:49] Bugs System
Pushed into 5.1.41-ndb-6.2.19 (revid:jonas@mysql.com-20091218100224-vtzr0fahhsuhjsmt) (version source revid:jonas@mysql.com-20091217101452-qwzyaig50w74xmye) (merge vers: 5.1.41-ndb-6.2.19) (pib:15)
[18 Dec 2009 11:04] Bugs System
Pushed into 5.1.41-ndb-6.3.31 (revid:jonas@mysql.com-20091218100616-75d9tek96o6ob6k0) (version source revid:jonas@mysql.com-20091217154335-290no45qdins5bwo) (merge vers: 5.1.41-ndb-6.3.31) (pib:15)
[18 Dec 2009 11:19] Bugs System
Pushed into 5.1.41-ndb-7.0.11 (revid:jonas@mysql.com-20091218101303-ga32mrnr15jsa606) (version source revid:jonas@mysql.com-20091218064304-ezreonykd9f4kelk) (merge vers: 5.1.41-ndb-7.0.11) (pib:15)
[18 Dec 2009 13:19] Paul DuBois
Test suite change. No changelog entry needed.