Below is the list of changes that have just been committed into a local
4.1 repository of ram. When ram does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-12-04 13:28:38+04:00, ramil@stripped +5 -0
Fix for bug #22533: Traditional: Too-long bit value not rejected.
Storing >8 byte hexadecimal values in bigint fields we don't check data.
Fix: check if the data fits the {u}longlong range.
mysql-test/r/range.result@stripped, 2006-12-04 13:28:35+04:00, ramil@stripped +4 -4
Fix for bug #22533: Traditional: Too-long bit value not rejected.
- adjusted.
mysql-test/r/select.result@stripped, 2006-12-04 13:28:35+04:00, ramil@stripped +17 -0
Fix for bug #22533: Traditional: Too-long bit value not rejected.
- test result.
mysql-test/t/range.test@stripped, 2006-12-04 13:28:35+04:00, ramil@stripped +4 -4
Fix for bug #22533: Traditional: Too-long bit value not rejected.
- adjusted.
mysql-test/t/select.test@stripped, 2006-12-04 13:28:35+04:00, ramil@stripped +12 -1
Fix for bug #22533: Traditional: Too-long bit value not rejected.
- test case.
sql/item.cc@stripped, 2006-12-04 13:28:36+04:00, ramil@stripped +28 -8
Fix for bug #22533: Traditional: Too-long bit value not rejected.
- raise a warning if we store >8 byte length value in a bigint field,
then store proper value.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: ramil
# Host: myoffice.izhnet.ru
# Root: /usr/home/ram/work/bug22533/my41-bug22533
--- 1.233/sql/item.cc 2006-12-04 13:28:43 +04:00
+++ 1.234/sql/item.cc 2006-12-04 13:28:43 +04:00
@@ -2340,18 +2340,38 @@ longlong Item_varbinary::val_int()
int Item_varbinary::save_in_field(Field *field, bool no_conversions)
{
- int error;
field->set_notnull();
if (field->result_type() == STRING_RESULT)
+ return field->store(str_value.ptr(), str_value.length(),
+ collation.collation);
+
+ ulonglong nr;
+ if (field->pack_length() == 8)
{
- error=field->store(str_value.ptr(),str_value.length(),collation.collation);
+ uint32 length= str_value.length();
+ if (length > 8)
+ {
+ nr= field->flags & UNSIGNED_FLAG ? ULONGLONG_MAX : LONGLONG_MAX;
+ goto warn;
+ }
+ else if (length == 8 && !(field->flags & UNSIGNED_FLAG))
+ {
+ nr= val_int();
+ if (nr > LONGLONG_MAX)
+ {
+ nr= LONGLONG_MAX;
+ goto warn;
+ }
+ return field->store((longlong) nr);
+ }
}
- else
- {
- longlong nr=val_int();
- error=field->store(nr);
- }
- return error;
+ return field->store(val_int());
+
+warn:
+ field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE,
+ 1);
+ field->store((longlong) nr);
+ return 1;
}
--- 1.36/mysql-test/r/range.result 2006-12-04 13:28:43 +04:00
+++ 1.37/mysql-test/r/range.result 2006-12-04 13:28:43 +04:00
@@ -476,8 +476,8 @@ id name uid id name uid
1026 Z 26 1026 Z 26
drop table t1,t2;
create table t1 (x bigint unsigned not null);
-insert into t1(x) values (0xfffffffffffffff0);
-insert into t1(x) values (0xfffffffffffffff1);
+insert into t1(x) values (-16);
+insert into t1(x) values (-15);
select * from t1;
x
18446744073709551600
@@ -504,8 +504,8 @@ select count(*) from t1 where x = 184467
count(*)
1
create table t2 (x bigint not null);
-insert into t2(x) values (0xfffffffffffffff0);
-insert into t2(x) values (0xfffffffffffffff1);
+insert into t2(x) values (-16);
+insert into t2(x) values (-15);
select * from t2;
x
-16
--- 1.77/mysql-test/r/select.result 2006-12-04 13:28:44 +04:00
+++ 1.78/mysql-test/r/select.result 2006-12-04 13:28:44 +04:00
@@ -2819,3 +2819,20 @@ select min(key1) from t1 where key1 >= 0
min(key1)
0.37619999051094
DROP TABLE t1,t2;
+create table t1(a bigint unsigned, b bigint);
+insert into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff),
+(0x10000000000000000, 0x10000000000000000),
+(0x8fffffffffffffff, 0x8fffffffffffffff);
+Warnings:
+Warning 1264 Data truncated; out of range for column 'a' at row 1
+Warning 1264 Data truncated; out of range for column 'b' at row 1
+Warning 1264 Data truncated; out of range for column 'a' at row 2
+Warning 1264 Data truncated; out of range for column 'b' at row 2
+Warning 1264 Data truncated; out of range for column 'b' at row 3
+select hex(a), hex(b) from t1;
+hex(a) hex(b)
+FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF
+FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF
+8FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF
+drop table t1;
+End of 4.1 tests
--- 1.32/mysql-test/t/range.test 2006-12-04 13:28:44 +04:00
+++ 1.33/mysql-test/t/range.test 2006-12-04 13:28:44 +04:00
@@ -387,8 +387,8 @@ drop table t1,t2;
# Fix for bug#4488
#
create table t1 (x bigint unsigned not null);
-insert into t1(x) values (0xfffffffffffffff0);
-insert into t1(x) values (0xfffffffffffffff1);
+insert into t1(x) values (-16);
+insert into t1(x) values (-15);
select * from t1;
select count(*) from t1 where x>0;
select count(*) from t1 where x=0;
@@ -400,8 +400,8 @@ select count(*) from t1 where x = 184467
create table t2 (x bigint not null);
-insert into t2(x) values (0xfffffffffffffff0);
-insert into t2(x) values (0xfffffffffffffff1);
+insert into t2(x) values (-16);
+insert into t2(x) values (-15);
select * from t2;
select count(*) from t2 where x>0;
select count(*) from t2 where x=0;
--- 1.60/mysql-test/t/select.test 2006-12-04 13:28:44 +04:00
+++ 1.61/mysql-test/t/select.test 2006-12-04 13:28:44 +04:00
@@ -2342,4 +2342,15 @@ select min(key1) from t1 where key1 >= 0
DROP TABLE t1,t2;
--enable_ps_protocol
-# End of 4.1 tests
+#
+# Bug #22533: storing large hex string in a bigint field
+#
+
+create table t1(a bigint unsigned, b bigint);
+insert into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff),
+ (0x10000000000000000, 0x10000000000000000),
+ (0x8fffffffffffffff, 0x8fffffffffffffff);
+select hex(a), hex(b) from t1;
+drop table t1;
+
+--echo End of 4.1 tests
| Thread |
|---|
| • bk commit into 4.1 tree (ramil:1.2558) BUG#22533 | ramil | 4 Dec |