mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / t / mysql.test
blobaa774036d107ee23222908657e2aabf404761cd4
1 # This test should work in embedded server after we fix mysqltest
2 -- source include/not_embedded.inc
4 # Testing the MySQL command line client(mysql)
7 --disable_warnings
8 drop table if exists t1;
9 --enable_warnings
12 # Test the "delimiter" functionality
13 # Bug#9879
15 create table t1(a int);
16 insert into t1 values(1);
18 # Test delimiters
19 --exec $MYSQL test 2>&1 < "./t/mysql_delimiter.sql"
21 --disable_query_log
22 # Test delimiter : supplied on the command line
23 select "Test delimiter : from command line" as "_";
24 --exec $MYSQL test --delimiter=":" -e "select * from t1:"
25 # Test delimiter :; supplied on the command line
26 select "Test delimiter :; from command line" as "_";
27 --exec $MYSQL test --delimiter=":;" -e "select * from t1:;"
28 # Test 'go' command (vertical output) \G
29 select "Test 'go' command(vertical output) \G" as "_";
30 --exec $MYSQL test -e "select * from t1\G"
31 # Test 'go' command \g
32 select "Test  'go' command \g" as "_";
33 --exec $MYSQL test -e "select * from t1\g"
34 --enable_query_log
35 drop table t1;
38 # BUG9998 - MySQL client hangs on USE "database"
40 create table t1(a int);
41 lock tables t1 write;
42 --exec $MYSQL -e "use test; select database();"
43 unlock tables;
44 drop table t1;
47 # Bug#16859 -- NULLs in columns must not truncate data as if a C-language "string".
49 --exec $MYSQL -t test -e "create table t1 (col1 binary(4), col2 varchar(10), col3 int); insert into t1 values ('a', 'b', 123421),('a ', '0123456789', 4), ('abcd', '', 4); select concat('>',col1,'<'), col2, col3 from t1; drop table t1;" 2>&1
52 # Bug#17939 Wrong table format when using UTF8 strings
54 --exec $MYSQL --default-character-set=utf8 --table -e "SELECT 'John Doe' as '__tañgè Ñãmé'" 2>&1
55 --exec $MYSQL --default-character-set=utf8 --table -e "SELECT '__tañgè Ñãmé' as 'John Doe'" 2>&1
58 # Bug#18265 -- mysql client: No longer right-justifies numeric columns
60 --exec $MYSQL -t --default-character-set utf8 test -e "create table t1 (i int, j int, k char(25) charset utf8); insert into t1 (i) values (1); insert into t1 (k) values ('<----------------------->'); insert into t1 (k) values ('<-----'); insert into t1 (k) values ('Τη γλώσσα'); insert into t1 (k) values ('ᛖᚴ ᚷᛖᛏ'); select * from t1; DROP TABLE t1;"
63 # "DESCRIBE" commands may return strange NULLness flags.
65 --exec $MYSQL --default-character-set utf8 test -e "create table t1 (i int, j int not null, k int); insert into t1 values (null, 1, null); select * from t1; describe t1; drop table t1;"
66 --exec $MYSQL -t --default-character-set utf8 test -e "create table t1 (i int, j int not null, k int); insert into t1 values (null, 1, null); select * from t1; describe t1; drop table t1;"
69 # Bug#19564: mysql displays NULL instead of space
71 --exec $MYSQL test -e "create table b19564 (i int, s1 char(1)); insert into b19564 values (1, 'x'); insert into b19564 values (2, NULL); insert into b19564 values (3, ' '); select * from b19564 order by i; drop table b19564;" 
72 --exec $MYSQL -t test -e "create table b19564 (i int, s1 char(1)); insert into b19564 values (1, 'x'); insert into b19564 values (2, NULL); insert into b19564 values (3, ' '); select * from b19564 order by i; drop table b19564;" 
75 # Bug#21618: NULL shown as empty string in client
77 --exec $MYSQL test -e "select unhex('zz');" 
78 --exec $MYSQL -t test -e "select unhex('zz');" 
80 # Bug#19265 describe command does not work from mysql prompt
83 create table t1(a int, b varchar(255), c int);
84 --exec $MYSQL test -e "desc t1"
85 --exec $MYSQL test -e "desc t1\g"
86 drop table t1;
88 --disable_parsing
90 # Bug#21042     mysql client segfaults on importing a mysqldump export
92 --error 1
93 --exec $MYSQL test -e "connect verylongdatabasenamethatshouldblowthe256byteslongbufferincom_connectfunctionxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxendcccccccdxxxxxxxxxxxxxxxxxkskskskskkskskskskskskskskskskkskskskskkskskskskskskskskskend" 2>&1
94 --enable_parsing
98 # Bug #20432: mysql client interprets commands in comments
101 --let $file = $MYSQLTEST_VARDIR/tmp/bug20432.sql
103 # if the client sees the 'use' within the comment, we haven't fixed
104 --exec echo "/*"          >  $file
105 --exec echo "use"         >> $file
106 --exec echo "*/"          >> $file
107 --exec $MYSQL              < $file 2>&1
109 # SQL can have embedded comments => workie
110 --exec echo "select /*"   >  $file
111 --exec echo "use"         >> $file
112 --exec echo "*/ 1"        >> $file
113 --exec $MYSQL              < $file 2>&1
115 # client commands on the other hand must be at BOL => error
116 --exec echo "/*"          >  $file
117 --exec echo "xxx"         >> $file
118 --exec echo "*/ use"      >> $file
119 --error 1
120 --exec $MYSQL              < $file 2>&1
122 # client comment recognized, but parameter missing => error
123 --exec echo "use"         >  $file
124 --exec $MYSQL              < $file 2>&1
126 --remove_file $file
129 # Bug #20328: mysql client interprets commands in comments
131 --let $file1 = $MYSQLTEST_VARDIR/tmp/bug20328_1.result
132 --let $file2 = $MYSQLTEST_VARDIR/tmp/bug20328_2.result
133 --exec $MYSQL -e "help" > $file1
134 --exec $MYSQL -e "help " > $file2
135 --diff_files $file1 $file2
136 --remove_file $file1
137 --remove_file $file2
140 # Bug #19216: Client crashes on long SELECT
142 # Create large SELECT
143 # - 3400 * 20 makes 68000 columns that is more than the
144 #   max number that can fit in a 16 bit number.
146 --perl
147 open(FILE,">","$ENV{'MYSQLTEST_VARDIR'}/tmp/b19216.tmp") or die;
148 print FILE "select\n";
149 print FILE "'a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a',\n" x 3400;
150 print FILE "'b';\n";
151 close FILE;
154 --disable_query_log
155 --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/b19216.tmp >/dev/null
156 --enable_query_log
158 --remove_file $MYSQLTEST_VARDIR/tmp/b19216.tmp
161 # Bug #20103: Escaping with backslash does not work
163 --let $file = $MYSQLTEST_VARDIR/tmp/bug20103.sql
164 --exec echo "SET SQL_MODE = 'NO_BACKSLASH_ESCAPES';"  > $file
165 --exec echo "SELECT '\';" >> $file
166 --exec $MYSQL < $file 2>&1
168 --exec echo "SET SQL_MODE = '';"  > $file
169 --exec echo "SELECT '\';';" >> $file
170 --exec $MYSQL              < $file 2>&1
171 --remove_file $file
174 # Bug#17583: mysql drops connection when stdout is not writable
176 create table t17583 (a int);
177 insert into t17583 (a) values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
178 insert into t17583 select a from t17583;
179 insert into t17583 select a from t17583;
180 insert into t17583 select a from t17583;
181 insert into t17583 select a from t17583;
182 insert into t17583 select a from t17583;
183 insert into t17583 select a from t17583;
184 insert into t17583 select a from t17583;
185 # Close to the minimal data needed to exercise bug.
186 select count(*) from t17583;
187 --exec echo "select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; " |$MYSQL test >&-
188 drop table t17583;
191 # Bug#20984: Reproducible MySQL client segmentation fault
192 #  + additional tests for the "com_connect" function in mysql
195 --echo Test connect without db- or host-name => reconnect
196 --exec $MYSQL test -e "\r" 2>&1
197 --exec $MYSQL test -e "connect" 2>&1
199 --echo Test connect with dbname only => new dbname, old hostname
200 --exec $MYSQL test -e "\r test" 2>&1
201 --exec $MYSQL test -e "connect test" 2>&1
202 --exec $MYSQL test -e "\rtest" 2>&1
203 --error 1
204 --exec $MYSQL test -e "connecttest" 2>&1
206 --echo Test connect with _invalid_ dbname only => new invalid dbname, old hostname
207 --error 1
208 --exec $MYSQL test -e "\r invalid" 2>&1
209 --error 1
210 --exec $MYSQL test -e "connect invalid" 2>&1
212 --echo Test connect with dbname + hostname
213 --exec $MYSQL test -e "\r test localhost" 2>&1
214 --exec $MYSQL test -e "connect test localhost" 2>&1
216 --echo Test connect with dbname + _invalid_ hostname
217 # Mask the errno of the error message
218 --replace_regex /\([0-9]*\)/(errno)/
219 --error 1
220 --exec $MYSQL test -e "\r test invalid_hostname" 2>&1
221 --replace_regex /\([0-9]*\)/(errno)/
222 --error 1
223 --exec $MYSQL test -e "connect test invalid_hostname" 2>&1
225 --echo The commands reported in the bug report
226 --replace_regex /\([0-9]*\)/(errno)/
227 --error 1
228 --exec $MYSQL test -e "\r\r\n\r\n cyril\ has\ found\ a\ bug\ :)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 2>&1
230 #--replace_regex /\([0-9]*\)/(errno)/
231 #--error 1
232 #--exec echo '\r\r\n\r\n cyril\ has\ found\ a\ bug\ :)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | $MYSQL 2>&1
234 --echo Too long dbname
235 --error 1
236 --exec $MYSQL test -e "\r test_really_long_dbnamexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx localhost" 2>&1
238 --echo Too long hostname
239 --replace_regex /\([0-9]*\)/(errno)/
240 --error 1
241 --exec $MYSQL test -e "\r  test cyrils_superlonghostnameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 2>&1
245 # Bug #21412: mysql cmdline client allows backslash(es) 
246 # as delimiter but can't recognize them
249 # This should work just fine...
250 --write_file $MYSQLTEST_VARDIR/tmp/bug21412.sql
251 DELIMITER /
252 SELECT 1/
254 --exec $MYSQL             < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1
255 remove_file $MYSQLTEST_VARDIR/tmp/bug21412.sql;
257 # This should give an error...
258 --write_file $MYSQLTEST_VARDIR/tmp/bug21412.sql
259 DELIMITER \
261 --exec $MYSQL             < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1
262 remove_file $MYSQLTEST_VARDIR/tmp/bug21412.sql;
264 # As should this...
265 --write_file $MYSQLTEST_VARDIR/tmp/bug21412.sql
266 DELIMITER \\
268 --exec $MYSQL             < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1
269 remove_file $MYSQLTEST_VARDIR/tmp/bug21412.sql;
272 # Some coverage of not normally used parts
275 --disable_query_log
276 --exec $MYSQL test -e "show status" 2>&1 > /dev/null
277 --exec $MYSQL --help 2>&1 > /dev/null
278 --exec $MYSQL --version 2>&1 > /dev/null
279 --enable_query_log
282 # bug #26851: Mysql Client --pager Buffer Overflow
285 # allow error 7(invalid argument) since --pager does not always exist in mysql
286 --error 0,7
287 --exec $MYSQL --pager="540bytelengthstringxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -e "select 1" > /dev/null 2>&1
288 --exec $MYSQL --character-sets-dir="540bytelengthstringxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -e "select 1" 2>&1
291 # bug #30164: Using client side macro inside server side comments generates broken queries
293 --exec $MYSQL test -e "/*! \C latin1 */ select 1;"
296 # Bug#29323 mysql client only accetps ANSI encoded files
298 --write_file $MYSQLTEST_VARDIR/tmp/bug29323.sql
299 select "This is a file starting with UTF8 BOM 0xEFBBBF";
301 --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug29323.sql 2>&1
302 remove_file $MYSQLTEST_VARDIR/tmp/bug29323.sql;
305 # Bug #33812: mysql client incorrectly parsing DELIMITER
307 # The space and ; after delimiter are important
308 --exec $MYSQL -e "select 1 delimiter ;"
311 # Bug #38158: mysql client regression, can't read dump files
313 --write_file $MYSQLTEST_VARDIR/tmp/bug38158.sql
314 -- Testing
316 delimiter ||
317 select 2 ||
319 --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug38158.sql 2>&1
320 --exec $MYSQL -c < $MYSQLTEST_VARDIR/tmp/bug38158.sql 2>&1
321 remove_file $MYSQLTEST_VARDIR/tmp/bug38158.sql;
324 # Bug #41437: Value stored in 'case' lacks charset, causees segfault
326 --exec $MYSQL -e "select @z:='1',@z=database()"
330 # Bug #31060: MySQL CLI parser bug 2
333 --write_file $MYSQLTEST_VARDIR/tmp/bug31060.sql
334 ;DELIMITER DELIMITER
336 SELECT 1DELIMITER
337 DELIMITER ;
338 SELECT 1;
341 --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug31060.sql 2>&1
343 remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql;
346 # Bug #39101: client -i (--ignore-spaces) option does not seem to work
348 --exec $MYSQL -i -e "SELECT COUNT (*)"
349 --exec $MYSQL --ignore-spaces -e "SELECT COUNT (*)"
350 --exec $MYSQL -b -i -e "SELECT COUNT (*)"
353 # Bug#37268 'binary' character set makes CLI-internal commands case sensitive
355 --replace_regex /\([0-9]*\)/(errno)/
356 --error 1
357 --exec $MYSQL --default-character-set=binary test -e "CONNECT test invalid_hostname" 2>&1
358 --exec $MYSQL --default-character-set=binary test -e "DELIMITER //" 2>&1
360 --echo End of 5.0 tests
363 # Bug #29903: The CMake build method does not produce the embedded library.
365 --disable_query_log
366 --exec $MYSQL --server-arg=no-defaults test -e "quit"
367 --enable_query_log
370 # Bug #25146: Some warnings/errors not shown when using --show-warnings
373 # This one should succeed with no warnings
374 --exec $MYSQL --show-warnings test -e "create table t1 (id int)"
376 # This should succeed, with warnings about conversion from nonexistent engine
377 --exec $MYSQL --show-warnings test -e "create table t2 (id int) engine=nonexistent"
379 # This should fail, with warnings as well
380 --error 1
381 --exec $MYSQL --show-warnings test -e "create table t2 (id int) engine=nonexistent2"
383 drop tables t1, t2;
386 # Bug #27884: mysql --html does not quote HTML special characters in output
388 --write_file $MYSQLTEST_VARDIR/tmp/bug27884.sql
389 SELECT '< & >' AS `<`;
391 --exec $MYSQL --html test < $MYSQLTEST_VARDIR/tmp/bug27884.sql
393 remove_file $MYSQLTEST_VARDIR/tmp/bug27884.sql;
397 # Bug #28203: mysql client + null byte
399 create table t1 (a char(5));
400 insert into t1 values ('\0b\0');
401 --exec $MYSQL test -e "select a from t1"
402 --exec $MYSQL -r test -e "select a from t1"
403 --exec $MYSQL -s test -e "select a from t1"
404 --exec $MYSQL --table test -e "select a from t1"
405 --exec $MYSQL --vertical test -e "select a from t1"
406 --exec $MYSQL --html test -e "select a from t1"
407 --exec $MYSQL --xml test -e "select a from t1"
408 drop table t1;
410 --echo
411 --echo Bug #47147: mysql client option --skip-column-names does not apply to vertical output
412 --echo
413 --exec $MYSQL --skip-column-names --vertical test -e "select 1 as a"
416 # Bug#57450: mysql client enter in an infinite loop if the standard input is a directory
418 --error 1
419 --exec $MYSQL < .
421 --echo
423 --echo #
424 --echo # Bug #54899: --one-database option cannot handle DROP/CREATE DATABASE 
425 --echo #             commands.
426 --echo #
427 --write_file $MYSQLTEST_VARDIR/tmp/bug54899.sql
428 DROP DATABASE connected_db;
429 CREATE DATABASE connected_db;
430 USE connected_db;
431 CREATE TABLE `table_in_connected_db`(a INT);
434 CREATE DATABASE connected_db;
435 --exec $MYSQL --one-database connected_db < $MYSQLTEST_VARDIR/tmp/bug54899.sql
436 USE connected_db;
437 SHOW TABLES;
438 DROP DATABASE connected_db;
439 --remove_file $MYSQLTEST_VARDIR/tmp/bug54899.sql
441 --echo
443 --echo #
444 --echo # Testing --one-database option
445 --echo #
446 --write_file $MYSQLTEST_VARDIR/tmp/one_db.sql
447 CREATE TABLE t1 (i INT);
448 CREATE TABLE test.t1 (i INT);
449 USE test;
450 # Following statements should be filtered.
451 CREATE TABLE connected_db.t2 (i INT);
452 CREATE TABLE t2 (i INT);
455 CREATE DATABASE connected_db;
456 --exec $MYSQL --one-database connected_db < $MYSQLTEST_VARDIR/tmp/one_db.sql
457 SHOW TABLES IN connected_db;
458 SHOW TABLES IN test;
459 USE test;
460 DROP TABLE t1;
461 DROP DATABASE connected_db;
462 --remove_file $MYSQLTEST_VARDIR/tmp/one_db.sql
464 --echo
465 --write_file $MYSQLTEST_VARDIR/tmp/one_db.sql
466 CREATE DATABASE test1;
467 USE test1;
468 USE test1;
469 # Following statements should be filtered.
470 CREATE TABLE connected_db.t1 (i INT);
473 --exec $MYSQL --one-database test < $MYSQLTEST_VARDIR/tmp/one_db.sql
474 SHOW TABLES IN test;
475 SHOW TABLES IN test1;
476 DROP DATABASE test1;
477 --remove_file $MYSQLTEST_VARDIR/tmp/one_db.sql
479 --echo
481 --echo #
482 --echo # Checking --one-database option followed by the execution of 
483 --echo # connect command.
484 --echo #
485 --write_file $MYSQLTEST_VARDIR/tmp/one_db.sql
486 CREATE TABLE t1 (i INT);
487 CREATE TABLE test.t1 (i INT);
488 CONNECT test;
489 CREATE TABLE connected_db.t2 (i INT);
490 CREATE TABLE t2 (i INT);
491 USE connected_db;
492 # Following statements should be filtered.
493 CREATE TABLE connected_db.t3 (i INT);
494 CREATE TABLE t3 (i INT);
497 CREATE DATABASE connected_db;
498 --exec $MYSQL --one-database connected_db < $MYSQLTEST_VARDIR/tmp/one_db.sql
499 SHOW TABLES IN connected_db;
500 SHOW TABLES IN test;
501 DROP TABLE test.t1;
502 DROP TABLE test.t2;
503 DROP DATABASE connected_db;
504 --remove_file $MYSQLTEST_VARDIR/tmp/one_db.sql
506 --echo
508 --echo #
509 --echo # Checking --one-database option with no database specified
510 --echo # at command-line.
511 --echo #
512 --write_file $MYSQLTEST_VARDIR/tmp/one_db.sql
513 # All following statements should be filtered.
514 CREATE TABLE t1 (i INT);
515 CREATE TABLE test.t1 (i INT);
516 USE test;
517 CREATE TABLE test.t2 (i INT);
518 CREATE TABLE t2 (i INT);
521 --exec $MYSQL --one-database < $MYSQLTEST_VARDIR/tmp/one_db.sql
522 SHOW TABLES IN test;
523 --remove_file $MYSQLTEST_VARDIR/tmp/one_db.sql
525 --echo
527 --echo #
528 --echo # Checking --one-database option with non_existent_db 
529 --echo # specified with USE command
530 --echo #
532 # CASE 1 : When 'connected_db' database exists and passed at commandline.
533 --write_file $MYSQLTEST_VARDIR/tmp/one_db_1.sql
534 CREATE TABLE `table_in_connected_db`(i INT);
535 USE non_existent_db;
536 # Following statement should be filtered out.
537 CREATE TABLE `table_in_non_existent_db`(i INT);
540 # CASE 2 : When 'connected_db' database exists but dropped and recreated in
541 # load file.
542 --write_file $MYSQLTEST_VARDIR/tmp/one_db_2.sql
543 DROP DATABASE connected_db;
544 CREATE DATABASE connected_db;
545 USE non_existent_db;
546 # Following statements should be filtered out.
547 CREATE TABLE `table_in_non_existent_db`(i INT);
548 USE connected_db;
549 # Following statements should not be filtered out.
550 CREATE TABLE `table_in_connected_db`(i INT);
553 CREATE DATABASE connected_db;
554 --exec $MYSQL --one-database connected_db < $MYSQLTEST_VARDIR/tmp/one_db_1.sql
555 SHOW TABLES IN connected_db;
556 --echo
557 --exec $MYSQL --one-database connected_db < $MYSQLTEST_VARDIR/tmp/one_db_2.sql
558 SHOW TABLES IN connected_db;
559 DROP DATABASE connected_db;
561 --remove_file $MYSQLTEST_VARDIR/tmp/one_db_1.sql
562 --remove_file $MYSQLTEST_VARDIR/tmp/one_db_2.sql
564 --echo
565 --echo End of tests