mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-4.1-maint
into mysql.com:/usr/home/ram/work/bug22533/my41-bug22533
This commit is contained in:
commit
adfe34d91e
4 changed files with 50 additions and 9 deletions
|
@ -2819,3 +2819,20 @@ select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||||
min(key1)
|
min(key1)
|
||||||
0.37619999051094
|
0.37619999051094
|
||||||
DROP TABLE t1,t2;
|
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
|
||||||
|
|
|
@ -400,8 +400,8 @@ select count(*) from t1 where x = 18446744073709551601;
|
||||||
|
|
||||||
|
|
||||||
create table t2 (x bigint not null);
|
create table t2 (x bigint not null);
|
||||||
insert into t2(x) values (0xfffffffffffffff0);
|
insert into t2(x) values (-16);
|
||||||
insert into t2(x) values (0xfffffffffffffff1);
|
insert into t2(x) values (-15);
|
||||||
select * from t2;
|
select * from t2;
|
||||||
select count(*) from t2 where x>0;
|
select count(*) from t2 where x>0;
|
||||||
select count(*) from t2 where x=0;
|
select count(*) from t2 where x=0;
|
||||||
|
|
|
@ -2342,4 +2342,15 @@ select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
--enable_ps_protocol
|
--enable_ps_protocol
|
||||||
|
|
||||||
# End of 4.1 tests
|
#
|
||||||
|
# Bug #22533: storing large hex strings
|
||||||
|
#
|
||||||
|
|
||||||
|
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
|
||||||
|
|
25
sql/item.cc
25
sql/item.cc
|
@ -2369,18 +2369,31 @@ longlong Item_varbinary::val_int()
|
||||||
|
|
||||||
int Item_varbinary::save_in_field(Field *field, bool no_conversions)
|
int Item_varbinary::save_in_field(Field *field, bool no_conversions)
|
||||||
{
|
{
|
||||||
int error;
|
|
||||||
field->set_notnull();
|
field->set_notnull();
|
||||||
if (field->result_type() == STRING_RESULT)
|
if (field->result_type() == STRING_RESULT)
|
||||||
|
return field->store(str_value.ptr(), str_value.length(),
|
||||||
|
collation.collation);
|
||||||
|
|
||||||
|
ulonglong nr;
|
||||||
|
uint32 length= str_value.length();
|
||||||
|
if (length > 8)
|
||||||
{
|
{
|
||||||
error=field->store(str_value.ptr(),str_value.length(),collation.collation);
|
nr= field->flags & UNSIGNED_FLAG ? ULONGLONG_MAX : LONGLONG_MAX;
|
||||||
|
goto warn;
|
||||||
}
|
}
|
||||||
else
|
nr= (ulonglong) val_int();
|
||||||
|
if ((length == 8) && !(field->flags & UNSIGNED_FLAG) && (nr > LONGLONG_MAX))
|
||||||
{
|
{
|
||||||
longlong nr=val_int();
|
nr= LONGLONG_MAX;
|
||||||
error=field->store(nr);
|
goto warn;
|
||||||
}
|
}
|
||||||
return error;
|
return field->store((longlong) nr);
|
||||||
|
|
||||||
|
warn:
|
||||||
|
if (!field->store((longlong) nr))
|
||||||
|
field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE,
|
||||||
|
1);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue