From 398f754b542487d0b2258f47d088eb6c6c2824f7 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 2 Apr 2012 11:45:07 +0300 Subject: [PATCH] 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. --- sql/sql_plugin.cc | 6 +++--- 1 file 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; }