Commit 607852cf authored by unknown's avatar unknown

a fix (bug #11546: Bad error message from inserting out of range values, SQL_MODE='tradition').


sql/field.cc:
  a fix (bug #11546: Bad error message from inserting out of range values, SQL_MODE='tradition').
  raise an error in case of strict mode for bit fields.
parent c15cab96
......@@ -1258,3 +1258,10 @@ select * from t1;
d
2000-10-01
drop table t1;
set @@sql_mode='traditional';
create table t1(a bit(2));
insert into t1 values(b'101');
ERROR 22001: Data too long for column 'a' at row 1
select * from t1;
a
drop table t1;
......@@ -1118,3 +1118,14 @@ insert into t1 values ('2000-10-01');
update t1 set d = 1100;
select * from t1;
drop table t1;
#
# BIT fields
#
set @@sql_mode='traditional';
create table t1(a bit(2));
--error 1406
insert into t1 values(b'101');
select * from t1;
drop table t1;
......@@ -7846,6 +7846,9 @@ int Field_bit::store(const char *from, uint length, CHARSET_INFO *cs)
{
set_rec_bits(0xff, bit_ptr, bit_ofs, bit_len);
memset(ptr, 0xff, field_length);
if (table->in_use->really_abort_on_warning())
set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
else
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
return 1;
}
......@@ -8063,6 +8066,9 @@ int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs)
memset(ptr, 0xff, field_length);
if (bits)
*ptr&= ((1 << bits) - 1); /* set first byte */
if (table->in_use->really_abort_on_warning())
set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
else
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