mysql.test 13.7 KB
Newer Older
1 2
# This test should work in embedded server after we fix mysqltest
-- source include/not_embedded.inc
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#
# Testing the MySQL command line client(mysql)
#

--disable_warnings
drop table if exists t1;
--enable_warnings

#
# Test the "delimiter" functionality
# Bug#9879
#
create table t1(a int);
insert into t1 values(1);

# Test delimiters
19
--exec $MYSQL test 2>&1 < "./t/mysql_delimiter.sql"
20 21 22

--disable_query_log
# Test delimiter : supplied on the command line
23
select "Test delimiter : from command line" as "_";
kent@mysql.com's avatar
kent@mysql.com committed
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 "_";
kent@mysql.com's avatar
kent@mysql.com committed
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 "_";
kent@mysql.com's avatar
kent@mysql.com committed
30
--exec $MYSQL test -e "select * from t1\G"
31
# Test 'go' command \g
32
select "Test  'go' command \g" as "_";
kent@mysql.com's avatar
kent@mysql.com committed
33
--exec $MYSQL test -e "select * from t1\g"
34
--enable_query_log
35
drop table t1;
36

37 38 39 40 41
#
# BUG9998 - MySQL client hangs on USE "database"
#
create table t1(a int);
lock tables t1 write;
kent@mysql.com's avatar
kent@mysql.com committed
42
--exec $MYSQL -e "use test; select database();"
43
unlock tables;
44
drop table t1;
45

46 47 48 49
#
# Bug#16859 -- NULLs in columns must not truncate data as if a C-language "string".
#
--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
50

51 52 53 54 55 56
#
# Bug#17939 Wrong table format when using UTF8 strings
#
--exec $MYSQL --default-character-set=utf8 --table -e "SELECT 'John Doe' as '__tañgè Ñãmé'" 2>&1
--exec $MYSQL --default-character-set=utf8 --table -e "SELECT '__tañgè Ñãmé' as 'John Doe'" 2>&1

57 58 59 60 61
#
# Bug#18265 -- mysql client: No longer right-justifies numeric columns
#
--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;"

62 63 64
#
# "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 67
--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;"

68 69 70
#
# 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 73
--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;" 

74
#
75 76 77 78 79
# Bug#21618: NULL shown as empty string in client
#
--exec $MYSQL test -e "select unhex('zz');" 
--exec $MYSQL -t test -e "select unhex('zz');" 

80 81 82 83 84 85 86 87
# Bug#19265 describe command does not work from mysql prompt
#

create table t1(a int, b varchar(255), c int);
--exec $MYSQL test -e "desc t1"
--exec $MYSQL test -e "desc t1\g"
drop table t1;

88
--disable_parsing
89 90 91 92 93
#
# Bug#21042  	mysql client segfaults on importing a mysqldump export
#
--error 1
--exec $MYSQL test -e "connect verylongdatabasenamethatshouldblowthe256byteslongbufferincom_connectfunctionxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxendcccccccdxxxxxxxxxxxxxxxxxkskskskskkskskskskskskskskskskkskskskskkskskskskskskskskskend" 2>&1
94
--enable_parsing
95

96

97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
#
# Bug #20432: mysql client interprets commands in comments
#

# if the client sees the 'use' within the comment, we haven't fixed
--exec echo "/*"          >  $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "use"         >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "*/"          >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec $MYSQL              < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1

# SQL can have embedded comments => workie
--exec echo "select /*"   >  $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "use"         >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "*/ 1"        >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec $MYSQL              < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1

# client commands on the other hand must be at BOL => error
--exec echo "/*"          >  $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "xxx"         >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "*/ use"      >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--error 1
--exec $MYSQL              < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1

# client comment recognized, but parameter missing => error
--exec echo "use"         >  $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec $MYSQL              < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
123

124 125 126
#
# Bug #20328: mysql client interprets commands in comments
#
127 128
--exec $MYSQL -e "help" > $MYSQLTEST_VARDIR/tmp/bug20328_1.result
--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
130

131 132 133
#
# Bug #19216: Client crashes on long SELECT
#
134 135 136 137 138 139 140 141 142 143 144 145
# Create large SELECT
# - 3400 * 20 makes 68000 columns that is more than the
#   max number that can fit in a 16 bit number.

--perl
open(FILE,">","$ENV{'MYSQLTEST_VARDIR'}/tmp/b19216.tmp") or die;
print FILE "select\n";
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;
print FILE "'b';\n";
close FILE;
EOF

146 147 148 149
--disable_query_log
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/b19216.tmp >/dev/null
--enable_query_log

150 151
--remove_file $MYSQLTEST_VARDIR/tmp/b19216.tmp

