mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Report truncation of spaces when inserting into a BINARY or VARBINARY
field. (Bug #14299) mysql-test/r/type_binary.result: Add results mysql-test/t/type_binary.test: Add new regression test sql/field.cc: Always report truncation of binary and varbinary strings, even if it was just spaces. (Plus some minor style/comment cleanups.)
This commit is contained in:
@ -111,3 +111,25 @@ select count(distinct s1) from t1;
|
||||
count(distinct s1)
|
||||
3
|
||||
drop table t1;
|
||||
create table t1 (b binary(2), vb varbinary(2));
|
||||
insert into t1 values(0x4120, 0x4120);
|
||||
insert into t1 values(0x412020, 0x412020);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'b' at row 1
|
||||
Warning 1265 Data truncated for column 'vb' at row 1
|
||||
drop table t1;
|
||||
create table t1 (c char(2), vc varchar(2));
|
||||
insert into t1 values(0x4120, 0x4120);
|
||||
insert into t1 values(0x412020, 0x412020);
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'vc' at row 1
|
||||
drop table t1;
|
||||
set @old_sql_mode= @@sql_mode, sql_mode= 'traditional';
|
||||
create table t1 (b binary(2), vb varbinary(2));
|
||||
insert into t1 values(0x4120, 0x4120);
|
||||
insert into t1 values(0x412020, NULL);
|
||||
ERROR 22001: Data too long for column 'b' at row 1
|
||||
insert into t1 values(NULL, 0x412020);
|
||||
ERROR 22001: Data too long for column 'vb' at row 1
|
||||
drop table t1;
|
||||
set @@sql_mode= @old_sql_mode;
|
||||
|
@ -65,3 +65,27 @@ select hex(s1) from t1 where s1=0x0120;
|
||||
select hex(s1) from t1 where s1=0x0100;
|
||||
select count(distinct s1) from t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug #14299: BINARY space truncation should cause warning or error
|
||||
#
|
||||
create table t1 (b binary(2), vb varbinary(2));
|
||||
insert into t1 values(0x4120, 0x4120);
|
||||
insert into t1 values(0x412020, 0x412020);
|
||||
drop table t1;
|
||||
create table t1 (c char(2), vc varchar(2));
|
||||
insert into t1 values(0x4120, 0x4120);
|
||||
insert into t1 values(0x412020, 0x412020);
|
||||
drop table t1;
|
||||
|
||||
set @old_sql_mode= @@sql_mode, sql_mode= 'traditional';
|
||||
create table t1 (b binary(2), vb varbinary(2));
|
||||
insert into t1 values(0x4120, 0x4120);
|
||||
--error ER_DATA_TOO_LONG
|
||||
insert into t1 values(0x412020, NULL);
|
||||
--error ER_DATA_TOO_LONG
|
||||
insert into t1 values(NULL, 0x412020);
|
||||
drop table t1;
|
||||
set @@sql_mode= @old_sql_mode;
|
||||
|
||||
# End of 5.0 tests
|
||||
|
Reference in New Issue
Block a user