6
6
# This test uses chmod, can't be run with root permissions
7
7
-- source include/not_as_root.inc
9
# Save the initial number of concurrent sessions
10
--source include/count_sessions.inc
9
12
# ============================================================================
11
14
# Test of mysqltest itself
51
54
# ----------------------------------------------------------------------------
52
55
# Negative case(statement):
53
# The derived table t1 does not contain a column named 'friedrich' .
56
# The derived table t1 does not contain a column named 'friedrich' .
54
57
# --> ERROR 42S22: Unknown column 'friedrich' in 'field list and
55
58
# --> 1054: Unknown column 'friedrich' in 'field list'
56
59
# ----------------------------------------------------------------------------
120
124
# $mysql_errno is a builtin variable of mysqltest and contains the return code
121
125
# of the last command sent to the server.
123
# The following test cases often initialize $mysql_errno to 1064 by
127
# The following test cases often initialize $mysql_errno to 1064 by
124
128
# a command with wrong syntax.
125
129
# Example: --error 1064 To prevent the abort after the error.
135
139
#----------------------------------------------------------------------------
136
140
# check mysql_errno = 1064 after statement with wrong syntax
137
141
# ----------------------------------------------------------------------------
142
--error ER_PARSE_ERROR
140
145
eval select $mysql_errno as "after_wrong_syntax_errno" ;
142
147
# ----------------------------------------------------------------------------
143
148
# check if let $my_var= 'abc' ; affects $mysql_errno
144
149
# ----------------------------------------------------------------------------
150
--error ER_PARSE_ERROR
147
153
let $my_var= 'abc' ;
148
154
eval select $mysql_errno as "after_let_var_equal_value" ;
170
178
# (May be disabled warnings affect $mysql_errno.)
171
179
# ----------------------------------------------------------------------------
172
180
drop table if exists t1 ;
181
--error ER_PARSE_ERROR
175
184
drop table if exists t1 ;
176
185
eval select $mysql_errno as "after_disable_warnings" ;
179
188
# ----------------------------------------------------------------------------
180
189
# check if masked errors affect $mysql_errno
181
190
# ----------------------------------------------------------------------------
191
--error ER_PARSE_ERROR
194
--error ER_NO_SUCH_TABLE
185
196
select 3 from t1 ;
186
197
eval select $mysql_errno as "after_minus_masked" ;
198
--error ER_PARSE_ERROR
201
--error ER_NO_SUCH_TABLE
190
203
select 3 from t1 ;
191
204
eval select $mysql_errno as "after_!_masked" ;
193
206
# ----------------------------------------------------------------------------
194
207
# Will manipulations of $mysql_errno be possible and visible ?
195
208
# ----------------------------------------------------------------------------
209
--error ER_PARSE_ERROR
198
212
let $mysql_errno= -1;
199
213
eval select $mysql_errno as "after_let_errno_equal_value" ;
202
216
# How affect actions on prepared statements $mysql_errno ?
203
217
# ----------------------------------------------------------------------------
204
218
# failing prepare
219
--error ER_PARSE_ERROR
222
--error ER_NO_SUCH_TABLE
208
224
prepare stmt from "select 3 from t1" ;
209
225
eval select $mysql_errno as "after_failing_prepare" ;
210
226
create table t1 ( f1 char(10));
212
228
# successful prepare
229
--error ER_PARSE_ERROR
215
232
prepare stmt from "select 3 from t1" ;
216
233
eval select $mysql_errno as "after_successful_prepare" ;
218
235
# successful execute
236
--error ER_PARSE_ERROR
222
240
eval select $mysql_errno as "after_successful_execute" ;
224
242
# failing execute (table has been dropped)
244
--error ER_PARSE_ERROR
247
--error ER_NO_SUCH_TABLE
230
250
eval select $mysql_errno as "after_failing_execute" ;
232
252
# failing execute (unknown statement)
253
--error ER_PARSE_ERROR
256
--error ER_UNKNOWN_STMT_HANDLER
237
259
eval select $mysql_errno as "after_failing_execute" ;
239
261
# successful deallocate
262
--error ER_PARSE_ERROR
242
265
deallocate prepare stmt;
243
266
eval select $mysql_errno as "after_successful_deallocate" ;
245
268
# failing deallocate ( statement handle does not exist )
269
--error ER_PARSE_ERROR
272
--error ER_UNKNOWN_STMT_HANDLER
249
274
deallocate prepare __stmt_;
250
275
eval select $mysql_errno as "after_failing_deallocate" ;
284
310
# masked failing statements
285
311
# ----------------------------------------------------------------------------
286
312
# expected error = response
313
--error ER_NO_SUCH_TABLE
288
315
select 3 from t1 ;
316
--error ER_NO_SUCH_TABLE
290
318
select 3 from t1 ;
291
319
eval select $mysql_errno as "after_!errno_masked_error" ;
292
320
# expected error <> response
459
489
# Allow trailing # comment
460
490
--sleep 1 # Wait for insert delayed to be executed.
461
--sleep 1 # Wait for insert delayed to be executed.
491
--sleep 1 # Wait for insert delayed to be executed.
463
493
# ----------------------------------------------------------------------------
684
711
--exec echo "let hi;" | $MYSQL_TEST 2>&1
686
# More advanced test for bug#17280
713
# More advanced test for Bug#17280
688
715
--echo # Execute: --echo # <whatever> success: \$success
689
716
--echo # <whatever> success: $success
1229
1254
--exec echo "replace_result a;" | $MYSQL_TEST 2>&1
1231
1256
--exec echo "replace_result a ;" | $MYSQL_TEST 2>&1
1232
--exec echo "replace_result a b; echo OK;" | $MYSQL_TEST 2>&1
1257
--exec echo "replace_result a b; echo OK; exit;" | $MYSQL_TEST 2>&1
1234
1259
--exec echo "--replace_result a b c" | $MYSQL_TEST 2>&1
1366
1391
# ----------------------------------------------------------------------------
1367
# TODO Test queries, especially their errormessages... so it's easy to debug
1392
# TODO Test queries, especially their errormessages... so it's easy to debug
1368
1393
# new scripts and diagnose errors
1369
1394
# ----------------------------------------------------------------------------
1371
1396
# ----------------------------------------------------------------------------
1373
1398
# ----------------------------------------------------------------------------
1402
--error ER_PARSE_ERROR
1378
1404
failing_statement;
1406
1432
# The message contains more then 80 characters on multiple lines
1407
1433
# and is kept between double quotes.
1409
1435
"Here comes a very very long message that
1410
1436
- is longer then 80 characters and
1411
1437
- consists of several lines";
1434
1460
# Test zero length result file. Should not pass
1436
--exec touch $MYSQLTEST_VARDIR/tmp/zero_length_file.result
1462
--exec echo '' > $MYSQLTEST_VARDIR/tmp/zero_length_file.result
1437
1463
--exec echo "echo ok;" > $MYSQLTEST_VARDIR/tmp/query.sql
1439
1465
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result > /dev/null 2>&1
1441
1467
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result;
1443
remove_file $MYSQLTEST_VARDIR/log/zero_length_file.reject;
1469
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.reject;
1471
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.log;
1445
1473
remove_file $MYSQL_TEST_DIR/r/zero_length_file.reject;
1500
1529
--exec echo "select 'select-me';" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1501
1530
--exec echo "insertz "error query"||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1502
1531
--exec echo "delimiter ;||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1532
--exec echo "exit;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1504
1534
# These two should work since the error is expected
1505
1535
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1
1508
1538
--exec $MYSQL_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1
1509
1539
# The .out file should exist
1510
--exec test -s $MYSQLTEST_VARDIR/tmp/bug11731.out
1540
--file_exists $MYSQLTEST_VARDIR/tmp/bug11731.out
1512
1542
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.out;
1513
1543
remove_file $MYSQLTEST_VARDIR/log/bug11731.log;
1514
1544
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.sql;
1517
# Bug#19890 mysqltest: "query" command is broken
1547
# Bug#19890 mysqltest "query" command is broken
1520
1550
# It should be possible to use the command "query" to force mysqltest to
1521
1551
# send the command to the server although it's a builtin mysqltest command.
1552
--error ER_PARSE_ERROR
1556
--error ER_PARSE_ERROR
1528
1560
# Just an empty query command
1561
--error ER_EMPTY_QUERY
1532
1565
# test for replace_regex
1537
1570
select "at" as col1, "AT" as col2, "c" as col3;
1539
1572
--replace_regex /a/b/ /ct/d/
1540
select "a" as col1, "ct" as col2;
1573
select "a" as col1, "ct" as col2;
1542
1575
--replace_regex /(strawberry)/raspberry and \1/ /blueberry/blackberry/ /potato/tomato/;
1543
1576
select "strawberry","blueberry","potato";
1919
1953
# 8. Ensure that "sorted_result " does not change the semantics of
1920
1954
# "--error ...." or the protocol output after such an expected failure
1921
1955
--sorted_result
1956
--error ER_NO_SUCH_TABLE
1923
1958
SELECT '2' as "my_col1",2 as "my_col2"
1925
1960
SELECT '1',1 from t2;
1927
# 9. Ensure that several result formatting options including "sorted_result"
1962
# 9. Ensure that several result formatting options including "sorted_result"
1928
1963
# - have all an effect
1929
1964
# - "--sorted_result" does not need to be direct before the statement
1930
1965
# - Row sorting is applied after modification of the column content
2140
2175
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
2143
# Bug #36041: mysql-test-run doesn't seem to string match 100% effectively
2178
# Bug#36041 mysql-test-run doesn't seem to string match 100% effectively
2147
2182
--replace_result c:\\a.txt z
2148
2183
SELECT 'c:\\a.txt' AS col;
2186
# Bug#32307 mysqltest - does not detect illegal if syntax
2194
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
2195
if ($mysql_errno != 1436)
2197
echo ^ Should not be allowed!
2201
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
2202
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
2205
# ----------------------------------------------------------------------------
2206
# Test that -- is not allowed as comment, only as mysqltest builtin command
2207
# ----------------------------------------------------------------------------
2212
--query -- a comment for the server
2214
# Not valid, "select" is not a mysqltest command
2216
--exec echo "--select 1;" | $MYSQL_TEST 2>&1
2219
# ----------------------------------------------------------------------------
2220
# BUG#35701 please allow test language variables in connection and sync_slave_with_master
2221
# Test that "connection $variable" works and that $CURRENT_CONNECTION has the right value.
2222
# ----------------------------------------------------------------------------
2224
connect (con1,localhost,root,,);
2225
--echo $CURRENT_CONNECTION
2226
connect (con2,localhost,root,,);
2227
--echo $CURRENT_CONNECTION
2230
--echo $CURRENT_CONNECTION
2233
--echo $CURRENT_CONNECTION
2236
--echo $CURRENT_CONNECTION
2242
--echo $CURRENT_CONNECTION
2245
--echo $CURRENT_CONNECTION
2247
# Disconnect the not selected connection
2249
--echo $CURRENT_CONNECTION
2251
# Disconnect the selected connection
2253
--echo $CURRENT_CONNECTION
2150
2256
--echo End of tests
2259
# Wait till we reached the initial number of concurrent sessions
2260
--source include/wait_until_count_sessions.inc