152 153 154 155 156 157 158 159 160 161 162
#
# Bug #20103: Escaping with backslash does not work
#
--exec echo "SET SQL_MODE = 'NO_BACKSLASH_ESCAPES';"  > $MYSQLTEST_VARDIR/tmp/bug20103.sql
--exec echo "SELECT '\';" >> $MYSQLTEST_VARDIR/tmp/bug20103.sql
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20103.sql 2>&1

--exec echo "SET SQL_MODE = '';"  > $MYSQLTEST_VARDIR/tmp/bug20103.sql
--exec echo "SELECT '\';';" >> $MYSQLTEST_VARDIR/tmp/bug20103.sql
--exec $MYSQL              < $MYSQLTEST_VARDIR/tmp/bug20103.sql 2>&1

163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
#
# Bug#17583: mysql drops connection when stdout is not writable
#
create table t17583 (a int);
insert into t17583 (a) values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
insert into t17583 select a from t17583;
insert into t17583 select a from t17583;
insert into t17583 select a from t17583;
insert into t17583 select a from t17583;
insert into t17583 select a from t17583;
insert into t17583 select a from t17583;
insert into t17583 select a from t17583;
# Close to the minimal data needed to exercise bug.
select count(*) from t17583;
--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 >&-
drop table t17583;

180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
#
# Bug#20984: Reproducible MySQL client segmentation fault
#  + additional tests for the "com_connect" function in mysql
#
#
--echo Test connect without db- or host-name => reconnect
--exec $MYSQL test -e "\r" 2>&1
--exec $MYSQL test -e "connect" 2>&1

--echo Test connect with dbname only => new dbname, old hostname
--exec $MYSQL test -e "\r test" 2>&1
--exec $MYSQL test -e "connect test" 2>&1
--exec $MYSQL test -e "\rtest" 2>&1
--error 1
--exec $MYSQL test -e "connecttest" 2>&1

--echo Test connect with _invalid_ dbname only => new invalid dbname, old hostname
--error 1
--exec $MYSQL test -e "\r invalid" 2>&1
--error 1
--exec $MYSQL test -e "connect invalid" 2>&1

--echo Test connect with dbname + hostname
--exec $MYSQL test -e "\r test localhost" 2>&1
--exec $MYSQL test -e "connect test localhost" 2>&1

--echo Test connect with dbname + _invalid_ hostname
# Mask the errno of the error message
--replace_regex /\([0-9]*\)/(errno)/
--error 1
--exec $MYSQL test -e "\r test invalid_hostname" 2>&1
--replace_regex /\([0-9]*\)/(errno)/
--error 1
--exec $MYSQL test -e "connect test invalid_hostname" 2>&1

--echo The commands reported in the bug report
--replace_regex /\([0-9]*\)/(errno)/
--error 1
--exec $MYSQL test -e "\r\r\n\r\n cyril\ has\ found\ a\ bug\ :)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 2>&1

220 221 222
#--replace_regex /\([0-9]*\)/(errno)/
#--error 1
#--exec echo '\r\r\n\r\n cyril\ has\ found\ a\ bug\ :)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | $MYSQL 2>&1
223 224 225

--echo Too long dbname
--error 1
226
--exec $MYSQL test -e "\r test_really_long_dbnamexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx localhost" 2>&1
227 228 229 230

--echo Too long hostname
--replace_regex /\([0-9]*\)/(errno)/
--error 1
231
--exec $MYSQL test -e "\r  test cyrils_superlonghostnameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 2>&1
232

233

234 235 236 237 238 239
#
# Bug #21412: mysql cmdline client allows backslash(es) 
# as delimiter but can't recognize them
#

# This should work just fine...
240 241 242 243
--write_file $MYSQLTEST_VARDIR/tmp/bug21412.sql
DELIMITER /
SELECT 1/
EOF
244 245 246
--exec $MYSQL             < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1

# This should give an error...
247 248 249
--write_file $MYSQLTEST_VARDIR/tmp/bug21412.sql
DELIMITER \
EOF
250 251 252
--exec $MYSQL             < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1

# As should this...
253 254 255
--write_file $MYSQLTEST_VARDIR/tmp/bug21412.sql
DELIMITER \\
EOF
256 257
--exec $MYSQL             < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1

258 259 260 261 262 263 264 265
#
# Some coverage of not normally used parts
#

--disable_query_log
--exec $MYSQL test -e "show status" 2>&1 > /dev/null
--exec $MYSQL --help 2>&1 > /dev/null
--exec $MYSQL --version 2>&1 > /dev/null
266
--enable_query_log
267

268 269 270
#
# bug #26851: Mysql Client --pager Buffer Overflow
#
271 272 273 274

# allow error 7(invalid argument) since --pager does not always exist in mysql
--error 0,7
--exec $MYSQL --pager="540bytelengthstringxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -e "select 1" > /dev/null 2>&1
275 276
--exec $MYSQL --character-sets-dir="540bytelengthstringxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -e "select 1" 2>&1

277
--echo End of 5.0 tests