mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / t / varbinary.test
blob1f9f7b5412dfe537c8e8d449c0e6f130279d520f
1 # This test uses chmod, can't be run with root permissions
2 -- source include/not_as_root.inc
5 # Initialise
6 --disable_warnings
7 drop table if exists t1;
8 --enable_warnings
11 # varbinary as string and number
14 select 0x41,0x41+0,0x41 | 0x7fffffffffffffff | 0,0xffffffffffffffff | 0 ;
15 select 0x31+1,concat(0x31)+1,-0xf;
16 select x'31',X'ffff'+0;
19 # Test of hex constants in WHERE:
22 create table t1 (ID int(8) unsigned zerofill not null auto_increment,UNIQ bigint(21) unsigned zerofill not null,primary key (ID),unique (UNIQ) );
23 insert into t1 set UNIQ=0x38afba1d73e6a18a;
24 insert into t1 set UNIQ=123; 
25 explain extended select * from t1 where UNIQ=0x38afba1d73e6a18a;
26 drop table t1;
29 # Test error conditions
31 --error 1064
32 select x'hello';
33 --error 1054
34 select 0xfg;
37 # Test likely error conditions
39 create table t1 select 1 as x, 2 as xx;
40 select x,xx from t1;
41 drop table t1;
43 # End of 4.1 tests
46 # Bug #19371 VARBINARY() have trailing zeros after upgrade from 4.1
49 # Test with a saved table from 4.1
50 let $MYSQLD_DATADIR= `select @@datadir`;
51 copy_file std_data/bug19371.frm $MYSQLD_DATADIR/test/t1.frm;
52 chmod 0777 $MYSQLD_DATADIR/test/t1.frm;
53 copy_file std_data/bug19371.MYD $MYSQLD_DATADIR/test/t1.MYD;
54 chmod 0777 $MYSQLD_DATADIR/test/t1.MYD;
55 copy_file std_data/bug19371.MYI $MYSQLD_DATADIR/test/t1.MYI;
56 chmod 0777 $MYSQLD_DATADIR/test/t1.MYI;
58 # Everything _looks_ fine
59 show create table t1;
61 # But the length of the varbinary columns are too long
62 select length(a), length(b) from t1;
64 # Run CHECK TABLE, it should indicate table need a REPAIR TABLE
65 CHECK TABLE t1 FOR UPGRADE;
67 # Run REPAIR TABLE to alter the table and repair
68 # the varbinary fields
69 REPAIR TABLE t1;
71 # Now check it's back to normal
72 show create table t1;
73 select length(a), length(b) from t1;
74 insert into t1 values("ccc", "ddd");
75 select length(a), length(b) from t1;
76 select hex(a), hex(b) from t1;
77 select concat("'", a, "'"), concat("'", b, "'") from t1;
79 drop table t1;
81 # Check that the fix does not affect table created with current version
82 create table t1(a varbinary(255));
83 insert into t1 values("aaa   ");
84 select length(a) from t1;
85 alter table t1 modify a varchar(255);
86 select length(a) from t1;
87 drop table t1;
91 # Bug#28127 (Some valid identifiers names are not parsed correctly)
94 --disable_warnings
95 drop table if exists table_28127_a;
96 drop table if exists table_28127_b;
97 --enable_warnings
99 create table table_28127_a(0b02 int);
100 show create table table_28127_a;
102 create table table_28127_b(0b2 int);
103 show create table table_28127_b;
105 drop table table_28127_a;
106 drop table table_28127_b;
109 # Bug#35658 (An empty binary value leads to mysqld crash)
112 select 0b01000001;
114 select 0x41;
116 select b'01000001';
118 select x'41', 0+x'41';
120 select N'abc', length(N'abc');
122 select N'', length(N'');
124 select '', length('');
126 select b'', 0+b'';
128 select x'', 0+x'';
130 --error ER_BAD_FIELD_ERROR
131 select 0x;
133 --error ER_BAD_FIELD_ERROR
134 select 0b;