diff options
author | unknown <sergefp@mysql.com> | 2004-08-17 02:59:24 +0400 |
---|---|---|
committer | unknown <sergefp@mysql.com> | 2004-08-17 02:59:24 +0400 |
commit | 5a7dd14edf990e6b23312ad305a92d05874be04c (patch) | |
tree | c15d08efcfe7345961ad895b97c4a32a10069dda | |
parent | b37a73611024d78de35145c5f6cb394a7c3f225c (diff) | |
download | mariadb-git-5a7dd14edf990e6b23312ad305a92d05874be04c.tar.gz |
Fix for bug#4488: sign-aware equality check
mysql-test/r/range.result:
Fix for bug#4488: more tests
mysql-test/t/range.test:
Fix for bug#4488: more tests
-rw-r--r-- | mysql-test/r/range.result | 9 | ||||
-rw-r--r-- | mysql-test/t/range.test | 4 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 16 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 1 |
4 files changed, 30 insertions, 0 deletions
diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index e66a3de0049..4ca96316800 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -500,6 +500,9 @@ count(*) select count(*) from t1 where x > -16; count(*) 2 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 create table t2 (x bigint not null); insert into t2(x) values (0xfffffffffffffff0); insert into t2(x) values (0xfffffffffffffff1); @@ -525,6 +528,9 @@ count(*) select count(*) from t2 where x > -16; count(*) 1 +select count(*) from t2 where x = 18446744073709551601; +count(*) +0 drop table t1; create table t1 (x bigint unsigned not null primary key) engine=innodb; insert into t1(x) values (0xfffffffffffffff0); @@ -551,4 +557,7 @@ count(*) select count(*) from t1 where x > -16; count(*) 1 +select count(*) from t1 where x = 18446744073709551601; +count(*) +1 drop table t1; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index b171f5f98e7..6037f68db55 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -396,6 +396,8 @@ select count(*) from t1 where x<0; select count(*) from t1 where x < -16; select count(*) from t1 where x = -16; select count(*) from t1 where x > -16; +select count(*) from t1 where x = 18446744073709551601; + create table t2 (x bigint not null); insert into t2(x) values (0xfffffffffffffff0); @@ -407,6 +409,7 @@ select count(*) from t2 where x<0; select count(*) from t2 where x < -16; select count(*) from t2 where x = -16; select count(*) from t2 where x > -16; +select count(*) from t2 where x = 18446744073709551601; drop table t1; create table t1 (x bigint unsigned not null primary key) engine=innodb; @@ -419,6 +422,7 @@ select count(*) from t1 where x<0; select count(*) from t1 where x < -16; select count(*) from t1 where x = -16; select count(*) from t1 where x > -16; +select count(*) from t1 where x = 18446744073709551601; drop table t1; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index e7531e17d34..45a1918de1c 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -325,6 +325,11 @@ int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type) else if ((*b)->unsigned_flag) func= &Arg_comparator::compare_int_signed_unsigned; } + else if (func== &Arg_comparator::compare_e_int) + { + if ((*a)->unsigned_flag ^ (*b)->unsigned_flag) + func= &Arg_comparator::compare_e_int_diff_signedness; + } } return 0; } @@ -530,6 +535,17 @@ int Arg_comparator::compare_e_int() return test(val1 == val2); } +/* + Compare unsigned *a with signed *b or signed *a with unsigned *b. +*/ +int Arg_comparator::compare_e_int_diff_signedness() +{ + longlong val1= (*a)->val_int(); + longlong val2= (*b)->val_int(); + if ((*a)->null_value || (*b)->null_value) + return test((*a)->null_value && (*b)->null_value); + return (val1 >= 0) && test(val1 == val2); +} int Arg_comparator::compare_row() { diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index de2b5e84038..415fae59de9 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -74,6 +74,7 @@ public: int compare_e_binary_string(); // compare args[0] & args[1] int compare_e_real(); // compare args[0] & args[1] int compare_e_int(); // compare args[0] & args[1] + int compare_e_int_diff_signedness(); int compare_e_row(); // compare args[0] & args[1] static arg_cmp_func comparator_matrix [4][2]; |