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.
This commit is contained in:
parent
3dc35ee493
commit
398f754b54
@ -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 @@ err:
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user