1
-- source include/have_log_bin.inc
3
# This test should work in embedded server after mysqltest is fixed
4
-- source include/not_embedded.inc
6
# This test uses chmod, can't be run with root permissions
7
-- source include/not_as_root.inc
9
# Save the initial number of concurrent sessions
10
--source include/count_sessions.inc
12
# ============================================================================
14
# Test of mysqltest itself
16
# There are three rules that determines what belong to each command
17
# 1. A normal command is delimited by the <delimiter> which by default is
23
# Command: "select * from t1"
25
# 2. Special case is a line that starts with "--", this is a comment
26
# ended when the new line character is reached. But the first word
27
# in the comment may contain a valid command, which then will be
28
# executed. This can be useful when sending commands that
29
# contains <delimiter>
31
# 3. Special case is also a line that starts with '#' which is treated
32
# as a comment and will be ended by new line character
34
# ============================================================================
36
# ----------------------------------------------------------------------------
37
# $mysql_errno contains the return code of the last command
39
# ----------------------------------------------------------------------------
40
# get $mysql_errno before the first statement
41
# $mysql_errno should be -1
42
eval select $mysql_errno as "before_use_test" ;
45
# ----------------------------------------------------------------------------
46
# Positive case(statement)
47
# ----------------------------------------------------------------------------
49
select otto from (select 1 as otto) as t1;
50
# expectation = response
52
select otto from (select 1 as otto) as t1;
54
# ----------------------------------------------------------------------------
55
# Negative case(statement):
56
# The derived table t1 does not contain a column named 'friedrich' .
57
# --> ERROR 42S22: Unknown column 'friedrich' in 'field list and
58
# --> 1054: Unknown column 'friedrich' in 'field list'
59
# ----------------------------------------------------------------------------
61
# expectation <> response
63
#select friedrich from (select 1 as otto) as t1
65
--exec echo "select friedrich from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1
67
# expectation = response
68
--error ER_BAD_FIELD_ERROR
70
select friedrich from (select 1 as otto) as t1;
72
# The following unmasked unsuccessful statement must give
73
# 1. mysqltest gives a 'failed'
74
# 2. does not produce a r/<test case>.reject file !!!
75
# PLEASE uncomment it and check its effect
76
#select friedrich from (select 1 as otto) as t1;
79
# ----------------------------------------------------------------------------
80
# Tests for the new feature - SQLSTATE error code matching
81
# Positive case(statement)
82
# ----------------------------------------------------------------------------
84
# This syntax not allowed anymore, use --error S00000, see below
85
# expectation = response
86
#!S00000 select otto from (select 1 as otto) as t1;
89
select otto from (select 1 as otto) as t1;
91
# expectation <> response
92
#!S42S22 select otto from (select 1 as otto) as t1;
94
#select otto from (select 1 as otto) as t1;
96
--exec echo "error S42S22; select otto from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1
98
# expecting a SQL-state for a command that can't give one should fail
99
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
101
--exec echo "error S00000; remove_file $MYSQLTEST_VARDIR/tmp/test_nonexistent.tmp;" | $MYSQL_TEST 2>&1
104
# ----------------------------------------------------------------------------
105
# Negative case(statement)
106
# ----------------------------------------------------------------------------
108
# This syntax not allowed anymore, use --error S42S22, see below
109
# expectation = response
110
#!S42S22 select friedrich from (select 1 as otto) as t1;
112
select friedrich from (select 1 as otto) as t1;
114
# expectation !=response
115
#!S00000 select friedrich from (select 1 as otto) as t1;
117
#select friedrich from (select 1 as otto) as t1;
119
--exec echo "error S00000; select friedrich from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1
121
# ----------------------------------------------------------------------------
122
# test cases for $mysql_errno
124
# $mysql_errno is a builtin variable of mysqltest and contains the return code
125
# of the last command sent to the server.
127
# The following test cases often initialize $mysql_errno to 1064 by
128
# a command with wrong syntax.
129
# Example: --error 1064 To prevent the abort after the error.
131
# ----------------------------------------------------------------------------
133
# ----------------------------------------------------------------------------
134
# check mysql_errno = 0 after successful statement
135
# ----------------------------------------------------------------------------
136
select otto from (select 1 as otto) as t1;
137
eval select $mysql_errno as "after_successful_stmt_errno" ;
139
#----------------------------------------------------------------------------
140
# check mysql_errno = 1064 after statement with wrong syntax
141
# ----------------------------------------------------------------------------
142
--error ER_PARSE_ERROR
145
eval select $mysql_errno as "after_wrong_syntax_errno" ;
147
# ----------------------------------------------------------------------------
148
# check if let $my_var= 'abc' ; affects $mysql_errno
149
# ----------------------------------------------------------------------------
150
--error ER_PARSE_ERROR
154
eval select $mysql_errno as "after_let_var_equal_value" ;
156
# ----------------------------------------------------------------------------
157
# check if set @my_var= 'abc' ; affects $mysql_errno
158
# ----------------------------------------------------------------------------
159
--error ER_PARSE_ERROR
163
eval select $mysql_errno as "after_set_var_equal_value" ;
165
# ----------------------------------------------------------------------------
166
# check if the setting of --disable-warnings itself affects $mysql_errno
167
# (May be --<whatever> modifies $mysql_errno.)
168
# ----------------------------------------------------------------------------
169
--error ER_PARSE_ERROR
173
eval select $mysql_errno as "after_disable_warnings_command" ;
175
# ----------------------------------------------------------------------------
176
# check if --disable-warnings + command with warning affects the errno
177
# stored within $mysql_errno
178
# (May be disabled warnings affect $mysql_errno.)
179
# ----------------------------------------------------------------------------
180
drop table if exists t1 ;
181
--error ER_PARSE_ERROR
184
drop table if exists t1 ;
185
eval select $mysql_errno as "after_disable_warnings" ;
188
# ----------------------------------------------------------------------------
189
# check if masked errors affect $mysql_errno
190
# ----------------------------------------------------------------------------
191
--error ER_PARSE_ERROR
194
--error ER_NO_SUCH_TABLE
197
eval select $mysql_errno as "after_minus_masked" ;
198
--error ER_PARSE_ERROR
201
--error ER_NO_SUCH_TABLE
204
eval select $mysql_errno as "after_!_masked" ;
206
# ----------------------------------------------------------------------------
207
# Will manipulations of $mysql_errno be possible and visible ?
208
# ----------------------------------------------------------------------------
209
--error ER_PARSE_ERROR
212
let $mysql_errno= -1;
213
eval select $mysql_errno as "after_let_errno_equal_value" ;
215
# ----------------------------------------------------------------------------
216
# How affect actions on prepared statements $mysql_errno ?
217
# ----------------------------------------------------------------------------
219
--error ER_PARSE_ERROR
222
--error ER_NO_SUCH_TABLE
224
prepare stmt from "select 3 from t1" ;
225
eval select $mysql_errno as "after_failing_prepare" ;
226
create table t1 ( f1 char(10));
229
--error ER_PARSE_ERROR
232
prepare stmt from "select 3 from t1" ;
233
eval select $mysql_errno as "after_successful_prepare" ;
236
--error ER_PARSE_ERROR
240
eval select $mysql_errno as "after_successful_execute" ;
242
# failing execute (table has been dropped)
244
--error ER_PARSE_ERROR
247
--error ER_NO_SUCH_TABLE
250
eval select $mysql_errno as "after_failing_execute" ;
252
# failing execute (unknown statement)
253
--error ER_PARSE_ERROR
256
--error ER_UNKNOWN_STMT_HANDLER
259
eval select $mysql_errno as "after_failing_execute" ;
261
# successful deallocate
262
--error ER_PARSE_ERROR
265
deallocate prepare stmt;
266
eval select $mysql_errno as "after_successful_deallocate" ;
268
# failing deallocate ( statement handle does not exist )
269
--error ER_PARSE_ERROR
272
--error ER_UNKNOWN_STMT_HANDLER
274
deallocate prepare __stmt_;
275
eval select $mysql_errno as "after_failing_deallocate" ;
278
# ----------------------------------------------------------------------------
279
# test cases for "--disable_abort_on_error"
281
# "--disable_abort_on_error" switches off the abort of mysqltest
282
# after "unmasked" failing statements.
284
# The default is "--enable_abort_on_error".
287
# --error <error number> and --error <error number>
288
# in the line before the failing statement.
290
# There are some additional test cases for $mysql_errno
291
# because "--disable_abort_on_error" enables a new situation.
292
# Example: "unmasked" statement fails + analysis of $mysql_errno
293
# ----------------------------------------------------------------------------
295
# ----------------------------------------------------------------------------
296
# Switch off the abort on error and check the effect on $mysql_errno
297
# ----------------------------------------------------------------------------
298
--error ER_PARSE_ERROR
301
--disable_abort_on_error
302
eval select $mysql_errno as "after_--disable_abort_on_error" ;
304
# ----------------------------------------------------------------------------
305
# "unmasked" failing statement should not cause an abort
306
# ----------------------------------------------------------------------------
309
# ----------------------------------------------------------------------------
310
# masked failing statements
311
# ----------------------------------------------------------------------------
312
# expected error = response
313
--error ER_NO_SUCH_TABLE
316
--error ER_NO_SUCH_TABLE
319
eval select $mysql_errno as "after_!errno_masked_error" ;
320
# expected error <> response
326
--exec echo "disable_abort_on_error; error 1000; select 3 from t1; error 1000; select 3 from t1;" | $MYSQL_TEST 2>&1
328
# ----------------------------------------------------------------------------
329
# Switch the abort on error on and check the effect on $mysql_errno
330
# ----------------------------------------------------------------------------
331
--error ER_PARSE_ERROR
334
--enable_abort_on_error
335
eval select $mysql_errno as "after_--enable_abort_on_error" ;
337
# ----------------------------------------------------------------------------
338
# masked failing statements
339
# ----------------------------------------------------------------------------
340
# expected error = response
341
--error ER_NO_SUCH_TABLE
345
# ----------------------------------------------------------------------------
346
# check that the old default behaviour is not changed
347
# Please remove the '#' to get the abort on error
348
# ----------------------------------------------------------------------------
355
--exec echo "disable_abort_on_error; enable_abort_on_error; error 1064; select 3 from t1; select 3 from t1;" | $MYSQL_TEST 2>&1
358
# ----------------------------------------------------------------------------
360
# ----------------------------------------------------------------------------
363
# This is a ; comment
364
# This is a -- comment
365
# -- This is also a comment
366
# -- # This is also a comment
367
# -- This is also a ; comment
369
# ----------------------------------------------------------------------------
370
# Test comments with embedded command
371
# ----------------------------------------------------------------------------
377
--echo # MySQL: -- The
379
# ----------------------------------------------------------------------------
380
# Test detect end of line "junk"
381
# Most likely caused by a missing delimiter
382
# ----------------------------------------------------------------------------
384
# Too many parameters to function
386
--exec echo "sleep 5 6;" | $MYSQL_TEST 2>&1
388
# Too many parameters to function
390
--exec echo "--sleep 5 6" | $MYSQL_TEST 2>&1
394
# The comment will be "sucked into" the sleep command since
395
# delimiter is missing until after "show status"
396
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
402
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
403
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
406
# Missing delimiter until eof
407
# The comment will be "sucked into" the sleep command since
408
# delimiter is missing
409
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
414
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
415
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
418
# Missing delimiter until "disable_query_log"
420
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
429
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
430
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
433
# Missing delimiter until "disable_query_log"
435
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
445
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
446
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
449
# Missing delimiter until eof
451
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
462
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
463
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
466
# Missing delimiter until eof
468
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
469
disconnect default # comment
476
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
478
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
484
--exec echo "--sleep 4;" | $MYSQL_TEST 2>&1
486
--exec echo "--disable_query_log;" | $MYSQL_TEST 2>&1
489
# Allow trailing # comment
490
--sleep 1 # Wait for insert delayed to be executed.
491
--sleep 1 # Wait for insert delayed to be executed.
493
# ----------------------------------------------------------------------------
495
# ----------------------------------------------------------------------------
499
--exec echo "error;" | $MYSQL_TEST 2>&1
501
--exec echo "--error" | $MYSQL_TEST 2>&1
503
# First char must be uppercase 'S' or 'E' or [0-9]
505
--exec echo "--error s99999" | $MYSQL_TEST 2>&1
507
--exec echo "--error e99999" | $MYSQL_TEST 2>&1
509
--exec echo "--error 9eeeee" | $MYSQL_TEST 2>&1
511
--exec echo "--error 1sssss" | $MYSQL_TEST 2>&1
513
# First char 'S' but too long
515
--exec echo "--error S999999" | $MYSQL_TEST 2>&1
517
# First char 'S' but lowercase char found
519
--exec echo "--error S99a99" | $MYSQL_TEST 2>&1
521
# First char 'S' but too short
523
--exec echo "--error S9999" | $MYSQL_TEST 2>&1
525
# First char 'E' but not found in error array
527
--exec echo "--error E9999" | $MYSQL_TEST 2>&1
529
# First char [0-9] but contains chars
531
--exec echo "--error 999e9" | $MYSQL_TEST 2>&1
533
--exec echo "--error 9b" | $MYSQL_TEST 2>&1
535
# Multiple errorcodes separated by ','
537
#--error 9,ER_PARSE_ERROR
538
#--error ER_PARSE_ERROR
539
#--error 9,ER_PARSE_ERROR,9,ER_PARSE_ERROR
540
#--error 9, ER_PARSE_ERROR, 9, ER_PARSE_ERROR
541
#--error 9,S00000,9,ER_PARSE_ERROR
542
#--error 9,S00000,9,ER_PARSE_ERROR,ER_PARSE_ERROR,ER_PARSE_ERROR,9,10,11,12
544
--error 9,S00000,9,9,10,11,12
550
# Too many errorcodes specified
552
--exec echo "--error 1,2,3,4,5,6,7,8,9,10,11" | $MYSQL_TEST 2>&1
555
# ----------------------------------------------------------------------------
557
# ----------------------------------------------------------------------------
561
echo MySQL: The world''s most popular open source database;
562
echo "MySQL: The world's most popular open source database";
564
echo MySQL: The world''s
568
echo # MySQL: The world''s
572
echo - MySQL: The world''s
576
echo - MySQL: The world''s
578
-- open source database;
586
echo "MySQL: The world's most popular; open source database";
587
echo "MySQL: The world's most popular ; open source database";
588
echo "MySQL: The world's most popular ;open source database";
589
echo echo message echo message;
594
# Illegal use of echo
597
#--exec echo "echo \$;" | $MYSQL_TEST 2>&1
600
# ----------------------------------------------------------------------------
602
# ----------------------------------------------------------------------------
604
# Illegal use of exec
606
--exec echo "--exec " | $MYSQL_TEST 2>&1
611
exec $MYSQL test -e "select
613
let $query = select 3
615
exec $MYSQL test -e "$query";
617
# ----------------------------------------------------------------------------
619
# ----------------------------------------------------------------------------
624
let $message="MySQL";
627
let $message= MySQL: The
633
let $message= # MySQL: The
639
let $message= -- MySQL: The
642
-- open source database;
645
let $message= # MySQL: The
670
let $where=a long variable content;
676
let $where3=a long $where variable content;
679
let $where3=a long \\\$where variable content;
682
let $novar1= $novar2;
689
# ba\$cat\$cat should have been sufficient.
690
# ba\\\$cat\\\$cat -> ba\$cat\$cat -> ba$cat$cat -> banana
691
# Magnus' upcoming patch will fix the missing second interpretation.
692
let $cat=ba\\\$cat\\\$cat;
693
echo Not a banana: $cat;
696
# Test illegal uses of let
699
--exec echo "let ;" | $MYSQL_TEST 2>&1
702
--exec echo "let \$=hi;" | $MYSQL_TEST 2>&1
705
--exec echo "let \$1 hi;" | $MYSQL_TEST 2>&1
708
--exec echo "let \$m hi;" | $MYSQL_TEST 2>&1
711
--exec echo "let \$hi;" | $MYSQL_TEST 2>&1
714
--exec echo "let \$ hi;" | $MYSQL_TEST 2>&1
717
--exec echo "let =hi;" | $MYSQL_TEST 2>&1
720
--exec echo "let hi;" | $MYSQL_TEST 2>&1
722
# More advanced test for Bug#17280
724
--echo # Execute: --echo # <whatever> success: \$success
725
--echo # <whatever> success: $success
726
--echo # Execute: echo # <whatever> success: \$success ;
727
echo # <whatever> success: $success ;
729
--echo # The next two variants work fine and expand the content of \$success
730
--echo # Execute: --echo \$success
732
--echo # Execute: echo \$success ;
736
# ----------------------------------------------------------------------------
737
# Test to assign let from variable
738
# let $<var_name>=$<var_name>;
739
# ----------------------------------------------------------------------------
741
--echo # Check if let \$B = \$A is an assignment per value.
743
# Basic preparations:
744
--echo let \$A = initial value of A;
745
let $A = initial value of A;
746
# --echo # Content of \$A is: $A
747
--echo let \$B = initial value of B;
748
let $B = initial value of B;
749
# --echo # Content of \$B is: $B
754
--echo # Content of \$A is: $A
756
# Changes of $B must NOT affect $A and Changes of $A must NOT affect $B !
757
--echo let \$A = changed value of A;
758
let $A = changed value of A;
759
--echo # Content of \$B is: $B
761
--echo let \$B = changed value of B;
762
let $B = changed value of B;
763
--echo # Content of \$A is: $A
765
# ----------------------------------------------------------------------------
766
# Test let from query with $variable
767
# let $<var_name>=`<query with $variable>`;
768
# ----------------------------------------------------------------------------
770
let $var1=content of variable 1;
771
let $var2= `select "$var1"`;
772
let $var3= `select concat("$var1", " ", "$var2")`;
775
if (`select length("$var3") > 0`)
777
echo length of var3 is longer than 0;
780
# ----------------------------------------------------------------------------
781
# Test to assign let from query
782
# let $<var_name>=`<query>`;
783
# ----------------------------------------------------------------------------
785
let $var1= `select "hi" as "Col", 1 as "Column1", "hi there" as Col3`;
789
let $var2= `select 2 as "Column num 2"`;
793
let $var2= `select 2 as "Column num 2"`;
796
echo var3 two columns with same name;
797
let $var3= `select 1 as "Col", 2 as "Col", 3 as "var3"`;
800
echo var4 from query that returns NULL;
801
let $var4= `select NULL`;
803
echo var5 from query that returns no row;
804
let $var5= `SHOW VARIABLES LIKE "nonexisting_variable"`;
806
echo failing query in let;
807
--write_file $MYSQLTEST_VARDIR/tmp/let.sql
808
let $var2= `failing query`;
813
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/let.sql 2>&1
815
remove_file $MYSQLTEST_VARDIR/tmp/let.sql;
818
# ----------------------------------------------------------------------------
819
# Test source command
820
# ----------------------------------------------------------------------------
822
# Test illegal uses of source
825
--exec echo "source ;" | $MYSQL_TEST 2>&1
828
--replace_result \\ /
829
# Source a nonexisting file
831
--exec echo "source non_existingFile;" | $MYSQL_TEST 2>&1
834
--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" > $MYSQLTEST_VARDIR/tmp/recursive.sql
835
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
837
--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" | $MYSQL_TEST 2>&1
838
remove_file $MYSQLTEST_VARDIR/tmp/recursive.sql;
840
# Source a file with error
841
--exec echo "garbage ;" > $MYSQLTEST_VARDIR/tmp/error.sql
842
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
844
--exec echo "source $MYSQLTEST_VARDIR/tmp/error.sql;" | $MYSQL_TEST 2>&1
846
remove_file $MYSQLTEST_VARDIR/tmp/error.sql;
848
# Test execution of source in a while loop
849
--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc
850
echo here is the sourced script;
853
let $outer= 2; # Number of outer loops
856
eval SELECT '$outer = outer loop variable after while' AS "";
858
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
860
eval SELECT '$outer = outer loop variable before dec' AS "";
862
eval SELECT '$outer = outer loop variable after dec' AS "";
865
# Test source in an if in a while which is false on 1st iteration
866
# Also test --error in same context
867
let $outer= 2; # Number of outer loops
868
let $ifval= 0; # false 1st time
871
echo outer=$outer ifval=$ifval;
874
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
875
--error ER_NO_SUCH_TABLE
876
SELECT * from nowhere;
883
# Test execution of source in a while loop
884
--disable_abort_on_error
885
# Sourcing of a file within while loop, sourced file will
890
SELECT 'In loop' AS "";
891
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
894
--enable_abort_on_error
897
# Test source $variable/<filename>
898
--source $MYSQLTEST_VARDIR/tmp/sourced.inc
900
--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc
902
--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc
907
source $MYSQLTEST_VARDIR/tmp/$x.inc;
909
let $x= $MYSQLTEST_VARDIR;
910
source $x/tmp/sourced.inc;
912
--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc
915
# ----------------------------------------------------------------------------
917
# ----------------------------------------------------------------------------
923
# Parameter from variable, legal and illegal
927
--real_sleep $sleep_var
929
--write_file $MYSQL_TMP_DIR/sleep.inc
934
--exec $MYSQL_TEST < $MYSQL_TMP_DIR/sleep.inc 2>&1
935
--remove_file $MYSQL_TMP_DIR/sleep.inc
937
--write_file $MYSQL_TMP_DIR/sleep.inc
939
real_sleep $sleep_var;
942
--exec $MYSQL_TEST < $MYSQL_TMP_DIR/sleep.inc 2>&1
943
--remove_file $MYSQL_TMP_DIR/sleep.inc
947
--exec echo "sleep ;" | $MYSQL_TEST 2>&1
949
--exec echo "real_sleep ;" | $MYSQL_TEST 2>&1
953
--exec echo "sleep abc;" | $MYSQL_TEST 2>&1
955
--exec echo "real_sleep abc;" | $MYSQL_TEST 2>&1
957
# ----------------------------------------------------------------------------
959
# ----------------------------------------------------------------------------
974
--exec echo "inc;" | $MYSQL_TEST 2>&1
976
--exec echo "inc i;" | $MYSQL_TEST 2>&1
978
--exec echo "let \$i=100; inc \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1
980
inc $i; inc $i; inc $i; --echo $i
984
# ----------------------------------------------------------------------------
986
# ----------------------------------------------------------------------------
1002
--exec echo "dec;" | $MYSQL_TEST 2>&1
1004
--exec echo "dec i;" | $MYSQL_TEST 2>&1
1006
--exec echo "let \$i=100; dec \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1
1009
# ----------------------------------------------------------------------------
1011
# ----------------------------------------------------------------------------
1012
#system ls > /dev/null;
1013
system echo "hej" > /dev/null;
1014
#--system ls > /dev/null
1015
--system echo "hej" > /dev/null;
1018
--exec echo "system;" | $MYSQL_TEST 2>&1
1020
--exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1
1022
--disable_abort_on_error
1023
system NonExistsinfComamdn 2> /dev/null;
1024
--enable_abort_on_error
1027
# ----------------------------------------------------------------------------
1029
# ----------------------------------------------------------------------------
1040
# ----------------------------------------------------------------------------
1041
# Test that delimiter within if() works in in various combinations
1042
# ----------------------------------------------------------------------------
1054
echo false-inner again||
1066
echo true-inner again/
1072
# ----------------------------------------------------------------------------
1074
# ----------------------------------------------------------------------------
1079
echo Counter is greater than 0, (counter=10);
1083
echo Counter is not 0, (counter=10);
1088
echo Counter is greater than 0, (counter=0);
1092
echo Counter is not 0, (counter=0);
1095
# ----------------------------------------------------------------------------
1096
# Test while, { and }
1097
# ----------------------------------------------------------------------------
1106
#let $i=1;while ($i){echo $i;dec $i;}
1111
echo Testing while with not;
1115
# Exceed max nesting level
1116
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc
1256
--replace_result \\ / $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1258
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc;" | $MYSQL_TEST 2>&1
1259
--remove_file $MYSQLTEST_VARDIR/tmp/mysqltest_while.inc
1261
--exec echo "while \$i;" | $MYSQL_TEST 2>&1
1263
--exec echo "while (\$i;" | $MYSQL_TEST 2>&1
1265
--exec echo "let \$i=1; while (\$i) dec \$i;" | $MYSQL_TEST 2>&1
1267
--exec echo "};" | $MYSQL_TEST 2>&1
1269
--exec echo "end;" | $MYSQL_TEST 2>&1
1271
--exec echo "{;" | $MYSQL_TEST 2>&1
1273
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1278
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
1279
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1281
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1286
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
1287
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1289
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1294
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
1296
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1298
# ----------------------------------------------------------------------------
1299
# Test error messages returned from comments starting with a command
1300
# ----------------------------------------------------------------------------
1302
--exec echo "--if the other server is down" | $MYSQL_TEST 2>&1
1305
--exec echo "-- end when ..." | $MYSQL_TEST 2>&1
1307
# ----------------------------------------------------------------------------
1309
# ----------------------------------------------------------------------------
1310
--replace_result a b
1311
select "a" as col1, "c" as col2;
1313
--replace_result a b c d
1314
select "a" as col1, "c" as col2;
1317
--exec echo "--replace_result a" | $MYSQL_TEST 2>&1
1319
--exec echo "--replace_result a;" | $MYSQL_TEST 2>&1
1321
--exec echo "replace_result a;" | $MYSQL_TEST 2>&1
1323
--exec echo "replace_result a ;" | $MYSQL_TEST 2>&1
1324
--exec echo "replace_result a b; echo OK; exit;" | $MYSQL_TEST 2>&1
1326
--exec echo "--replace_result a b c" | $MYSQL_TEST 2>&1
1328
--exec echo "replace_result a b c ;" | $MYSQL_TEST 2>&1
1331
--replace_column 1 b
1332
select "a" as col1, "c" as col2;
1334
--replace_column 1 b 2 d
1335
select "a" as col1, "c" as col2;
1338
--exec echo "--replace_column a" | $MYSQL_TEST 2>&1
1341
--exec echo "--replace_column 1" | $MYSQL_TEST 2>&1
1344
--exec echo "--replace_column a b" | $MYSQL_TEST 2>&1
1346
--exec echo "--replace_column a 1" | $MYSQL_TEST 2>&1
1348
--exec echo "--replace_column 1 b c " | $MYSQL_TEST 2>&1
1350
let $long_rep= 1234567890123456789012345678901234567890;
1351
let $long_rep= $long_rep,$long_rep;
1352
let $long_rep= $long_rep,$long_rep;
1353
let $long_rep= $long_rep,$long_rep;
1354
let $long_rep= $long_rep,$long_rep;
1355
let $long_rep= $long_rep,$long_rep;
1357
# This tests from strings > 1024 (here 1311)
1359
--replace_result $long_rep LONG_STRING
1360
eval select "$long_rep" as x;
1362
# ----------------------------------------------------------------------------
1363
# Test sync_with_master
1364
# ----------------------------------------------------------------------------
1366
--exec echo "sync_with_master 10!;" | $MYSQL_TEST 2>&1
1368
--exec echo "sync_with_master a;" | $MYSQL_TEST 2>&1
1370
# ----------------------------------------------------------------------------
1372
# ----------------------------------------------------------------------------
1375
--exec echo "connect;" | $MYSQL_TEST 2>&1
1377
--exec echo "connect ();" | $MYSQL_TEST 2>&1
1379
--exec echo "connect (con2);" | $MYSQL_TEST 2>&1
1381
--exec echo "connect (con2,);" | $MYSQL_TEST 2>&1
1383
--exec echo "connect (con2,localhost,root,,illegal_db);" | $MYSQL_TEST 2>&1
1385
--exec echo "connect (con1,localhost,root,,,illegal_port,);" | $MYSQL_TEST 2>&1
1387
--exec echo "connect (con1,localhost,root,,,,,SMTP POP);" | $MYSQL_TEST 2>&1
1389
# Repeat connect/disconnect
1390
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1394
connect (test_con1,localhost,root,,);
1395
disconnect test_con1;
1399
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql; echo OK; exit;" | $MYSQL_TEST 2>&1
1400
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1402
# Repeat connect/disconnect
1403
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1407
connect (test_con1,localhost,root,,);
1408
disconnect test_con1;
1412
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1414
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
1415
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1417
# Select disconnected connection
1418
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1419
connect (test_con1,localhost,root,,);
1420
disconnect test_con1;
1421
connection test_con1;
1423
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1425
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
1426
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1428
# Connection name already used
1429
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
1430
connect (test_con1,localhost,root,,);
1431
connect (test_con1,localhost,root,,);
1433
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1435
--exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
1437
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
1439
# connect when "disable_abort_on_error" caused "connection not found"
1440
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
1441
--disable_abort_on_error
1442
connect (con1,localhost,root,,);
1446
--enable_abort_on_error
1448
# Test connect without a database
1449
connect (con2,localhost,root,,*NO-ONE*);
1450
--error ER_NO_DB_ERROR
1455
# ----------------------------------------------------------------------------
1456
# Test mysqltest arguments
1457
# ----------------------------------------------------------------------------
1459
# -x <file_name>, use the file specified after -x as the test file
1460
--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc
1461
--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc
1462
--exec $MYSQL_TEST --test_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc
1464
--replace_result \\ /
1466
--exec $MYSQL_TEST -x non_existing_file.inc 2>&1
1469
# ----------------------------------------------------------------------------
1470
# TODO Test queries, especially their errormessages... so it's easy to debug
1471
# new scripts and diagnose errors
1472
# ----------------------------------------------------------------------------
1474
# ----------------------------------------------------------------------------
1476
# ----------------------------------------------------------------------------
1480
--error ER_PARSE_ERROR
1491
# Bug#10251 Identifiers containing quotes not handled correctly
1493
select 1 as `a'b`, 2 as `a"b`;
1495
# Test escaping of quotes
1496
select 'aaa\\','aa''a',"aa""a";
1499
# Check of include/show_msg.inc and include/show_msg80.inc
1502
# The message contains in most cases a string with the default character set
1503
let $message= Here comes a message;
1504
--source include/show_msg.inc
1506
# The message could also contain a string with character set utf8
1507
let $message= `SELECT USER()`;
1508
--source include/show_msg.inc
1510
# The message contains more then 80 characters on multiple lines
1511
# and is kept between double quotes.
1513
"Here comes a very very long message that
1514
- is longer then 80 characters and
1515
- consists of several lines";
1516
--source include/show_msg80.inc
1518
# The message contains more then 80 characters on multiple lines
1519
# and uses the auxiliary character "." at the beginning of the message lines.
1520
let $message= . Here comes a very very long message that
1521
. - is longer then 80 characters and
1522
. - consists of several lines;
1523
--source include/show_msg80.inc
1526
# Test --enable_parsing / disable_parsing
1530
# The following will not enable query logging
1532
select "this will not be executed";
1534
select "this will be executed";
1538
# Test zero length result file. Should not pass
1540
--exec echo '' > $MYSQLTEST_VARDIR/tmp/zero_length_file.result
1541
--exec echo "echo ok;" > $MYSQLTEST_VARDIR/tmp/query.sql
1543
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result > /dev/null 2>&1
1545
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result;
1547
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.reject;
1549
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.log;
1551
remove_file $MYSQL_TEST_DIR/r/zero_length_file.reject;
1554
# Test that a test file that does not generate any output fails.
1556
--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql
1558
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql 2>&1
1560
remove_file $MYSQLTEST_VARDIR/tmp/query.sql;
1563
# Test that mysqltest fails when there are no queries executed
1564
# but a result file exists
1565
# NOTE! This will never happen as long as it's not allowed to have
1566
# test files that produce no output
1567
#--exec echo "something" > $MYSQLTEST_VARDIR/tmp/result_file.result
1568
#--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql
1570
#--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/result_file.result 2>&1
1573
# Bug#11731 mysqltest in multi-statement queries ignores errors in
1577
echo Failing multi statement query;
1578
# PS does not support multi statement
1579
--exec echo "--disable_ps_protocol" > $MYSQLTEST_VARDIR/tmp/bug11731.sql
1580
--exec echo "delimiter ||||;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1581
--exec echo "create table t1 (a int primary key);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1582
--exec echo "insert into t1 values (1);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1583
--exec echo "select 'select-me';" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1584
--exec echo "insertz 'error query'||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1585
--exec echo "delimiter ;||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1588
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1
1591
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1593
--exec $MYSQL_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1
1594
# The .out file should be non existent
1596
--file_exists $MYSQLTEST_VARDIR/tmp/bug11731.out
1600
echo Multi statement using expected error;
1601
# PS does not support multi statement
1602
--exec echo "--disable_ps_protocol" > $MYSQLTEST_VARDIR/tmp/bug11731.sql
1603
--exec echo "delimiter ||||;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1604
--exec echo "--error 1064" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1605
--exec echo "create table t1 (a int primary key);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1606
--exec echo "insert into t1 values (1);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1607
--exec echo "select 'select-me';" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1608
--exec echo "insertz "error query"||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1609
--exec echo "delimiter ;||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1610
--exec echo "exit;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql
1612
# These two should work since the error is expected
1613
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1
1616
--exec $MYSQL_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1
1617
# The .out file should exist
1618
--file_exists $MYSQLTEST_VARDIR/tmp/bug11731.out
1620
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.out;
1621
remove_file $MYSQLTEST_VARDIR/log/bug11731.log;
1622
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.sql;
1625
# Bug#19890 mysqltest "query" command is broken
1628
# It should be possible to use the command "query" to force mysqltest to
1629
# send the command to the server although it's a builtin mysqltest command.
1630
--error ER_PARSE_ERROR
1634
--error ER_PARSE_ERROR
1638
# Just an empty query command
1639
--error ER_EMPTY_QUERY
1643
# test for replace_regex
1644
--replace_regex /at/b/
1645
select "at" as col1, "c" as col2;
1647
--replace_regex /at/b/i
1648
select "at" as col1, "AT" as col2, "c" as col3;
1650
--replace_regex /a/b/ /ct/d/
1651
select "a" as col1, "ct" as col2;
1653
--replace_regex /(strawberry)/raspberry and \1/ /blueberry/blackberry/ /potato/tomato/;
1654
select "strawberry","blueberry","potato";
1657
--exec echo "--replace_regex a" | $MYSQL_TEST 2>&1
1659
--exec echo "--replace_regex a;" | $MYSQL_TEST 2>&1
1661
--exec echo "replace_regex a;" | $MYSQL_TEST 2>&1
1663
--exec echo "replace_regex a ;" | $MYSQL_TEST 2>&1
1665
--exec echo "replace_regex a b; echo OK;" | $MYSQL_TEST 2>&1
1667
--exec echo "--replace_regex /a b c" | $MYSQL_TEST 2>&1
1669
--exec echo "replace_regex /a /b c ;" | $MYSQL_TEST 2>&1
1672
# replace_regex should replace substitutions from left to right in output
1674
create table t1 (a int, b int);
1675
insert into t1 values (1,3);
1676
insert into t1 values (2,4);
1677
--replace_regex /A/C/ /B/D/i /3/2/ /2/1/
1681
# ----------------------------------------------------------------------------
1683
# ----------------------------------------------------------------------------
1685
create table t1 ( f1 char(10));
1686
insert into t1 values ("Abcd");
1690
send select * from t1;
1693
# 2. Test with error
1695
--send select * from t2;
1696
--error ER_NO_SUCH_TABLE
1699
# 3. test send of next stmt
1705
# 4. Non-query stmt betwen send and reap allowed
1707
--send select * from t1;
1709
--echo Result coming up
1712
# 5. Test of send_eval
1714
--let $my_stmt= select * from t1;
1715
--send_eval $my_stmt
1718
# 6. Test that mysqltest does not allow query stmt between send and reap
1719
# Untestable directly as it causes mysqltest to fail
1721
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.in
1722
--send select * from t1;
1727
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.in 2>&1
1728
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.in;
1732
# ----------------------------------------------------------------------------
1733
# test for remove_file
1734
# ----------------------------------------------------------------------------
1737
--exec echo "remove_file ;" | $MYSQL_TEST 2>&1
1740
remove_file non_existing_file;
1742
# ----------------------------------------------------------------------------
1743
# test for remove_files_wildcard
1744
# ----------------------------------------------------------------------------
1747
--exec echo "remove_files_wildcard ;" | $MYSQL_TEST 2>&1
1750
remove_files_wildcard non_existing_dir;
1753
remove_files_wildcard non_existing_dir non_existing_file;
1755
# ----------------------------------------------------------------------------
1756
# test for write_file
1757
# ----------------------------------------------------------------------------
1759
--exec echo "write_file ;" | $MYSQL_TEST 2>&1
1762
--exec echo "write_file filename ;" | $MYSQL_TEST 2>&1
1764
# Comment out this test as it confuses cmd.exe with unmatched "
1766
#--exec echo "write_file filename \";" | $MYSQL_TEST 2>&1
1768
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1769
Content for test_file1
1771
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1772
cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1773
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1775
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp END_DELIMITER;
1776
Content for test_file1 contains EOF
1778
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1780
# write to already exisiting file
1781
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1783
--exec echo "write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;" | $MYSQL_TEST 2>&1
1785
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1787
# ----------------------------------------------------------------------------
1788
# test for append_file
1789
# ----------------------------------------------------------------------------
1791
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1792
Content for test_file1
1794
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1796
append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1799
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1801
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1802
append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1803
Appended text on nonexisting file
1806
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1808
# Test append_file within while
1809
let $outer= 2; # Number of outer loops
1812
append_file $MYSQLTEST_VARDIR/tmp/app_while.tmp;
1813
These lines should be repeated,
1814
if things work as expected
1819
cat_file $MYSQLTEST_VARDIR/tmp/app_while.tmp;
1820
remove_file $MYSQLTEST_VARDIR/tmp/app_while.tmp;
1822
# ----------------------------------------------------------------------------
1824
# ----------------------------------------------------------------------------
1826
--write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp
1828
for cat_file command
1831
cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1832
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1835
--exec echo "cat_file non_existing_file;" | $MYSQL_TEST 2>&1
1837
# ----------------------------------------------------------------------------
1838
# test for diff_files
1839
# ----------------------------------------------------------------------------
1841
--write_file $MYSQLTEST_VARDIR/tmp/diff1.tmp
1843
for diff_file command
1847
--write_file $MYSQLTEST_VARDIR/tmp/diff2.tmp
1849
for diff_file command
1853
--write_file $MYSQLTEST_VARDIR/tmp/diff3.tmp
1855
for diff_file command
1859
--write_file $MYSQLTEST_VARDIR/tmp/diff4.tmp
1861
for diff_file command
1865
# Compare equal files
1866
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp
1867
--diff_files $MYSQLTEST_VARDIR/tmp/diff2.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp
1869
# Compare files that differ in size
1871
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff3.tmp
1873
--diff_files $MYSQLTEST_VARDIR/tmp/diff3.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp
1875
# Compare files that differ only in content
1877
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff4.tmp
1879
--diff_files $MYSQLTEST_VARDIR/tmp/diff4.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp
1881
# Compare equal files, again...
1882
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp
1884
--remove_file $MYSQLTEST_VARDIR/tmp/diff1.tmp
1885
--remove_file $MYSQLTEST_VARDIR/tmp/diff2.tmp
1886
--remove_file $MYSQLTEST_VARDIR/tmp/diff3.tmp
1887
--remove_file $MYSQLTEST_VARDIR/tmp/diff4.tmp
1890
# ----------------------------------------------------------------------------
1891
# test for file_exist
1892
# ----------------------------------------------------------------------------
1894
--exec echo "file_exists ;" | $MYSQL_TEST 2>&1
1897
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1899
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1900
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1901
Content for test_file1
1903
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1904
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1906
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
1909
# ----------------------------------------------------------------------------
1910
# test for copy_file
1911
# ----------------------------------------------------------------------------
1912
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1916
copy_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp;
1917
file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp;
1918
remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp;
1919
remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp;
1922
--exec echo "copy_file ;" | $MYSQL_TEST 2>&1
1925
--exec echo "copy_file from_file;" | $MYSQL_TEST 2>&1
1928
# ----------------------------------------------------------------------------
1929
# test for move_file
1930
# ----------------------------------------------------------------------------
1932
# - Check that if source file does not exist, nothing will be created.
1935
file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp;
1937
file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp;
1939
move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp;
1941
file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp;
1943
file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp;
1945
# - Check that if source file exists, everything works properly.
1947
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1951
move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp;
1953
file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp;
1954
file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp;
1956
# - Check that if destination file exists, everything works properly.
1957
# (file2.tmp exists from the previous check; file1.tmp needs to be created)
1959
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1963
move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp;
1965
file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp;
1966
file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp;
1967
remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp;
1972
--exec echo "move_file ;" | $MYSQL_TEST 2>&1
1975
--exec echo "move_file from_file;" | $MYSQL_TEST 2>&1
1977
# ----------------------------------------------------------------------------
1979
# ----------------------------------------------------------------------------
1980
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1984
chmod 0000 $MYSQLTEST_VARDIR/tmp/file1.tmp;
1985
# The below write fails, but --error is not implemented
1987
#--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1991
chmod 0777 $MYSQLTEST_VARDIR/tmp/file1.tmp;
1992
remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp;
1993
--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp
1997
remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp;
2000
--exec echo "chmod ;" | $MYSQL_TEST 2>&1
2003
--exec echo "chmod 0 from_file;" | $MYSQL_TEST 2>&1
2006
--exec echo "chmod 08 from_file;" | $MYSQL_TEST 2>&1
2009
--exec echo "chmod from_file;" | $MYSQL_TEST 2>&1
2012
--exec echo "chmod ABZD from_file;" | $MYSQL_TEST 2>&1
2015
--exec echo "chmod 06789 from_file;" | $MYSQL_TEST 2>&1
2018
# ----------------------------------------------------------------------------
2020
# ----------------------------------------------------------------------------
2034
--exec echo "perl TOO_LONG_DELIMITER ;" | $MYSQL_TEST 2>&1
2045
# Test perl within while, also with if being false first iteration
2052
print "val is $val\n";
2059
# ----------------------------------------------------------------------------
2061
# ----------------------------------------------------------------------------
2064
--exec echo "die test of die;" | $MYSQL_TEST 2>&1
2067
# ----------------------------------------------------------------------------
2069
# ----------------------------------------------------------------------------
2071
--exec echo "echo Some output; exit; echo Not this;" | $MYSQL_TEST 2>&1
2073
# ----------------------------------------------------------------------------
2074
# test for sorted_result
2075
# ----------------------------------------------------------------------------
2077
create table t1( a int, b char(255), c timestamp);
2078
insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 2", '2007-04-05');
2079
insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 3", '2007-04-05');
2083
# Should not be sorted
2102
# 1. Assignment of result set sorting
2104
SELECT 2 as "my_col"
2109
SELECT 2 as "my_col" UNION SELECT 1;
2111
SELECT 2 as "my_col"
2115
# 2. Ensure that the table header will be not sorted into the result
2121
# 3. Ensure that an empty result set does not cause problems
2122
CREATE TABLE t1( a CHAR);
2127
# 4. Ensure that NULL values within the result set do not cause problems
2128
SELECT NULL as "my_col1",2 AS "my_col2"
2132
SELECT NULL as "my_col1",2 AS "my_col2"
2136
SELECT 2 as "my_col1",NULL AS "my_col2"
2140
SELECT 2 as "my_col1",NULL AS "my_col2"
2144
# 5. "sorted_result" changes nothing when applied to a non query statement.
2148
# 6. Show that "sorted_result;" before the "SET @a = 17;" above does not affect
2149
# the now following query.
2150
SELECT 2 as "my_col"
2154
# 7. Ensure that "sorted_result" in combination with $variables works
2155
let $my_stmt=SELECT 2 as "my_col"
2161
# 8. Ensure that "sorted_result " does not change the semantics of
2162
# "--error ...." or the protocol output after such an expected failure
2164
--error ER_NO_SUCH_TABLE
2166
SELECT '2' as "my_col1",2 as "my_col2"
2168
SELECT '1',1 from t2;
2170
# 9. Ensure that several result formatting options including "sorted_result"
2171
# - have all an effect
2172
# - "--sorted_result" does not need to be direct before the statement
2173
# - Row sorting is applied after modification of the column content
2175
--replace_column 1 #
2176
SELECT '1' as "my_col1",2 as "my_col2"
2180
# 10. Ensure that at least 1024 rows within a result set do not cause problems
2182
CREATE TABLE t1 (f1 INT);
2183
INSERT INTO t1 SET f1 = 1024;
2184
INSERT INTO t1 SELECT f1 - 1 FROM t1;
2185
INSERT INTO t1 SELECT f1 - 2 FROM t1;
2186
INSERT INTO t1 SELECT f1 - 4 FROM t1;
2187
INSERT INTO t1 SELECT f1 - 8 FROM t1;
2188
INSERT INTO t1 SELECT f1 - 16 FROM t1;
2189
INSERT INTO t1 SELECT f1 - 32 FROM t1;
2190
INSERT INTO t1 SELECT f1 - 64 FROM t1;
2191
INSERT INTO t1 SELECT f1 - 128 FROM t1;
2192
INSERT INTO t1 SELECT f1 - 256 FROM t1;
2193
INSERT INTO t1 SELECT f1 - 512 FROM t1;
2194
--disable_result_log
2200
# ----------------------------------------------------------------------------
2201
# test for lowercase_result
2202
# ----------------------------------------------------------------------------
2206
SELECT "500g BLļæ½Bļæ½RSYLTETļæ½Y" AS "WILL BE lower cased";
2208
# 2. test that it does not apply to next statement
2209
SELECT "UPPER" AS "WILL NOT BE lower cased";
2211
# 3. test that it does not affect non-SQL or the following statement
2214
SELECT 0 as "UP AGAIN";
2216
# 4. test that it works with eval and variables
2217
let $lower_stmt=SELECT "ABCdef" AS "uvwXYZ";
2221
# 5. test that it works in combination with sort
2224
SELECT "Xyz" AS Name UNION SELECT "Abc" as Name ORDER BY Name DESC;
2226
# 6. Test combination with replace, and that lower casing is done first
2228
--replace_result old new
2229
SELECT 1 as "SOME OLD TEXT";
2231
# 7. Test missing lower casing of "unknown" characters
2232
--character_set utf8
2234
SELECT 0 as "WILL NOT lower case ļæ½ļæ½ļæ½";
2235
--character_set latin1
2237
# ----------------------------------------------------------------------------
2238
# Some coverage tests
2239
# ----------------------------------------------------------------------------
2242
--exec $MYSQL_TEST --help 2>&1 > /dev/null
2243
--exec $MYSQL_TEST --version 2>&1 > /dev/null
2245
--disable_abort_on_error
2247
--exec $MYSQL_TEST a b c 2>&1 > /dev/null
2248
--enable_abort_on_error
2251
# ----------------------------------------------------------------------------
2252
# test for query_get_value
2253
# ----------------------------------------------------------------------------
2256
a int, b varchar(255), c datetime
2258
SHOW COLUMNS FROM t1;
2260
#------------ Positive tests ------------
2261
# 1. constant parameters
2262
# value is simple string without spaces
2263
let $value= query_get_value(SHOW COLUMNS FROM t1, Type, 1);
2264
--echo statement=SHOW COLUMNS FROM t1 row_number=1, column_name="Type", Value=$value
2265
let $value= query_get_value("SHOW COLUMNS FROM t1", Type, 1);
2266
--echo statement="SHOW COLUMNS FROM t1" row_number=1, column_name="Type", Value=$value
2268
# 2. $variables as parameters
2270
let $my_show= SHOW COLUMNS FROM t1;
2271
let $column_name= Default;
2273
let $value= query_get_value($my_show, $column_name, $row_number);
2274
--echo statement=$my_show row_number=$row_number, column_name=$column_name, Value=$value
2276
# 3. result set of a SELECT (not recommended, because projection and
2277
# selection could be done much better by pure SELECT functionality)
2278
# value is string with space in the middle
2279
let $value= query_get_value(SELECT 'A B' AS "MyColumn", MyColumn, 1);
2280
--echo value= ->$value<-
2282
# 4. column name with space
2283
let $value= query_get_value(SELECT 1 AS "My Column", My Column, 1);
2284
--echo value= $value
2286
# 4.1 Query containing , protected by quotes, quotes also on column
2287
let $value= query_get_value('SELECT 1 as a, 2 as b', "b", 1);
2288
--echo value= $value
2290
#------------ Negative tests ------------
2291
# 5. Incomplete statement including missing parameters
2292
# 5.1 incomplete statement
2294
--exec echo "let \$value= query_get_value(SHOW;" | $MYSQL_TEST 2>&1
2297
--exec echo "let \$value= query_get_value;" | $MYSQL_TEST 2>&1
2298
# 5.3 missing column name
2300
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1);" | $MYSQL_TEST 2>&1
2301
# 5.4 missing row number
2303
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, Field);" | $MYSQL_TEST 2>&1
2305
# 6. Somehow "wrong" value of parameters
2307
# 6.1.1 non sense number 0
2308
let $value= initialized;
2309
let $value= query_get_value(SHOW COLUMNS FROM t1, Field, 0);
2310
--echo value= $value
2311
# 6.1.2 after the last row
2312
let $value= initialized;
2313
let $value= query_get_value(SHOW COLUMNS FROM t1, Field, 10);
2314
--echo value= $value
2315
# 6.1.3 invalid row number
2317
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, Field, notnumber);" | $MYSQL_TEST 2>&1
2318
# 6.2 column name parameter, name of not existing column
2320
--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, column_not_exists, 1);" | $MYSQL_TEST 2>&1
2321
# 6.3. statement which never gives a result set
2323
--exec echo "let \$value= query_get_value(SET @A = 1, Field, 1);" | $MYSQL_TEST 2>&1
2324
# 6.4. statement contains a ","
2325
# Note: There is no need to improve this, because we need query_get_value
2326
# for SHOW commands only.
2328
--exec echo "let \$value= query_get_value(SELECT 1 AS "A", 1 AS "B", 1);" | $MYSQL_TEST 2>&1
2330
# 7. empty result set
2331
let $value= initialized;
2332
let $value= query_get_value(SELECT a FROM t1, a, 1);
2333
--echo value= $value
2335
# 9. failing statement
2337
--exec echo "let \$value= query_get_value(SHOW COLNS FROM t1, Field, 1);" | $MYSQL_TEST 2>&1
2339
# 10. Artificial example how to process a complete SHOW result set:
2340
let $show_statement= SHOW COLUMNS FROM t1;
2345
--echo Field Type Null Key Default Extra
2348
let $Field= query_get_value($show_statement, Field, $rowno);
2349
if (`SELECT '$Field' = 'No such row'`)
2353
if (`SELECT '$Field' <> 'No such row'`)
2355
let $Type= query_get_value($show_statement, Type, $rowno);
2356
let $Null= query_get_value($show_statement, Null, $rowno);
2357
if (`SELECT '$Null' = 'YES'`)
2361
let $Key= query_get_value($show_statement, Key, $rowno);
2362
let $Default= query_get_value($show_statement, Default, $rowno);
2363
let $Extra= query_get_value($show_statement, Extra, $rowno);
2364
--echo $Field $Type $Null ->$Key<- $Default $Extra
2369
--echo Number of columns with Default NULL: $count
2371
eval $show_statement;
2375
# ----------------------------------------------------------------------------
2376
# Test change_user command
2377
# ----------------------------------------------------------------------------
2380
--exec echo "--change_user root,,inexistent" | $MYSQL_TEST 2>&1
2383
--exec echo "--change_user inexistent,,test" | $MYSQL_TEST 2>&1
2386
--exec echo "--change_user root,inexistent,test" | $MYSQL_TEST 2>&1
2390
--change_user root,,
2391
--change_user root,,test
2393
# ----------------------------------------------------------------------------
2394
# Test mkdir and rmdir command
2395
# ----------------------------------------------------------------------------
2397
mkdir $MYSQLTEST_VARDIR/tmp/testdir;
2398
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
2400
# Directory already exist
2401
mkdir $MYSQLTEST_VARDIR/tmp/testdir;
2403
mkdir $MYSQLTEST_VARDIR/tmp/testdir;
2405
# Remove dir with file inside
2406
write_file $MYSQLTEST_VARDIR/tmp/testdir/file1.txt;
2410
list_files $MYSQLTEST_VARDIR/tmp/testdir;
2411
# list_files gets the directory list before creating the new file
2412
list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir *;
2413
list_files_append_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir *2*;
2414
list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir file?.txt;
2415
list_files_append_file $MYSQLTEST_VARDIR/tmp/testdir/file3.txt $MYSQLTEST_VARDIR/tmp/testdir file*.txt;
2416
diff_files $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir/file3.txt;
2418
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
2420
cat_file $MYSQLTEST_VARDIR/tmp/testdir/file3.txt;
2422
list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/file11.txt $MYSQLTEST_VARDIR/tmp/testdir file?.txt;
2423
remove_files_wildcard $MYSQLTEST_VARDIR/tmp/testdir file?.txt;
2424
list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/dir-list.txt $MYSQLTEST_VARDIR/tmp/testdir file*.txt;
2425
cat_file $MYSQLTEST_VARDIR/tmp/testdir/dir-list.txt;
2426
remove_files_wildcard $MYSQLTEST_VARDIR/tmp/testdir file*.txt;
2427
list_files $MYSQLTEST_VARDIR/tmp/testdir;
2428
remove_files_wildcard $MYSQLTEST_VARDIR/tmp/testdir;
2429
list_files $MYSQLTEST_VARDIR/tmp/testdir;
2430
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
2433
# Bug#36041 mysql-test-run doesn't seem to string match 100% effectively
2437
--replace_result c:\\a.txt z
2438
SELECT 'c:\\a.txt' AS col;
2441
# Bug#32307 mysqltest - does not detect illegal if syntax
2449
--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
2450
if ($mysql_errno != 1436)
2452
echo ^ Should not be allowed!
2456
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
2457
remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
2460
# ----------------------------------------------------------------------------
2461
# Test that -- is not allowed as comment, only as mysqltest builtin command
2462
# ----------------------------------------------------------------------------
2467
--query -- a comment for the server
2469
# Not valid, "select" is not a mysqltest command
2471
--exec echo "--select 1;" | $MYSQL_TEST 2>&1
2474
# ----------------------------------------------------------------------------
2475
# BUG#35701 please allow test language variables in connection and sync_slave_with_master
2476
# Test that "connection $variable" works and that $CURRENT_CONNECTION has the right value.
2477
# ----------------------------------------------------------------------------
2479
connect (con1,localhost,root,,);
2480
--echo $CURRENT_CONNECTION
2481
connect (con2,localhost,root,,);
2482
--echo $CURRENT_CONNECTION
2485
--echo $CURRENT_CONNECTION
2488
--echo $CURRENT_CONNECTION
2491
--echo $CURRENT_CONNECTION
2497
--echo $CURRENT_CONNECTION
2500
--echo $CURRENT_CONNECTION
2502
# Disconnect the not selected connection
2504
--echo $CURRENT_CONNECTION
2506
# Disconnect the selected connection
2508
--echo $CURRENT_CONNECTION
2514
# Wait till we reached the initial number of concurrent sessions
2515
--source include/wait_until_count_sessions.inc