Commit 5aa6e861 authored by unknown's avatar unknown

Post-review fixes for bug #20924


mysql-test/r/case.result:
  Post-review fix for bug #20924
mysql-test/r/func_if.result:
  Post-review fix for bug #20924
mysql-test/r/func_test.result:
  Post-review fix for bug #20924
mysql-test/r/user_var.result:
  Post-review fix for bug #20924
mysql-test/t/case.test:
  Post-review fix for bug #20924
mysql-test/t/func_if.test:
  Post-review fix for bug #20924
mysql-test/t/func_test.test:
  Post-review fix for bug #20924
mysql-test/t/user_var.test:
  Post-review fix for bug #20924
sql/item_func.cc:
  Post-review fix for bug #20924
sql/item_func.h:
  Post-review fix for bug #20924
sql/log_event.cc:
  Post-review fix for bug #20924
parent f64483cb
......@@ -183,3 +183,4 @@ CASE 1 WHEN 1 THEN 18446744073709551615 ELSE 1 END
SELECT COALESCE(18446744073709551615);
COALESCE(18446744073709551615)
18446744073709551615
End of 4.1 tests
......@@ -105,3 +105,4 @@ IF(1 != 0, 18446744073709551615, 1)
SELECT IFNULL(NULL, 18446744073709551615);
IFNULL(NULL, 18446744073709551615)
18446744073709551615
End of 4.1 tests
......@@ -189,3 +189,4 @@ GREATEST(1, 18446744073709551615)
SELECT LEAST(1, 18446744073709551615);
LEAST(1, 18446744073709551615)
1
End of 4.1 tests
......@@ -207,3 +207,4 @@ set @a=18446744073709551615;
select @a;
@a
18446744073709551615
End of 4.1 tests
......@@ -131,9 +131,11 @@ from t1 where b=3 group by b;
drop table t1;
#
# Bug #20924: UNSIGNED values in CASE and COALESCE are treated as SIGNED
# Bug #20924: CAST(expr as UNSIGNED) returns SIGNED value when used in various
# functions
# - UNSIGNED values in CASE and COALESCE are treated as SIGNED
#
SELECT CASE 1 WHEN 1 THEN 18446744073709551615 ELSE 1 END;
SELECT COALESCE(18446744073709551615);
# End of 4.1 tests
--echo End of 4.1 tests
......@@ -74,13 +74,17 @@ SELECT a, NULLIF(a,'') FROM t1 WHERE NULLIF(a,'') IS NULL;
DROP TABLE t1;
#
# Bug #20924: UNSIGNED values in IF() are treated as SIGNED
# Bug #20924: CAST(expr as UNSIGNED) returns SIGNED value when used in various
# functions
# - UNSIGNED values in IF() are treated as SIGNED
#
SELECT IF(1 != 0, 18446744073709551615, 1);
#
# Bug #20924: UNSIGNED values in IFNULL() are treated as SIGNED
# Bug #20924: CAST(expr as UNSIGNED) returns SIGNED value when used in various
# functions
# - UNSIGNED values in IFNULL() are treated as SIGNED
#
SELECT IFNULL(NULL, 18446744073709551615);
# End of 4.1 tests
--echo End of 4.1 tests
......@@ -109,9 +109,11 @@ select 5.1 mod 3, 5.1 mod -3, -5.1 mod 3, -5.1 mod -3;
select 5 mod 3, 5 mod -3, -5 mod 3, -5 mod -3;
#
# Bug #20924: UNSIGNED values in GREATEST() and LEAST() are treated as SIGNED
# Bug #20924: CAST(expr as UNSIGNED) returns SIGNED value when used in various
# functions
# - UNSIGNED values in GREATEST() and LEAST() are treated as SIGNED
#
SELECT GREATEST(1, 18446744073709551615);
SELECT LEAST(1, 18446744073709551615);
# End of 4.1 tests
--echo End of 4.1 tests
......@@ -142,9 +142,11 @@ select @@global.version;
select @@session.VERSION;
#
# Bug #20924 SET on a user variable saves UNSIGNED as SIGNED
# Bug #20924: CAST(expr as UNSIGNED) returns SIGNED value when used in various
# functions
# - SET on a user variable saves UNSIGNED as SIGNED
#
set @a=18446744073709551615;
select @a;
# End of 4.1 tests
--echo End of 4.1 tests
......@@ -1252,8 +1252,7 @@ longlong Item_func_min_max::val_int()
{
if (args[i]->null_value)
continue;
if (unsigned_flag && arg_unsigned_flag ||
(!unsigned_flag && !arg_unsigned_flag))
if (unsigned_flag == arg_unsigned_flag)
cmp= tmp < value;
else if (unsigned_flag)
cmp= compare_int_signed_unsigned(tmp, value) < 0;
......@@ -2614,7 +2613,7 @@ Item_func_set_user_var::update()
case REAL_RESULT:
{
res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal),
REAL_RESULT, &my_charset_bin, DERIVATION_IMPLICIT);
REAL_RESULT, &my_charset_bin, DERIVATION_IMPLICIT, 0);
break;
}
case INT_RESULT:
......@@ -2628,12 +2627,12 @@ Item_func_set_user_var::update()
{
if (!save_result.vstr) // Null value
res= update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin,
DERIVATION_IMPLICIT);
DERIVATION_IMPLICIT, 0);
else
res= update_hash((void*) save_result.vstr->ptr(),
save_result.vstr->length(), STRING_RESULT,
save_result.vstr->charset(),
DERIVATION_IMPLICIT);
DERIVATION_IMPLICIT, 0);
break;
}
case ROW_RESULT:
......
......@@ -962,7 +962,7 @@ public:
longlong val_int();
String *val_str(String *str);
bool update_hash(void *ptr, uint length, enum Item_result type,
CHARSET_INFO *cs, Derivation dv, bool unsigned_arg= 0);
CHARSET_INFO *cs, Derivation dv, bool unsigned_arg);
bool check();
bool update();
enum Item_result result_type () const { return cached_result_type; }
......
......@@ -2607,7 +2607,7 @@ int User_var_log_event::exec_event(struct st_relay_log_info* rli)
a single record and with a single column. Thus, like
a column value, it could always have IMPLICIT derivation.
*/
e.update_hash(val, val_len, type, charset, DERIVATION_IMPLICIT);
e.update_hash(val, val_len, type, charset, DERIVATION_IMPLICIT, 0);
free_root(thd->mem_root,0);
rli->inc_event_relay_log_pos(get_event_len());
......
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