mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / extra / binlog_tests / blackhole.test
blobda63a7a86197213acf83dd58e66f4c5f91edfed5
2 # Simple test for blackhole example
3 # Taken from the select test
5 -- source include/not_embedded.inc
6 -- source include/have_blackhole.inc
7 -- source include/have_log_bin.inc
9 # The server need to be started in $MYSQLTEST_VARDIR since it
10 # uses ../../std_data/
11 -- source include/uses_vardir.inc
13 --disable_warnings
14 drop table if exists t1,t2;
15 --enable_warnings
17 CREATE TABLE t1 (
18   Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
19   Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
20 ) ENGINE=blackhole;
22 INSERT INTO t1 VALUES (9410,9412);
23   
24 select period from t1;
25 select * from t1;
26 select t1.* from t1;
29 # Create test table
32 CREATE TABLE t2 (
33   auto int NOT NULL auto_increment,
34   fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL,
35   companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL,
36   fld3 char(30) DEFAULT '' NOT NULL,
37   fld4 char(35) DEFAULT '' NOT NULL,
38   fld5 char(35) DEFAULT '' NOT NULL,
39   fld6 char(4) DEFAULT '' NOT NULL,
40   primary key (auto)
41 ) ENGINE=blackhole;  
43 INSERT INTO t2 VALUES (1192,068305,00,'Colombo','hardware','colicky','');
44 INSERT INTO t2 VALUES (1193,000000,00,'nondecreasing','implant','thrillingly','');
45 --enable_query_log
48 # Search with a key
51 select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%";
52 select fld3 from t2 where fld3 like "%cultivation" ;
55 # Search with a key using sorting and limit the same time
58 select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3;
59 select fld3,companynr from t2 where companynr = 58 order by fld3;
61 select fld3 from t2 order by fld3 desc limit 10;
62 select fld3 from t2 order by fld3 desc limit 5;
63 select fld3 from t2 order by fld3 desc limit 5,5;
66 # Search with a key having a constant with each unique key.
67 # The table is read directly with read-next on fld3
70 select t2.fld3 from t2 where fld3 = 'honeysuckle';
71 select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_';
72 select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_';
73 select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%';
74 select t2.fld3 from t2 where fld3 LIKE 'h%le';
76 select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_';
77 select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%';
80 # Test sorting with a used key (there is no need for sorting)
83 select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
84 select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
87 # Test for fulltext
88 DROP TABLE t1;
89 CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
90 INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
91                        ('Full-text indexes', 'are called collections'),
92                           ('Only MyISAM tables','support collections'),
93              ('Function MATCH ... AGAINST()','is used to do a search'),
94         ('Full-text search in MySQL', 'implements vector space model');
95 SHOW INDEX FROM t1;
97 # nl search
99 select * from t1 where MATCH(a,b) AGAINST ("collections");
100 explain extended select * from t1 where MATCH(a,b) AGAINST ("collections");
101 select * from t1 where MATCH(a,b) AGAINST ("indexes");
102 select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
103 select * from t1 where MATCH(a,b) AGAINST ("only");
105 # Test that every DML (except SELECT) and DDL gets into binlog
106 # so that blackhole can be used as "binlog propagator"
108 reset master;
109 drop table t1,t2;
110 create table t1 (a int) engine=blackhole;
111 delete from t1 where a=10;
112 update t1 set a=11 where a=15;
113 insert into t1 values(1);
114 insert ignore into t1 values(1);
115 replace into t1 values(100);
116 create table t2 (a varchar(200)) engine=blackhole;
117 eval load data infile '../../std_data/words.dat' into table t2;
118 alter table t1 add b int;
119 alter table t1 drop b;
120 create table t3 like t1;
121 insert into t1 select * from t3;
122 replace into t1 select * from t3;
123 # Just to verify
124 select * from t1;
125 select * from t2;
126 select * from t3;
128 --source include/show_binlog_events.inc
130 drop table t1,t2,t3;
133 # BUG#27998 - mysqld crashed when executing INSERT DELAYED on a BLACKHOLE
134 #             table
136 CREATE TABLE t1(a INT) ENGINE=BLACKHOLE;
137 INSERT DELAYED INTO t1 VALUES(1);
138 DROP TABLE t1;
142 #Bug#19717: DELETE Query Error on BLACKHOLE when using WHERE on column with UNIQUE INDEX
144 CREATE TABLE t1(a INT, b INT) ENGINE=BLACKHOLE;
145 DELETE FROM t1 WHERE a=10;
146 ALTER TABLE t1 ADD INDEX(a);
147 DELETE FROM t1 WHERE a=10;
148 ALTER TABLE t1 DROP INDEX a;
149 ALTER TABLE t1 ADD UNIQUE INDEX(a);
150 DELETE FROM t1 WHERE a=10;
151 ALTER TABLE t1 DROP INDEX a;
152 ALTER TABLE t1 ADD PRIMARY KEY(a);
153 DELETE FROM t1 WHERE a=10;
154 DROP TABLE t1;
157 # Test that a transaction which is rolled back does not go into binlog
158 # and that a transaction which is committed does
160 reset master;
161 create table t1 (a int) engine=blackhole;
162 set autocommit=0;
163 start transaction;
164 insert into t1 values(1);
165 commit;
167 let $master_log_pos_1= query_get_value(SHOW MASTER STATUS, Position, 1);
169 start transaction;
170 insert into t1 values(2);
171 rollback;
173 let $master_log_pos_2= query_get_value(SHOW MASTER STATUS, Position, 1);
174 if (`SELECT $master_log_pos_2 <> $master_log_pos_1`)
176   echo $master_log_pos_1 $master_log_pos_2;
177   die Rollbacked transaction has been binlogged;
180 set autocommit=1;
181 drop table if exists t1;
184 # Bug#35178 INSERT_ID not written to binary log for inserts against BLACKHOLE backed tables
187 # the test checks that explicitly prescribed with set insert_id= value
188 # preceeds the following autoincrement insert in a blachhole
191 reset master;
192 create table t1 (a int auto_increment, primary key (a)) engine=blackhole;
194 # not insert_id prescribed insert binlogs with the default set insert_id 1
195 insert into t1 values (11), (NULL), (NULL), (NULL);
196 set insert_id= 3;
197 insert into t1 values (NULL), (33), (NULL);
198 set insert_id= 5;
199 insert into t1 values (55), (NULL);
200 source include/show_binlog_events2.inc;
202 # cleanup
203 drop table t1;
206 # End of tests