Bug #49837 mysqltest exec cannot handle multi-line command correctly
Submitted: 21 Dec 2009 6:13 Modified: 17 Jun 2010 19:39
Reporter: Zhenxing He Email Updates:
Status: Closed Impact on me:
None 
Category:Tools: MTR / mysql-test-run Severity:S3 (Non-critical)
Version:5.0,5.1,6.0 OS:Any
Assigned to: Bjørn Munch CPU Architecture:Any

[21 Dec 2009 6:13] Zhenxing He
Description:
mysqltest 'exec' cannot handle command correctly when it was written in multi-line. For example the following will pass on Unix systems, but will fail on Windows systems:

----------------------------------------------------------------
create table t1 (a int);
insert into t1 values (1),(2),(3);
exec $MYSQL test -e "select a
     from t1";

let $query = select a
    from t1;
exec $MYSQL test -e "$query";
-----------------------------------------------------------------

ERROR 1054 <42S22> at line 1: Unkown column 'a' in 'field list'

And this will fail on all platforms:

-----------------------------------------------------------------
create table t1 (a int);
insert into t1 values (1),(2),(3);
exec $MYSQL test -e
   "select a from t1";
-----------------------------------------------------------------

mysql: option '-e' requires an argument
sh: select a from t1: not found
mysqltest: At line 25: command "$MYSQL test -e
"select a from t1"" failed

Workaround is to always write the command line in a single line for exec command.

How to repeat:
See description.

Suggested fix:
Make 'exec' handles multi-line command correctly and behaves the same on all platforms.
[21 Dec 2009 6:15] Zhenxing He
See also Bug#47638
[21 Dec 2009 11:48] MySQL Verification Team
Thank you for the bug report.

insert into t1 values (1),(2),(3);
main.bugtest                             [ fail ]
        Test ended at 2009-12-21 09:46:34

CURRENT_TEST: main.bugtest
ERROR 1054 (42S22) at line 1: Unknown column 'a' in 'field list'
mysqltest: At line 3: command "$MYSQL test -e "select a
     from t1"" failed
[13 Jan 2010 10:23] 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/96713

2876 Bjorn Munch	2010-01-13
      Bug #49837 mysqltest exec cannot handle multi-line command correctly
      Since the exec command line is passed on externally, it cannot take newlines
      Simply replace \n with space
      Also tested with the example cases on Windows
[19 Jan 2010 16:45] Magnus Blåudd
Shouldn't it return an error instead of silently ignoring?
or
Shouldn't it be properly quoted?

If the user intentionally has written a newline it must mean something...
[19 Jan 2010 16:55] Bjørn Munch
To the last comment: no, the user (test writer) is used to being able to write multi-line SQL or mysqltest commands without quoting, it's counter-intuitive that this doesn't work with exec.

mysqltest itself ignores newlines while parsing commands, but with exec the entire command is passed on to some external program which can *not* be expected to ignore them the same way. Hence the pre-filtering.
[20 Jan 2010 11:53] 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/97539

2878 Bjorn Munch	2010-01-20
      Bug #49837 mysqltest exec cannot handle multi-line command correctly
      Since the exec command line is passed on externally, it cannot take newlines
      Simply replace \n with space
      Now also added test case
[20 Jan 2010 15:52] Bjørn Munch
Pushed to 5.1-mtr, trunk-mtr, next-mr-mtr, 6.0-codebase-mtr
[20 Jan 2010 15:53] Bjørn Munch
Sorry mouso, wrong status
[20 Feb 2010 9:32] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100220092844-jh07ayojyxn8uh9p) (version source revid:bjorn.munch@sun.com-20100120153513-b70e3bs7e06jfvf3) (merge vers: 6.0.14-alpha) (pib:16)
[20 Feb 2010 9:35] Bugs System
Pushed into 5.5.3-m2 (revid:alik@sun.com-20100220092622-wvhh1vfy5tjq4mhu) (version source revid:bjorn.munch@sun.com-20100120133748-0aiuazzbcqje8my0) (merge vers: 5.5.1-m2) (pib:16)
[20 Feb 2010 9:38] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100220092730-paoo5t9gcajs5dq8) (version source revid:bjorn.munch@sun.com-20100120154314-icr9oiinm588c3sk) (pib:16)
[23 Feb 2010 2:14] Paul DuBois
Changes to test suite. No changelog entry needed.

Setting report to Need Merge pending push to 5.1.x, Celosia.
[1 Mar 2010 8:42] Bugs System
Pushed into 5.1.45 (revid:joro@sun.com-20100301083827-xnimmrjg6bh33o1o) (version source revid:azundris@mysql.com-20100222175719-viuh0f3gdsrkgv0r) (merge vers: 5.1.45) (pib:16)
[1 Mar 2010 16:35] Paul DuBois
No changelog entry needed.
[17 Jun 2010 11:45] Bugs System
Pushed into 5.1.47-ndb-7.0.16 (revid:martin.skold@mysql.com-20100617114014-bva0dy24yyd67697) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 12:23] Bugs System
Pushed into 5.1.47-ndb-6.2.19 (revid:martin.skold@mysql.com-20100617115448-idrbic6gbki37h1c) (version source revid:martin.skold@mysql.com-20100609140708-52rvuyq4q500sxkq) (merge vers: 5.1.45-ndb-6.2.19) (pib:16)
[17 Jun 2010 13:10] Bugs System
Pushed into 5.1.47-ndb-6.3.35 (revid:martin.skold@mysql.com-20100617114611-61aqbb52j752y116) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)