Commit 4f58bd7e authored by unknown's avatar unknown

a fix (bug #10539: When inserting out of range value in BIT, different engines...

a fix (bug #10539: When inserting out of range value in BIT, different engines behaves differently).           


sql/field.cc:
  a fix (bug #10539: When inserting out of range value in BIT, different engines behaves differently).           
  we have to set the first byte only if there is(are) uneven bit(s).
parent b8421582
......@@ -458,3 +458,11 @@ select h from t1;
h
a
drop table t1;
create table t1 (a bit(8)) engine=heap;
insert into t1 values ('1111100000');
Warnings:
Warning 1264 Out of range value adjusted for column 'a' at row 1
select a+0 from t1;
a+0
255
drop table t1;
......@@ -162,3 +162,12 @@ create table t1 (a int, b time, c tinyint, d bool, e char(10), f bit(1),
insert into t1 set a=1;
select h from t1;
drop table t1;
#
# Bug #10539
#
create table t1 (a bit(8)) engine=heap;
insert into t1 values ('1111100000');
select a+0 from t1;
drop table t1;
......@@ -7821,7 +7821,7 @@ int Field_bit::store(const char *from, uint length, CHARSET_INFO *cs)
int Field_bit::store(double nr)
{
return (Field_bit::store((longlong) nr));
return store((longlong) nr);
}
......@@ -8004,7 +8004,8 @@ int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs)
(delta == 0 && bits && (uint) (uchar) *from >= (uint) (1 << bits)))
{
memset(ptr, 0xff, field_length);
*ptr&= ((1 << bits) - 1); /* set first byte */
if (bits)
*ptr&= ((1 << bits) - 1); /* set first byte */
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