summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2012-04-02 11:45:07 +0300
committerMichael Widenius <monty@askmonty.org>2012-04-02 11:45:07 +0300
commit398f754b542487d0b2258f47d088eb6c6c2824f7 (patch)
treee910b3604fac571bd71b291bf5078af8b6fe2b9c
parent3dc35ee493711f084efa682d2c8a3ba6780f6297 (diff)
downloadmariadb-git-398f754b542487d0b2258f47d088eb6c6c2824f7.tar.gz
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.
-rw-r--r--sql/sql_plugin.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 5b7c2d285e6..1547e576eca 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -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;
}