From 5ae2eda776477494af7dfe2cad9d50bb4ad8d9eb Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 20 Jan 2010 12:51:18 +0100 Subject: 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 --- client/mysqltest.cc | 4 ++++ mysql-test/r/mysqltest.result | 6 ++++++ mysql-test/t/mysqltest.test | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 45f94982472..e88414a44e7 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -2661,6 +2661,10 @@ void do_exec(struct st_command *command) #endif #endif + /* exec command is interpreted externally and will not take newlines */ + while(replace(&ds_cmd, "\n", 1, " ", 1) == 0) + ; + DBUG_PRINT("info", ("Executing '%s' as '%s'", command->first_argument, ds_cmd.str)); diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index e77dcd7b0a6..74bf387ec0c 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -216,6 +216,12 @@ source database echo message echo message mysqltest: At line 1: Missing argument in exec +1 +1 +2 +2 +X +3 MySQL "MySQL" MySQL: The diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 45fc0715312..58f66ac814c 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -605,6 +605,15 @@ echo ; --error 1 --exec echo "--exec " | $MYSQL_TEST 2>&1 +# Multi-line exec +exec $MYSQL + test -e "select 1"; +exec $MYSQL test -e "select + 2"; +let $query = select 3 + as X; +exec $MYSQL test -e "$query"; + # ---------------------------------------------------------------------------- # Test let command # ---------------------------------------------------------------------------- -- cgit v1.2.1