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)
8
drop table if exists t1;
12
# Test the "delimiter" functionality
15
create table t1(a int);
16
insert into t1 values(1);
19
--exec $MYSQL test 2>&1 < "./t/mysql_delimiter.sql"
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"
38
# BUG9998 - MySQL client hangs on USE "database"
40
create table t1(a int);
42
--exec $MYSQL -e "use test; select database();"
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"
90
# Bug#21042 mysql client segfaults on importing a mysqldump export
93
--exec $MYSQL test -e "connect verylongdatabasenamethatshouldblowthe256byteslongbufferincom_connectfunctionxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxendcccccccdxxxxxxxxxxxxxxxxxkskskskskkskskskskskskskskskskkskskskskkskskskskskskskskskend" 2>&1
98
# Bug #20432: mysql client interprets commands in comments
101
# if the client sees the 'use' within the comment, we haven't fixed
102
--exec echo "/*" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
103
--exec echo "use" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
104
--exec echo "*/" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
105
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
107
# SQL can have embedded comments => workie
108
--exec echo "select /*" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
109
--exec echo "use" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
110
--exec echo "*/ 1" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
111
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
113
# client commands on the other hand must be at BOL => error
114
--exec echo "/*" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
115
--exec echo "xxx" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
116
--exec echo "*/ use" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
118
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
120
# client comment recognized, but parameter missing => error
121
--exec echo "use" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
122
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
125
# Bug #20328: mysql client interprets commands in comments
127
--exec $MYSQL -e "help" > $MYSQLTEST_VARDIR/tmp/bug20328_1.result
128
--exec $MYSQL -e "help " > $MYSQLTEST_VARDIR/tmp/bug20328_2.result
129
--diff_files $MYSQLTEST_VARDIR/tmp/bug20328_1.result $MYSQLTEST_VARDIR/tmp/bug20328_2.result
132
# Bug #19216: Client crashes on long SELECT
134
# Create large SELECT
135
# - 3400 * 20 makes 68000 columns that is more than the
136
# max number that can fit in a 16 bit number.
139
open(FILE,">","$ENV{'MYSQLTEST_VARDIR'}/tmp/b19216.tmp") or die;
140
print FILE "select\n";
141
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;
147
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/b19216.tmp >/dev/null
150
--remove_file $MYSQLTEST_VARDIR/tmp/b19216.tmp
153
# Bug #20103: Escaping with backslash does not work
155
--exec echo "SET SQL_MODE = 'NO_BACKSLASH_ESCAPES';" > $MYSQLTEST_VARDIR/tmp/bug20103.sql
156
--exec echo "SELECT '\';" >> $MYSQLTEST_VARDIR/tmp/bug20103.sql
157
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20103.sql 2>&1
159
--exec echo "SET SQL_MODE = '';" > $MYSQLTEST_VARDIR/tmp/bug20103.sql
160
--exec echo "SELECT '\';';" >> $MYSQLTEST_VARDIR/tmp/bug20103.sql
161
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20103.sql 2>&1
164
# Bug#17583: mysql drops connection when stdout is not writable
166
create table t17583 (a int);
167
insert into t17583 (a) values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
168
insert into t17583 select a from t17583;
169
insert into t17583 select a from t17583;
170
insert into t17583 select a from t17583;
171
insert into t17583 select a from t17583;
172
insert into t17583 select a from t17583;
173
insert into t17583 select a from t17583;
174
insert into t17583 select a from t17583;
175
# Close to the minimal data needed to exercise bug.
176
select count(*) from t17583;
177
--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 >&-
181
# Bug#20984: Reproducible MySQL client segmentation fault
182
# + additional tests for the "com_connect" function in mysql
185
--echo Test connect without db- or host-name => reconnect
186
--exec $MYSQL test -e "\r" 2>&1
187
--exec $MYSQL test -e "connect" 2>&1
189
--echo Test connect with dbname only => new dbname, old hostname
190
--exec $MYSQL test -e "\r test" 2>&1
191
--exec $MYSQL test -e "connect test" 2>&1
192
--exec $MYSQL test -e "\rtest" 2>&1
194
--exec $MYSQL test -e "connecttest" 2>&1
196
--echo Test connect with _invalid_ dbname only => new invalid dbname, old hostname
198
--exec $MYSQL test -e "\r invalid" 2>&1
200
--exec $MYSQL test -e "connect invalid" 2>&1
202
--echo Test connect with dbname + hostname
203
--exec $MYSQL test -e "\r test localhost" 2>&1
204
--exec $MYSQL test -e "connect test localhost" 2>&1
206
--echo Test connect with dbname + _invalid_ hostname
207
# Mask the errno of the error message
208
--replace_regex /\([0-9]*\)/(errno)/
210
--exec $MYSQL test -e "\r test invalid_hostname" 2>&1
211
--replace_regex /\([0-9]*\)/(errno)/
213
--exec $MYSQL test -e "connect test invalid_hostname" 2>&1
215
--echo The commands reported in the bug report
216
--replace_regex /\([0-9]*\)/(errno)/
218
--exec $MYSQL test -e "\r\r\n\r\n cyril\ has\ found\ a\ bug\ :)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 2>&1
220
#--replace_regex /\([0-9]*\)/(errno)/
222
#--exec echo '\r\r\n\r\n cyril\ has\ found\ a\ bug\ :)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | $MYSQL 2>&1
224
--echo Too long dbname
226
--exec $MYSQL test -e "\r test_really_long_dbnamexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx localhost" 2>&1
228
--echo Too long hostname
229
--replace_regex /\([0-9]*\)/(errno)/
231
--exec $MYSQL test -e "\r test cyrils_superlonghostnameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 2>&1
235
# Bug #21412: mysql cmdline client allows backslash(es)
236
# as delimiter but can't recognize them
239
# This should work just fine...
240
--write_file $MYSQLTEST_VARDIR/tmp/bug21412.sql
244
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1
245
remove_file $MYSQLTEST_VARDIR/tmp/bug21412.sql;
247
# This should give an error...
248
--write_file $MYSQLTEST_VARDIR/tmp/bug21412.sql
251
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1
252
remove_file $MYSQLTEST_VARDIR/tmp/bug21412.sql;
255
--write_file $MYSQLTEST_VARDIR/tmp/bug21412.sql
258
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1
259
remove_file $MYSQLTEST_VARDIR/tmp/bug21412.sql;
262
# Some coverage of not normally used parts
266
--exec $MYSQL test -e "show status" 2>&1 > /dev/null
267
--exec $MYSQL --help 2>&1 > /dev/null
268
--exec $MYSQL --version 2>&1 > /dev/null
272
# bug #26851: Mysql Client --pager Buffer Overflow
275
# allow error 7(invalid argument) since --pager does not always exist in mysql
277
--exec $MYSQL --pager="540bytelengthstringxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -e "select 1" > /dev/null 2>&1
278
--exec $MYSQL --character-sets-dir="540bytelengthstringxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -e "select 1" 2>&1
281
# bug #30164: Using client side macro inside server side comments generates broken queries
283
--exec $MYSQL test -e "/*! \C latin1 */ select 1;"
286
# Bug#29323 mysql client only accetps ANSI encoded files
288
--write_file $MYSQLTEST_VARDIR/tmp/bug29323.sql
289
select "This is a file starting with UTF8 BOM 0xEFBBBF";
291
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug29323.sql 2>&1
292
remove_file $MYSQLTEST_VARDIR/tmp/bug29323.sql;
294
--echo End of 5.0 tests
297
# Bug #29903: The CMake build method does not produce the embedded library.
300
--exec $MYSQL --server-arg=no-defaults test -e "quit"
304
# Bug#26780: patch to add auto vertical output option to the cli.
306
# Make this wide enough that it will wrap almost everywhere.
307
--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;"
309
--exec $MYSQL test --auto-vertical-output --table -e "SELECT 1;"
312
# Bug #25146: Some warnings/errors not shown when using --show-warnings
315
# This one should succeed with no warnings
316
--exec $MYSQL --show-warnings test -e "create table t1 (id int)"
318
# This should succeed, with warnings about conversion from nonexistent engine
319
--exec $MYSQL --show-warnings test -e "create table t2 (id int) engine=nonexistent"
321
# This should fail, with warnings as well
323
--exec $MYSQL --show-warnings test -e "create table t2 (id int) engine=nonexistent2"