📄 type_binary.test
字号:
# check 0x00 paddingcreate table t1 (s1 binary(3));insert into t1 values (0x61), (0x6120), (0x612020);select hex(s1) from t1;drop table t1;# check that 0x00 is not stripped in val_strcreate table t1 (s1 binary(2), s2 varbinary(2));insert into t1 values (0x4100,0x4100);select length(concat('*',s1,'*',s2,'*')) from t1;delete from t1;insert into t1 values (0x4120,0x4120);select length(concat('*',s1,'*',s2,'*')) from t1;drop table t1;# check that trailing 0x00 and 0x20 do matter on comparisoncreate table t1 (s1 varbinary(20), s2 varbinary(20));show create table t1;insert into t1 values (0x41,0x4100),(0x41,0x4120),(0x4100,0x4120);select hex(s1), hex(s2) from t1;select count(*) from t1 where s1 < s2;drop table t1;# check that trailing 0x00 do matter on filesortcreate table t1 (s1 varbinary(2), s2 varchar(1));insert into t1 values (0x41,'a'), (0x4100,'b'), (0x41,'c'), (0x4100,'d');select hex(s1),s2 from t1 order by s1,s2;drop table t1;# check that 0x01 is padded to 0x0100 and thus we get a duplicate valuecreate table t1 (s1 binary(2) primary key);insert into t1 values (0x01);insert into t1 values (0x0120);--error 1062insert into t1 values (0x0100);select hex(s1) from t1 order by s1;# check index searchselect hex(s1) from t1 where s1=0x01;select hex(s1) from t1 where s1=0x0120;select hex(s1) from t1 where s1=0x0100;select count(distinct s1) from t1;alter table t1 drop primary key;# check non-indexed searchselect hex(s1) from t1 where s1=0x01;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;# check that 0x01 is not padded, and all three values are uniquecreate table t1 (s1 varbinary(2) primary key);insert into t1 values (0x01);insert into t1 values (0x0120);insert into t1 values (0x0100);select hex(s1) from t1 order by s1;# check index searchselect hex(s1) from t1 where s1=0x01;select hex(s1) from t1 where s1=0x0120;select hex(s1) from t1 where s1=0x0100;select count(distinct s1) from t1;alter table t1 drop primary key;# check non-indexed searchselect hex(s1) from t1 where s1=0x01;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;# check that cast appends trailing zerosselect hex(cast(0x10 as binary(2)));## 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_LONGinsert into t1 values(0x412020, NULL);--error ER_DATA_TOO_LONGinsert into t1 values(NULL, 0x412020);drop table t1;set @@sql_mode= @old_sql_mode;--echo End of 5.0 tests
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -