Commit 92aa1484 authored by unknown's avatar unknown

Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.1-maint

into  mysql.com:/usr/home/ram/work/bug22533/my51-bug22533


mysql-test/r/select.result:
  Auto merged
mysql-test/t/select.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/item.cc:
  Auto merged
parents cd31b33d 896aca8f
......@@ -521,8 +521,8 @@ select count(*) from t1 where x = 18446744073709551601;
count(*)
1
create table t2 (x bigint not null);
insert into t2(x) values (cast(0xfffffffffffffff0+0 as signed));
insert into t2(x) values (cast(0xfffffffffffffff1+0 as signed));
insert into t2(x) values (-16);
insert into t2(x) values (-15);
select * from t2;
x
-16
......
......@@ -2811,6 +2811,23 @@ SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;
i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01')
1 1 1 1
DROP TABLE t1;
create table t1(a bigint unsigned, b bigint);
insert into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff),
(0x10000000000000000, 0x10000000000000000),
(0x8fffffffffffffff, 0x8fffffffffffffff);
Warnings:
Warning 1264 Out of range value adjusted for column 'a' at row 1
Warning 1264 Out of range value adjusted for column 'b' at row 1
Warning 1264 Out of range value adjusted for column 'a' at row 2
Warning 1264 Out of range value adjusted for column 'b' at row 2
Warning 1264 Out of range value adjusted 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
CREATE TABLE t1 (
K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '',
K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000',
......
......@@ -568,7 +568,7 @@ create table t1 (a bit(7));
insert into t1 values (0x60);
select * from t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t1 a a 16 7 1 Y 0 0 63
def test t1 t1 a a 16 7 1 Y 32 0 63
a
`
drop table t1;
......
......@@ -406,7 +406,7 @@ create table t1 (a bit(7)) engine=innodb;
insert into t1 values (0x60);
select * from t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t1 a a 16 7 1 Y 0 0 63
def test t1 t1 a a 16 7 1 Y 32 0 63
a
`
drop table t1;
......
......@@ -406,8 +406,8 @@ select count(*) from t1 where x = 18446744073709551601;
create table t2 (x bigint not null);
insert into t2(x) values (cast(0xfffffffffffffff0+0 as signed));
insert into t2(x) values (cast(0xfffffffffffffff1+0 as signed));
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;
......
......@@ -2350,7 +2350,18 @@ INSERT INTO t1 VALUES (10);
SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;
DROP TABLE t1;
# 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
#
# Test for bug #6474
......
......@@ -8245,6 +8245,7 @@ Field_bit::Field_bit(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
bit_ptr(bit_ptr_arg), bit_ofs(bit_ofs_arg), bit_len(len_arg & 7),
bytes_in_rec(len_arg / 8)
{
flags|= UNSIGNED_FLAG;
/*
Ensure that Field::eq() can distinguish between two different bit fields.
(two bit fields that are not null, may have same ptr and null_ptr)
......@@ -8554,6 +8555,7 @@ Field_bit_as_char::Field_bit_as_char(char *ptr_arg, uint32 len_arg,
:Field_bit(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, 0, 0,
unireg_check_arg, field_name_arg)
{
flags|= UNSIGNED_FLAG;
bit_len= 0;
bytes_in_rec= (len_arg + 7) / 8;
}
......
......@@ -4639,18 +4639,31 @@ my_decimal *Item_hex_string::val_decimal(my_decimal *decimal_value)
int Item_hex_string::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;
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();
error=field->store(nr, TRUE); // Assume hex numbers are unsigned
nr= LONGLONG_MAX;
goto warn;
}
return error;
return field->store((longlong) nr, TRUE); // Assume hex numbers are unsigned
warn:
if (!field->store((longlong) nr, TRUE))
field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE,
1);
return 1;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment