Commit 398f754b authored by Michael Widenius's avatar Michael Widenius

Fixed lp:886479 "[PATCH] plugin boolean result"

Thanks to Maarten Vanraes for the patch


sql/sql_plugin.cc:
  Fix plugin boolean variables to receive the value "1", not "-1", when they are set to 1.
  Aside from being bizarre, the existing behavior is unportable: machines where char is unsigned print "255" instead.
parent 3dc35ee4
......@@ -2203,7 +2203,7 @@ static int check_func_bool(THD *thd, struct st_mysql_sys_var *var,
{
if (value->val_int(value, &tmp) < 0)
goto err;
if (tmp > 1)
if (tmp != 0 && tmp != 1)
{
llstr(tmp, buff);
strvalue= buff;
......@@ -2211,7 +2211,7 @@ static int check_func_bool(THD *thd, struct st_mysql_sys_var *var,
}
result= (int) tmp;
}
*(my_bool *) save= -result;
*(my_bool *) save= result ? 1 : 0;
return 0;
err:
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->name, strvalue);
......@@ -2392,7 +2392,7 @@ static int check_func_set(THD *thd, struct st_mysql_sys_var *var,
static void update_func_bool(THD *thd, struct st_mysql_sys_var *var,
void *tgt, const void *save)
{
*(my_bool *) tgt= *(my_bool *) save ? TRUE : FALSE;
*(my_bool *) tgt= *(my_bool *) save ? 1 : 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment