summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorBjorn Munch <bjorn.bunch@oracle.com>2010-08-05 14:41:07 +0200
committerBjorn Munch <bjorn.bunch@oracle.com>2010-08-05 14:41:07 +0200
commit489e6c136b93bf0c8aba34ef5c212fcbda5b8581 (patch)
treec031d5dd411d0530740a75f91cd2ccd08a132629 /client
parent3cd9a145e32810103f928f270f830785f87a9f3a (diff)
parent992f49c0c47241f51588c74d0f018f6140a6ff1b (diff)
downloadmariadb-git-489e6c136b93bf0c8aba34ef5c212fcbda5b8581.tar.gz
upmerge 55582
Diffstat (limited to 'client')
-rw-r--r--client/mysqltest.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 18fcbe11a60..459e70bc5ab 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -2440,6 +2440,9 @@ void eval_expr(VAR *v, const char *p, const char **p_end)
if ((vp= var_get(p, p_end, 0, 0)))
var_copy(v, vp);
+ /* Apparently it is not safe to assume null-terminated string */
+ v->str_val[v->str_val_len]= 0;
+
/* Make sure there was just a $variable and nothing else */
const char* end= *p_end + 1;
if (end < expected_end)
@@ -5426,8 +5429,20 @@ void do_block(enum block_cmd cmd, struct st_command* command)
/* Define inner block */
cur_block++;
cur_block->cmd= cmd;
- cur_block->ok= (v.int_val ? TRUE : FALSE);
+ if (v.int_val)
+ {
+ cur_block->ok= TRUE;
+ } else
+ /* Any non-empty string which does not begin with 0 is also TRUE */
+ {
+ p= v.str_val;
+ /* First skip any leading white space or unary -+ */
+ while (*p && ((my_isspace(charset_info, *p) || *p == '-' || *p == '+')))
+ p++;
+ cur_block->ok= (*p && *p != '0') ? TRUE : FALSE;
+ }
+
if (not_expr)
cur_block->ok = !cur_block->ok;