From 5aa6e8615e0aeb3babafcd5e93e67b72027fcdaa Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Sep 2006 16:25:40 +0400 Subject: [PATCH] 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 --- mysql-test/r/case.result | 1 + mysql-test/r/func_if.result | 1 + mysql-test/r/func_test.result | 1 + mysql-test/r/user_var.result | 1 + mysql-test/t/case.test | 6 ++++-- mysql-test/t/func_if.test | 10 +++++++--- mysql-test/t/func_test.test | 6 ++++-- mysql-test/t/user_var.test | 6 ++++-- sql/item_func.cc | 13 ++++++------- sql/item_func.h | 2 +- sql/log_event.cc | 2 +- 11 files changed, 31 insertions(+), 18 deletions(-) diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result index ccac701bfc1..db56fd82f72 100644 --- a/mysql-test/r/case.result +++ b/mysql-test/r/case.result @@ -183,3 +183,4 @@ CASE 1 WHEN 1 THEN 18446744073709551615 ELSE 1 END SELECT COALESCE(18446744073709551615); COALESCE(18446744073709551615) 18446744073709551615 +End of 4.1 tests diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result index e9aa195d175..72275039ba7 100644 --- a/mysql-test/r/func_if.result +++ b/mysql-test/r/func_if.result @@ -105,3 +105,4 @@ IF(1 != 0, 18446744073709551615, 1) SELECT IFNULL(NULL, 18446744073709551615); IFNULL(NULL, 18446744073709551615) 18446744073709551615 +End of 4.1 tests diff --git a/mysql-test/r/func_test.result b/mysql-test/r/func_test.result index cc27865cc4c..7c9827a5005 100644 --- a/mysql-test/r/func_test.result +++ b/mysql-test/r/func_test.result @@ -189,3 +189,4 @@ GREATEST(1, 18446744073709551615) SELECT LEAST(1, 18446744073709551615); LEAST(1, 18446744073709551615) 1 +End of 4.1 tests diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index dce852e84ae..6797fb0799d 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -207,3 +207,4 @@ set @a=18446744073709551615; select @a; @a 18446744073709551615 +End of 4.1 tests diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test index b868ae12b69..d0d503a8821 100644 --- a/mysql-test/t/case.test +++ b/mysql-test/t/case.test @@ -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 diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test index 17117b07437..69cfcf7860b 100644 --- a/mysql-test/t/func_if.test +++ b/mysql-test/t/func_if.test @@ -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 diff --git a/mysql-test/t/func_test.test b/mysql-test/t/func_test.test index 631639c7a74..549b0e60246 100644 --- a/mysql-test/t/func_test.test +++ b/mysql-test/t/func_test.test @@ -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 diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index 810d5e96da5..b7c8f962637 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -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 diff --git a/sql/item_func.cc b/sql/item_func.cc index 85865ad6fb6..d43dadfa4a4 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -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,26 +2613,26 @@ 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: { res= update_hash((void*) &save_result.vint, sizeof(save_result.vint), - INT_RESULT, &my_charset_bin, DERIVATION_IMPLICIT, - unsigned_flag); + INT_RESULT, &my_charset_bin, DERIVATION_IMPLICIT, + unsigned_flag); break; } case STRING_RESULT: { 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: diff --git a/sql/item_func.h b/sql/item_func.h index d9e1396fde6..3a29b9d6f15 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -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; } diff --git a/sql/log_event.cc b/sql/log_event.cc index 19c32b2d28e..ef375a30441 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -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());