1-- source include/have_working_dns.inc 2# This test should work in embedded server after we fix mysqltest 3-- source include/not_embedded.inc 4# 5# Testing the MySQL command line client(mysql) 6# 7set GLOBAL sql_mode=""; 8set LOCAL sql_mode=""; 9 10--disable_warnings 11drop table if exists t1,t2,t3; 12--enable_warnings 13 14# 15# Test the "delimiter" functionality 16# Bug#9879 17# 18create table t1(a int); 19insert into t1 values(1); 20 21# Test delimiters 22--exec $MYSQL test 2>&1 < "./main/mysql_delimiter.sql" 23 24--disable_query_log 25# Test delimiter : supplied on the command line 26select "Test delimiter : from command line" as "_"; 27--exec $MYSQL test --delimiter=":" -e "select * from t1:" 28# Test delimiter :; supplied on the command line 29select "Test delimiter :; from command line" as "_"; 30--exec $MYSQL test --delimiter=":;" -e "select * from t1:;" 31# Test 'go' command (vertical output) \G 32select "Test 'go' command(vertical output) \G" as "_"; 33--exec $MYSQL test -e "select * from t1\G" 34# Test 'go' command \g 35select "Test 'go' command \g" as "_"; 36--exec $MYSQL test -e "select * from t1\g" 37--enable_query_log 38drop table t1; 39 40# 41# BUG9998 - MySQL client hangs on USE "database" 42# 43create table t1(a int); 44lock tables t1 write; 45--exec $MYSQL -e "use test; select database();" 46unlock tables; 47drop table t1; 48 49# 50# Bug#16859 -- NULLs in columns must not truncate data as if a C-language "string". 51# 52--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 53 54# 55# Bug#17939 Wrong table format when using UTF8 strings 56write_file $MYSQL_TMP_DIR/mysql_in; 57SELECT 'John Doe' as '__tañgè Ñãmé'; 58SELECT '__tañgè Ñãmé' as 'John Doe'; 59EOF 60--exec $MYSQL --default-character-set=utf8 --table < $MYSQL_TMP_DIR/mysql_in 2>&1 61remove_file $MYSQL_TMP_DIR/mysql_in; 62 63# 64# Bug#18265 -- mysql client: No longer right-justifies numeric columns 65# 66write_file $MYSQL_TMP_DIR/mysql_in; 67create 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; 68EOF 69--exec $MYSQL -t --default-character-set utf8 test < $MYSQL_TMP_DIR/mysql_in 70remove_file $MYSQL_TMP_DIR/mysql_in; 71 72 73# 74# "DESCRIBE" commands may return strange NULLness flags. 75# 76--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;" 77--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;" 78 79# 80# Bug#19564: mysql displays NULL instead of space 81# 82--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;" 83--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;" 84 85# 86# Bug#21618: NULL shown as empty string in client 87# 88--exec $MYSQL test -e "select unhex('zz');" 89--exec $MYSQL -t test -e "select unhex('zz');" 90 91# Bug#19265 describe command does not work from mysql prompt 92# 93 94create table t1(a int, b varchar(255), c int); 95--exec $MYSQL test -e "desc t1" 96--exec $MYSQL test -e "desc t1\g" 97drop table t1; 98 99--disable_parsing 100# 101# Bug#21042 mysql client segfaults on importing a mysqldump export 102# 103--error 1 104--exec $MYSQL test -e "connect verylongdatabasenamethatshouldblowthe256byteslongbufferincom_connectfunctionxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxendcccccccdxxxxxxxxxxxxxxxxxkskskskskkskskskskskskskskskskkskskskskkskskskskskskskskskend" 2>&1 105--enable_parsing 106 107 108# 109# Bug #20432: mysql client interprets commands in comments 110# 111 112--let $file = $MYSQLTEST_VARDIR/tmp/bug20432.sql 113 114# if the client sees the 'use' within the comment, we haven't fixed 115--exec echo "/*" > $file 116--exec echo "use" >> $file 117--exec echo "*/" >> $file 118--exec $MYSQL < $file 2>&1 119 120# SQL can have embedded comments => workie 121--exec echo "select /*" > $file 122--exec echo "use" >> $file 123--exec echo "*/ 1" >> $file 124--exec $MYSQL < $file 2>&1 125 126# client commands on the other hand must be at BOL => error 127--exec echo "/*" > $file 128--exec echo "xxx" >> $file 129--exec echo "*/ use" >> $file 130--error 1 131--exec $MYSQL < $file 2>&1 132 133# client comment recognized, but parameter missing => error 134--exec echo "use" > $file 135--exec $MYSQL < $file 2>&1 136 137# Test exceutable comments 138--exec echo "SELECT 1 /*! +1 */;" > $file 139--exec echo "SELECT 1 /*M! +1 */;" >> $file 140--exec echo "SELECT 1 /*!00000 +1 */;" >> $file 141--exec echo "SELECT 1 /*M!00000 +1 */" >> $file 142--exec $MYSQL < $file 2>&1 143 144--remove_file $file 145 146# 147# Bug #20328: mysql client interprets commands in comments 148# 149--let $file1 = $MYSQLTEST_VARDIR/tmp/bug20328_1.result 150--let $file2 = $MYSQLTEST_VARDIR/tmp/bug20328_2.result 151--exec $MYSQL -e "help" > $file1 152--exec $MYSQL -e "help " > $file2 153--diff_files $file1 $file2 154--remove_file $file1 155--remove_file $file2 156 157# 158# Bug #19216: Client crashes on long SELECT 159# 160# Create large SELECT 161# - 3400 * 20 makes 68000 columns that is more than the 162# max number that can fit in a 16 bit number. 163 164--perl 165open(FILE,">","$ENV{'MYSQLTEST_VARDIR'}/tmp/b19216.tmp") or die; 166print FILE "select\n"; 167print FILE "'a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a',\n" x 3400; 168print FILE "'b';\n"; 169close FILE; 170EOF 171 172--disable_query_log 173--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/b19216.tmp >/dev/null 174--enable_query_log 175 176--remove_file $MYSQLTEST_VARDIR/tmp/b19216.tmp 177 178# 179# Bug #20103: Escaping with backslash does not work 180# 181--let $file = $MYSQLTEST_VARDIR/tmp/bug20103.sql 182--exec echo "SET SQL_MODE = 'NO_BACKSLASH_ESCAPES';" > $file 183--exec echo "SELECT '\';" >> $file 184--exec $MYSQL < $file 2>&1 185 186--exec echo "SET SQL_MODE = '';" > $file 187--exec echo "SELECT '\';';" >> $file 188--exec $MYSQL < $file 2>&1 189--remove_file $file 190 191# 192# Bug#17583: mysql drops connection when stdout is not writable 193# 194create table t17583 (a int); 195insert into t17583 (a) values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 196insert into t17583 select a from t17583; 197insert into t17583 select a from t17583; 198insert into t17583 select a from t17583; 199insert into t17583 select a from t17583; 200insert into t17583 select a from t17583; 201insert into t17583 select a from t17583; 202insert into t17583 select a from t17583; 203# Close to the minimal data needed to exercise bug. 204select count(*) from t17583; 205--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 >&- 206drop table t17583; 207 208# 209# Bug#20984: Reproducible MySQL client segmentation fault 210# + additional tests for the "com_connect" function in mysql 211# 212# 213--echo Test connect without db- or host-name => reconnect 214--exec $MYSQL test -e "\r" 2>&1 215--exec $MYSQL test -e "connect" 2>&1 216 217--echo Test connect with dbname only => new dbname, old hostname 218--exec $MYSQL test -e "\r test" 2>&1 219--exec $MYSQL test -e "connect test" 2>&1 220--exec $MYSQL test -e "\rtest" 2>&1 221--error 1 222--exec $MYSQL test -e "connecttest" 2>&1 223 224--echo Test connect with _invalid_ dbname only => new invalid dbname, old hostname 225--error 1 226--exec $MYSQL test -e "\r invalid" 2>&1 227--error 1 228--exec $MYSQL test -e "connect invalid" 2>&1 229 230--echo Test connect with dbname + hostname 231--exec $MYSQL test -e "\r test localhost" 2>&1 232--exec $MYSQL test -e "connect test localhost" 2>&1 233 234--echo Test connect with dbname + _invalid_ hostname 235# Mask the errno of the error message 236--replace_regex /\([0-9|-]*\)/(errno)/ 237--error 1 238--exec $MYSQL test -e "\r test invalid_hostname" 2>&1 239--replace_regex /\([0-9|-]*\)/(errno)/ 240--error 1 241--exec $MYSQL test -e "connect test invalid_hostname" 2>&1 242 243--echo The commands reported in the bug report 244--replace_regex /\([0-9|-]*\)/(errno)/ 245--error 1 246--exec $MYSQL test -e "\r\r\n\r\n cyril\ has\ found\ a\ bug\ :)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 2>&1 247 248#--replace_regex /\([0-9|-]*\)/(errno)/ 249#--error 1 250#--exec echo '\r\r\n\r\n cyril\ has\ found\ a\ bug\ :)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | $MYSQL 2>&1 251 252--echo Too long dbname 253--error 1 254--exec $MYSQL test -e "\r test_really_long_dbnamexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx localhost" 2>&1 255 256--echo Too long hostname 257--replace_regex /\([0-9|-]*\)/(errno)/ 258--error 1 259--exec $MYSQL test -e "\r test cyrils_superlonghostnameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 2>&1 260 261 262# 263# Bug #21412: mysql cmdline client allows backslash(es) 264# as delimiter but can't recognize them 265# 266 267# This should work just fine... 268--write_file $MYSQLTEST_VARDIR/tmp/bug21412.sql 269DELIMITER / 270SELECT 1/ 271EOF 272--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1 273remove_file $MYSQLTEST_VARDIR/tmp/bug21412.sql; 274 275# This should give an error... 276--write_file $MYSQLTEST_VARDIR/tmp/bug21412.sql 277DELIMITER \ 278EOF 279--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1 280remove_file $MYSQLTEST_VARDIR/tmp/bug21412.sql; 281 282# As should this... 283--write_file $MYSQLTEST_VARDIR/tmp/bug21412.sql 284DELIMITER \\ 285EOF 286--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1 287remove_file $MYSQLTEST_VARDIR/tmp/bug21412.sql; 288 289# 290# Some coverage of not normally used parts 291# 292 293--disable_query_log 294--exec $MYSQL test -e "show status" 2>&1 > /dev/null 295--exec $MYSQL --help 2>&1 > /dev/null 296--exec $MYSQL --version 2>&1 > /dev/null 297--enable_query_log 298 299# 300# bug #26851: Mysql Client --pager Buffer Overflow 301# 302 303# allow error 7(invalid argument) since --pager does not always exist in mysql 304--error 0,7 305--exec $MYSQL --pager="540bytelengthstringxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -e "select 1" > /dev/null 2>&1 306--exec $MYSQL --character-sets-dir="540bytelengthstringxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -e "select 1" 2>&1 307 308# 309# bug #30164: Using client side macro inside server side comments generates broken queries 310# 311--exec $MYSQL test -e "/*! \C latin1 */ select 1;" 312 313# 314# Bug#29323 mysql client only accetps ANSI encoded files 315# 316--write_file $MYSQLTEST_VARDIR/tmp/bug29323.sql 317select "This is a file starting with UTF8 BOM 0xEFBBBF"; 318EOF 319--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug29323.sql 2>&1 320remove_file $MYSQLTEST_VARDIR/tmp/bug29323.sql; 321 322# 323# Bug #33812: mysql client incorrectly parsing DELIMITER 324# 325# The space and ; after delimiter are important 326--exec $MYSQL -e "select 1 delimiter ;" 327 328# 329# Bug #38158: mysql client regression, can't read dump files 330# 331--write_file $MYSQLTEST_VARDIR/tmp/bug38158.sql 332-- Testing 333-- 334delimiter || 335select 2 || 336EOF 337--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug38158.sql 2>&1 338--exec $MYSQL -c < $MYSQLTEST_VARDIR/tmp/bug38158.sql 2>&1 339remove_file $MYSQLTEST_VARDIR/tmp/bug38158.sql; 340 341# 342# Bug #41437: Value stored in 'case' lacks charset, causees segfault 343# 344--exec $MYSQL -e "select @z:='1',@z=database()" 345 346 347# 348# Bug #31060: MySQL CLI parser bug 2 349# 350 351--write_file $MYSQLTEST_VARDIR/tmp/bug31060.sql 352;DELIMITER DELIMITER 353; 354SELECT 1DELIMITER 355DELIMITER ; 356SELECT 1; 357EOF 358 359--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug31060.sql 2>&1 360 361remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql; 362 363# 364# Bug #39101: client -i (--ignore-spaces) option does not seem to work 365# 366--exec $MYSQL -i -e "SELECT COUNT (*)" 367--exec $MYSQL --ignore-spaces -e "SELECT COUNT (*)" 368--exec $MYSQL -b -i -e "SELECT COUNT (*)" 369 370# 371# Bug#37268 'binary' character set makes CLI-internal commands case sensitive 372# 373--replace_regex /\([0-9|-]*\)/(errno)/ 374--error 1 375--exec $MYSQL --default-character-set=binary test -e "CONNECT test invalid_hostname" 2>&1 376--exec $MYSQL --default-character-set=binary test -e "DELIMITER //" 2>&1 377 378--echo End of 5.0 tests 379 380# 381# Bug #29903: The CMake build method does not produce the embedded library. 382# 383--disable_query_log 384--exec $MYSQL --server-arg=no-defaults test -e "quit" 385--enable_query_log 386 387# 388# Bug#26780: patch to add auto vertical output option to the cli. 389# 390# Make this wide enough that it will wrap almost everywhere. 391--exec $MYSQL test --auto-vertical-output --table -e "SELECT 1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0;" 392# Too short to wrap. 393--exec $MYSQL test --auto-vertical-output --table -e "SELECT 1;" 394 395# 396# Bug #25146: Some warnings/errors not shown when using --show-warnings 397# 398 399# This one should succeed with no warnings 400--exec $MYSQL --show-warnings test -e "create table t1 (id int)" 401 402# This should succeed, with warnings about conversion from nonexistent engine 403--exec $MYSQL --show-warnings test -e "create table t2 (id int) engine=nonexistent" 404 405# This should fail, with warnings as well 406--error 1 407--exec $MYSQL --show-warnings test -e "create table t2 (id int) engine=nonexistent2" 408 409drop tables t1, t2; 410 411# 412# mysql client with 'init-command' option 413# 414--exec $MYSQL --init-command="SET lc_messages=ru_RU" -e "SHOW VARIABLES LIKE 'lc_messages';" 415 416# 417# Bug #27884: mysql --html does not quote HTML special characters in output 418# 419--write_file $MYSQLTEST_VARDIR/tmp/bug27884.sql 420SELECT '< & >' AS `<`; 421EOF 422--exec $MYSQL --html test < $MYSQLTEST_VARDIR/tmp/bug27884.sql 423 424remove_file $MYSQLTEST_VARDIR/tmp/bug27884.sql; 425 426 427# 428# Bug #28203: mysql client + null byte 429# 430create table t1 (a char(5)); 431insert into t1 values ('\0b\0'); 432--exec $MYSQL test -e "select a from t1" 433--exec $MYSQL -r test -e "select a from t1" 434--exec $MYSQL -s test -e "select a from t1" 435--exec $MYSQL --table test -e "select a from t1" 436--exec $MYSQL --vertical test -e "select a from t1" 437--exec $MYSQL --html test -e "select a from t1" 438--exec $MYSQL --xml test -e "select a from t1" 439drop table t1; 440 441--echo 442--echo Bug #47147: mysql client option --skip-column-names does not apply to vertical output 443--echo 444--exec $MYSQL --skip-column-names --vertical test -e "select 1 as a" 445 446# 447# Bug#57450: mysql client enter in an infinite loop if the standard input is a directory 448# 449--error 1 450--exec $MYSQL < . 451 452--echo 453 454--echo # 455--echo # Bug #54899: --one-database option cannot handle DROP/CREATE DATABASE 456--echo # commands. 457--echo # 458--write_file $MYSQLTEST_VARDIR/tmp/bug54899.sql 459DROP DATABASE connected_db; 460CREATE DATABASE connected_db; 461USE connected_db; 462CREATE TABLE `table_in_connected_db`(a INT); 463EOF 464 465CREATE DATABASE connected_db; 466--exec $MYSQL --one-database connected_db < $MYSQLTEST_VARDIR/tmp/bug54899.sql 467USE connected_db; 468SHOW TABLES; 469DROP DATABASE connected_db; 470--remove_file $MYSQLTEST_VARDIR/tmp/bug54899.sql 471 472--echo 473 474--echo # 475--echo # Testing --one-database option 476--echo # 477--write_file $MYSQLTEST_VARDIR/tmp/one_db.sql 478CREATE TABLE t1 (i INT); 479CREATE TABLE test.t1 (i INT); 480USE test; 481# Following statements should be filtered. 482CREATE TABLE connected_db.t2 (i INT); 483CREATE TABLE t2 (i INT); 484EOF 485 486CREATE DATABASE connected_db; 487--exec $MYSQL --one-database connected_db < $MYSQLTEST_VARDIR/tmp/one_db.sql 488SHOW TABLES IN connected_db; 489SHOW TABLES IN test; 490USE test; 491DROP TABLE t1; 492DROP DATABASE connected_db; 493--remove_file $MYSQLTEST_VARDIR/tmp/one_db.sql 494 495--echo 496--write_file $MYSQLTEST_VARDIR/tmp/one_db.sql 497CREATE DATABASE test1; 498USE test1; 499USE test1; 500# Following statements should be filtered. 501CREATE TABLE connected_db.t1 (i INT); 502EOF 503 504--exec $MYSQL --one-database test < $MYSQLTEST_VARDIR/tmp/one_db.sql 505SHOW TABLES IN test; 506SHOW TABLES IN test1; 507DROP DATABASE test1; 508--remove_file $MYSQLTEST_VARDIR/tmp/one_db.sql 509 510--echo 511 512--echo # 513--echo # Checking --one-database option followed by the execution of 514--echo # connect command. 515--echo # 516--write_file $MYSQLTEST_VARDIR/tmp/one_db.sql 517CREATE TABLE t1 (i INT); 518CREATE TABLE test.t1 (i INT); 519CONNECT test; 520CREATE TABLE connected_db.t2 (i INT); 521CREATE TABLE t2 (i INT); 522USE connected_db; 523# Following statements should be filtered. 524CREATE TABLE connected_db.t3 (i INT); 525CREATE TABLE t3 (i INT); 526EOF 527 528CREATE DATABASE connected_db; 529--exec $MYSQL --one-database connected_db < $MYSQLTEST_VARDIR/tmp/one_db.sql 530SHOW TABLES IN connected_db; 531SHOW TABLES IN test; 532DROP TABLE test.t1; 533DROP TABLE test.t2; 534DROP DATABASE connected_db; 535--remove_file $MYSQLTEST_VARDIR/tmp/one_db.sql 536 537--echo 538 539--echo # 540--echo # Checking --one-database option with no database specified 541--echo # at command-line. 542--echo # 543--write_file $MYSQLTEST_VARDIR/tmp/one_db.sql 544# All following statements should be filtered. 545CREATE TABLE t1 (i INT); 546CREATE TABLE test.t1 (i INT); 547USE test; 548CREATE TABLE test.t2 (i INT); 549CREATE TABLE t2 (i INT); 550EOF 551 552--exec $MYSQL --one-database < $MYSQLTEST_VARDIR/tmp/one_db.sql 553SHOW TABLES IN test; 554--remove_file $MYSQLTEST_VARDIR/tmp/one_db.sql 555 556--echo 557 558--echo # 559--echo # Checking --one-database option with non_existent_db 560--echo # specified with USE command 561--echo # 562 563# CASE 1 : When 'connected_db' database exists and passed at commandline. 564--write_file $MYSQLTEST_VARDIR/tmp/one_db_1.sql 565CREATE TABLE `table_in_connected_db`(i INT); 566USE non_existent_db; 567# Following statement should be filtered out. 568CREATE TABLE `table_in_non_existent_db`(i INT); 569EOF 570 571# CASE 2 : When 'connected_db' database exists but dropped and recreated in 572# load file. 573--write_file $MYSQLTEST_VARDIR/tmp/one_db_2.sql 574DROP DATABASE connected_db; 575CREATE DATABASE connected_db; 576USE non_existent_db; 577# Following statements should be filtered out. 578CREATE TABLE `table_in_non_existent_db`(i INT); 579USE connected_db; 580# Following statements should not be filtered out. 581CREATE TABLE `table_in_connected_db`(i INT); 582EOF 583 584CREATE DATABASE connected_db; 585--exec $MYSQL --one-database connected_db < $MYSQLTEST_VARDIR/tmp/one_db_1.sql 586SHOW TABLES IN connected_db; 587--echo 588--exec $MYSQL --one-database connected_db < $MYSQLTEST_VARDIR/tmp/one_db_2.sql 589SHOW TABLES IN connected_db; 590DROP DATABASE connected_db; 591 592--remove_file $MYSQLTEST_VARDIR/tmp/one_db_1.sql 593--remove_file $MYSQLTEST_VARDIR/tmp/one_db_2.sql 594 595# 596# USE and names with backticks 597# 598--write_file $MYSQLTEST_VARDIR/tmp/backticks.sql 599\u aa`bb``cc 600SELECT DATABASE(); 601USE test 602SELECT DATABASE(); 603USE aa`bb``cc 604SELECT DATABASE(); 605USE test 606SELECT DATABASE(); 607USE `aa``bb````cc` 608SELECT DATABASE(); 609EOF 610create database `aa``bb````cc`; 611--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/backticks.sql 612drop database `aa``bb````cc`; 613 614# 615# MySQL Bug#13639125 DELIMITER STRIPS THE NEXT NEW LINE IN A SQL STATEMENT 616# 617--write_file $MYSQLTEST_VARDIR/tmp/13639125.sql 618select ">> 619delimiter 620<<" as a; 621EOF 622--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/13639125.sql 623 624# 625# --skip-column-names and alignment 626# 627--exec $MYSQL -t -N -e "SELECT 'a' union select 'aaaaaaaaaaaaaaaaa'" 628 629--echo # 630--echo # Start of 10.1 tests 631--echo # 632 633--echo # 634--echo # MDEV-6572 "USE dbname" with a bad sequence erroneously connects to a wrong database 635--echo # 636 637--echo # 638--echo # End of 10.1 tests 639--echo # 640 641 642--write_file $MYSQLTEST_VARDIR/tmp/mdev-6572.sql 643SET NAMES utf8; 644USE test ; 645EOF 646--error 1 647--exec $MYSQL --default-character-set=utf8 < $MYSQLTEST_VARDIR/tmp/mdev-6572.sql 2>&1 648--remove_file $MYSQLTEST_VARDIR/tmp/mdev-6572.sql 649 650set GLOBAL sql_mode=default; 651--echo 652--echo End of tests 653 654# 655# MDEV-13187 incorrect backslash parsing in clients 656# 657create table `a1\``b1` (a int); 658show tables; 659insert `a1\``b1` values (1),(2); 660show create table `a1\``b1`; 661--exec $MYSQL_DUMP --compact test 662--exec $MYSQL_DUMP test > $MYSQLTEST_VARDIR/tmp/bug.sql 663insert `a1\``b1` values (4),(5); 664--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug.sql 665show create table `a1\``b1`; 666select * from `a1\``b1`; 667drop table `a1\``b1`; 668 669# same with ansi_quotes 670set sql_mode=ansi_quotes; 671create table "a1\""b1" (a int); 672show tables; 673insert "a1\""b1" values (1),(2); 674show create table "a1\""b1"; 675--exec $MYSQL_DUMP --compact --compatible=postgres test 676--exec $MYSQL_DUMP --compatible=postgres test > $MYSQLTEST_VARDIR/tmp/bug.sql 677insert "a1\""b1" values (4),(5); 678--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug.sql 679show create table "a1\""b1"; 680select * from "a1\""b1"; 681drop table "a1\""b1"; 682set sql_mode=default; 683 684# 685# mysql --local-infile 686# 687--let $ldli = load data local infile '$MYSQLTEST_VARDIR/tmp/bug.sql' into table test.t1; 688create table t1 (a text); 689--exec $MYSQL -e "$ldli" 690select count(*) from t1; truncate table t1; 691--exec $MYSQL --enable-local-infile -e "$ldli" 692select count(*) from t1; truncate table t1; 693--error 1 694--exec $MYSQL --disable-local-infile -e "$ldli" 695select count(*) from t1; truncate table t1; 696--error 1 697--exec $MYSQL --local-infile=0 -e "/*q*/$ldli" 698select count(*) from t1; truncate table t1; 699--exec $MYSQL --enable-local-infile -e "/*q*/$ldli" 700select count(*) from t1; truncate table t1; 701 --error 1 702 --exec $MYSQL --disable-local-infile -e "/*q*/$ldli" 703select count(*) from t1; truncate table t1; 704drop table t1; 705 706 707--echo # 708--echo # MDEV-15538 '-N' Produce html output wrong 709--echo # 710--exec $MYSQL -NHe "select 1 as a" 711