From 1b3ffb1bcbe182f38741107da8133dfae9471fba Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 Feb 2005 23:50:06 +0300 Subject: [PATCH 1/2] Fix for BUG#8562: In Item_int_with_ref::new_item() create Item_int or Item_uint depending on ref->unsigned_flag. Item_int_with_ref can refer to both signed and unsigned integers. mysql-test/r/bigint.result: Test case for BUG#8562 mysql-test/t/bigint.test: Test case for BUG#8562 --- mysql-test/r/bigint.result | 39 ++++++++++++++++++++++++++++++++++++++ mysql-test/t/bigint.test | 33 ++++++++++++++++++++++++++++++++ sql/item.h | 5 +++++ 3 files changed, 77 insertions(+) diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index 4c70e72bdfb..eb3d0da3f23 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -87,3 +87,42 @@ drop table t1; SELECT '0x8000000000000001'+0; '0x8000000000000001'+0 0 +create table t1 ( +value64 bigint unsigned not null, +value32 integer not null, +primary key(value64, value32) +); +create table t2 ( +value64 bigint unsigned not null, +value32 integer not null, +primary key(value64, value32) +); +insert into t1 values(17156792991891826145, 1); +insert into t1 values( 9223372036854775807, 2); +insert into t2 values(17156792991891826145, 3); +insert into t2 values( 9223372036854775807, 4); +select * from t1; +value64 value32 +9223372036854775807 2 +17156792991891826145 1 +select * from t2; +value64 value32 +9223372036854775807 4 +17156792991891826145 3 +select * from t1, t2 where t1.value64=17156792991891826145 and +t2.value64=17156792991891826145; +value64 value32 value64 value32 +17156792991891826145 1 17156792991891826145 3 +select * from t1, t2 where t1.value64=17156792991891826145 and +t2.value64=t1.value64; +value64 value32 value64 value32 +17156792991891826145 1 17156792991891826145 3 +select * from t1, t2 where t1.value64= 9223372036854775807 and +t2.value64=9223372036854775807; +value64 value32 value64 value32 +9223372036854775807 2 9223372036854775807 4 +select * from t1, t2 where t1.value64= 9223372036854775807 and +t2.value64=t1.value64; +value64 value32 value64 value32 +9223372036854775807 2 9223372036854775807 4 +drop table t1, t2; diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index c509a4113f4..a26b78254e7 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -71,3 +71,36 @@ drop table t1; # atof() behaviour is different of different systems. to be fixed in 4.1 SELECT '0x8000000000000001'+0; +# Test for BUG#8562: joins over BIGINT UNSIGNED value + constant propagation +create table t1 ( + value64 bigint unsigned not null, + value32 integer not null, + primary key(value64, value32) +); + +create table t2 ( + value64 bigint unsigned not null, + value32 integer not null, + primary key(value64, value32) +); + +insert into t1 values(17156792991891826145, 1); +insert into t1 values( 9223372036854775807, 2); +insert into t2 values(17156792991891826145, 3); +insert into t2 values( 9223372036854775807, 4); + +select * from t1; +select * from t2; + +select * from t1, t2 where t1.value64=17156792991891826145 and +t2.value64=17156792991891826145; +select * from t1, t2 where t1.value64=17156792991891826145 and +t2.value64=t1.value64; + +select * from t1, t2 where t1.value64= 9223372036854775807 and +t2.value64=9223372036854775807; +select * from t1, t2 where t1.value64= 9223372036854775807 and +t2.value64=t1.value64; + +drop table t1, t2; + diff --git a/sql/item.h b/sql/item.h index 97e2b0c0945..423a9d6e425 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1011,6 +1011,11 @@ public: { return ref->save_in_field(field, no_conversions); } + Item *new_item() + { + return (ref->unsigned_flag)? new Item_uint(ref->name, ref->max_length) : + new Item_int(ref->name, ref->max_length); + } }; From d88c56a63749e5e5b0828557bd81f207a29eaacd Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Mar 2005 05:03:21 +0300 Subject: [PATCH 2/2] Comments added --- sql/item.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/item.h b/sql/item.h index 423a9d6e425..2827be2d237 100644 --- a/sql/item.h +++ b/sql/item.h @@ -997,6 +997,8 @@ public: The following class is used to optimize comparing of date and bigint columns We need to save the original item, to be able to set the field to the original value in 'opt_range'. + An instance of Item_int_with_ref may refer to a signed or an unsigned + integer. */ class Item_int_with_ref :public Item_int