summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjorn Munch <bjorn.munch@oracle.com>2010-11-17 16:05:52 +0100
committerBjorn Munch <bjorn.munch@oracle.com>2010-11-17 16:05:52 +0100
commit32ea070845fd4196ad5d9e5ffc4ce64b736c9869 (patch)
treecb93bdacc84cdb965cb9a52dd76b5290ba5b5ffd
parent92a1a112030452b375684e2b8633de0a32dc0912 (diff)
downloadmariadb-git-32ea070845fd4196ad5d9e5ffc4ce64b736c9869.tar.gz
Bug #58257 mysqltest: in if(), ! $var with space is always false
Evaluation would start with the space and thus ignore the $ Added while() to skip past white space
-rw-r--r--client/mysqltest.cc4
-rw-r--r--mysql-test/r/mysqltest.result2
-rw-r--r--mysql-test/t/mysqltest.test9
3 files changed, 14 insertions, 1 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 9fc692d0d04..b2fcb8fe39e 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -5434,7 +5434,9 @@ void do_block(enum block_cmd cmd, struct st_command* command)
if (*expr_start == '!')
{
not_expr= TRUE;
- expr_start++; /* Step past the '!' */
+ expr_start++; /* Step past the '!', then any whitespace */
+ while (*expr_start && my_isspace(charset_info, *expr_start))
+ expr_start++;
}
/* Find ending ')' */
expr_end= strrchr(expr_start, ')');
diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result
index f22a18057c3..013728ebd01 100644
--- a/mysql-test/r/mysqltest.result
+++ b/mysql-test/r/mysqltest.result
@@ -402,7 +402,9 @@ true-inner
true-inner again
true-outer
Counter is greater than 0, (counter=10)
+Counter should still be 10, is 10
Counter is not 0, (counter=0)
+Not space var works
Counter is true, (counter=alpha)
Beta is true
while with string, only once
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index 59ff70e1591..fe04b8c19e0 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -1138,6 +1138,11 @@ if (!$counter)
{
echo Counter is not 0, (counter=10);
}
+if (! $counter)
+{
+ let $counter=5;
+}
+echo Counter should still be 10, is $counter;
let $counter=0;
if($counter)
{
@@ -1147,6 +1152,10 @@ if (!$counter)
{
echo Counter is not 0, (counter=0);
}
+if (! $counter)
+{
+ echo Not space var works;
+}
# ----------------------------------------------------------------------------
# Test if with some non-numerics